Skip to content

Commit

Permalink
Initial Observability extension - PromQL client, devservices, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Oct 13, 2023
1 parent e337149 commit 93a6d8e
Show file tree
Hide file tree
Showing 112 changed files with 4,811 additions and 2 deletions.
75 changes: 75 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@
<mutiny-zero.version>1.0.0</mutiny-zero.version>
<pulsar-client.version>3.0.0</pulsar-client.version>
<async-http-client.version>2.12.3</async-http-client.version>
<!-- keep in-sync, if possible, with Micrometer registry Prometheus -->
<prometheus.version>0.16.0</prometheus.version>
<!-- Dev UI -->
<importmap.version>1.0.10</importmap.version>
</properties>
Expand Down Expand Up @@ -463,6 +465,19 @@
<scope>import</scope>
</dependency>

<!-- Prometheus -->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_common</artifactId>
<version>${prometheus.version}</version>
</dependency>


<!-- Quarkus core -->

<dependency>
Expand Down Expand Up @@ -2944,6 +2959,66 @@
<artifactId>quarkus-virtual-threads-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-promql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-victoriametrics</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-testlibs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-testcontainers</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource-victoriametrics</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource-vmagent</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource-grafana</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource-otel-collector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devresource-jaeger</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Quarkus test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public enum Feature {
NARAYANA_LRA,
NARAYANA_STM,
NEO4J,
OBSERVABILITY,
OIDC,
OIDC_CLIENT,
OIDC_CLIENT_FILTER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.quarkus.runtime.util;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
* Transform to "old school" Enumeration from Iterator/Spliterator/Stream
*/
public class EnumerationUtil {
public static <T> Enumeration<T> from(Iterator<T> iterator) {
Objects.requireNonNull(iterator);

return new Enumeration<T>() {
@Override
public boolean hasMoreElements() {
return iterator.hasNext();
}

@Override
public T nextElement() {
return iterator.next();
}
};
}

public static <T> Enumeration<T> from(Spliterator<T> spliterator) {
Objects.requireNonNull(spliterator);

class Adapter implements Enumeration<T>, Consumer<T> {
boolean valueReady;
T nextElement;

public void accept(T t) {
this.valueReady = true;
this.nextElement = t;
}

public boolean hasMoreElements() {
if (!this.valueReady) {
spliterator.tryAdvance(this);
}

return this.valueReady;
}

public T nextElement() {
if (!this.valueReady && !this.hasMoreElements()) {
throw new NoSuchElementException();
} else {
this.valueReady = false;
T t = this.nextElement;
this.nextElement = null;
return t;
}
}
}

return new Adapter();
}

public static <T> Enumeration<T> from(Stream<T> stream) {
return from(stream.spliterator());
}
}
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.quarkus.devservices.common;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -61,6 +63,30 @@ public Optional<ContainerAddress> locateContainer(String serviceName, boolean sh
}
}

/**
* @return container id, if exists
*/
public Optional<String> locateContainer(String serviceName, boolean shared, LaunchMode launchMode,
BiConsumer<Integer, ContainerAddress> consumer) {
if (shared && launchMode == LaunchMode.DEVELOPMENT) {
return lookup(serviceName)
.map(container -> {
Arrays.stream(container.getPorts())
.filter(cp -> Objects.nonNull(cp.getPublicPort()) && Objects.nonNull(cp.getPrivatePort()))
.forEach(cp -> {
ContainerAddress containerAddress = new ContainerAddress(
container.getId(),
DockerClientFactory.instance().dockerHostIpAddress(),
cp.getPublicPort());
consumer.accept(cp.getPrivatePort(), containerAddress);
});
return container.getId();
});
} else {
return Optional.empty();
}
}

public Optional<Integer> locatePublicPort(String serviceName, boolean shared, LaunchMode launchMode, int privatePort) {
if (shared && launchMode == LaunchMode.DEVELOPMENT) {
return lookup(serviceName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public final class ContainerShutdownCloseable implements Closeable {

private static final Logger LOG = Logger.getLogger(ContainerShutdownCloseable.class);

private final GenericContainer container;
private final GenericContainer<?> container;
private final String friendlyServiceName;

/**
* @param container the container to be eventually closed
* @param friendlyServiceName for logging purposes
*/
public ContainerShutdownCloseable(GenericContainer container, String friendlyServiceName) {
public ContainerShutdownCloseable(GenericContainer<?> container, String friendlyServiceName) {
Objects.requireNonNull(container);
Objects.requireNonNull(friendlyServiceName);
this.container = container;
Expand Down
27 changes: 27 additions & 0 deletions extensions/observability/common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>quarkus-observability-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-observability-common</artifactId>
<name>Quarkus - Observability - Common</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.smallrye.config</groupId>
<artifactId>smallrye-config-core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.observability.common;

public final class ContainerConstants {

public static final String GRAFANA = "grafana/grafana:10.1.0";
public static final String JAEGER = "quay.io/jaegertracing/all-in-one:1.48.0";
public static final String OTEL = "otel/opentelemetry-collector-contrib:0.83.0";
public static final String VICTORIA_METRICS = "victoriametrics/victoria-metrics:v1.93.0";
public static final String VM_AGENT = "victoriametrics/vmagent:v1.93.0";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.quarkus.observability.common.config;

import java.util.Locale;
import java.util.Optional;
import java.util.Set;

public abstract class AbstractContainerConfig implements ContainerConfig {

private final String imageName;
private final boolean shared;

public AbstractContainerConfig(String imageName) {
this(imageName, true);
}

public AbstractContainerConfig(String imageName, boolean shared) {
this.imageName = imageName;
this.shared = shared;
}

@Override
public boolean enabled() {
return true;
}

@Override
public String imageName() {
return imageName;
}

@Override
public boolean shared() {
return shared;
}

@Override
public Optional<Set<String>> networkAliases() {
return Optional.empty();
}

@Override
public String label() {
String sn = getClass().getSimpleName().toLowerCase(Locale.ROOT);
return "quarkus-dev-resource-" + sn;
}

@Override
public String serviceName() {
return "quarkus";
}
}
Loading

0 comments on commit 93a6d8e

Please sign in to comment.