-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
353 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ain/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/MetricRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx; | ||
|
||
import java.util.Optional; | ||
|
||
import io.vertx.core.Context; | ||
import io.vertx.core.http.impl.HttpServerRequestInternal; | ||
import io.vertx.core.spi.observability.HttpRequest; | ||
|
||
public final class MetricRequest { | ||
private final HttpRequest request; | ||
|
||
MetricRequest(final HttpRequest request) { | ||
this.request = request; | ||
} | ||
|
||
Optional<Context> getContext() { | ||
if (request instanceof HttpServerRequestInternal) { | ||
return Optional.of(((HttpServerRequestInternal) request).context()); | ||
} else { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
static MetricRequest request(final HttpRequest httpRequest) { | ||
return new MetricRequest(httpRequest); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...ntelemetry/runtime/tracing/intrumentation/vertx/OpenTelemetryVertxHttpMetricsFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx; | ||
|
||
import io.quarkus.vertx.http.runtime.ExtendedQuarkusVertxHttpMetrics; | ||
import io.vertx.core.VertxOptions; | ||
import io.vertx.core.http.HttpServerOptions; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.core.spi.VertxMetricsFactory; | ||
import io.vertx.core.spi.metrics.HttpServerMetrics; | ||
import io.vertx.core.spi.metrics.VertxMetrics; | ||
import io.vertx.core.spi.observability.HttpRequest; | ||
|
||
/** | ||
* This is used to retrieve the route name from Vert.x. This is useful for OpenTelemetry to generate the Span name and | ||
* <code>http.route</code> attribute. Right now, there is no other way to retrieve the route name from Vert.x using the | ||
* Telemetry SPI, so we need to rely on the Metrics SPI. | ||
* <p> | ||
* Right now, it is not possible to register multiple <code>VertxMetrics</code>, meaning that only a single one is | ||
* available per Quarkus instance. To avoid clashing with other extensions that provide Metrics data (like the | ||
* Micrometer extension), we only register the {@link OpenTelemetryVertxHttpMetricsFactory} if the | ||
* <code>VertxHttpServerMetrics</code> is not available in the runtime. | ||
*/ | ||
public class OpenTelemetryVertxHttpMetricsFactory implements VertxMetricsFactory { | ||
@Override | ||
public VertxMetrics metrics(final VertxOptions options) { | ||
return new OpenTelemetryVertxHttpServerMetrics(); | ||
} | ||
|
||
public static class OpenTelemetryVertxHttpServerMetrics | ||
implements HttpServerMetrics<MetricRequest, Object, Object>, | ||
VertxMetrics, ExtendedQuarkusVertxHttpMetrics { | ||
|
||
@Override | ||
public HttpServerMetrics<?, ?, ?> createHttpServerMetrics(final HttpServerOptions options, | ||
final SocketAddress localAddress) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public MetricRequest requestBegin(final Object socketMetric, final HttpRequest request) { | ||
return MetricRequest.request(request); | ||
} | ||
|
||
@Override | ||
public void requestRouted(final MetricRequest requestMetric, final String route) { | ||
if (route != null) { | ||
requestMetric.getContext().ifPresent(context -> context.putLocal("VertxRoute", route)); | ||
} | ||
} | ||
|
||
@Override | ||
public ConnectionTracker getHttpConnectionTracker() { | ||
// To be implemented if we decide to instrument with OpenTelemetry. See VertxMeterBinderAdapter for an example. | ||
return ExtendedQuarkusVertxHttpMetrics.NOOP_CONNECTION_TRACKER; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-integration-test-opentelemetry-minimal</artifactId> | ||
<name>Quarkus - Integration Tests - OpenTelemetry minimal (No HTTP)</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-vertx</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-opentelemetry</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-testing</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
|
||
<artifactId>quarkus-vertx-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-opentelemetry-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native-image</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
|
||
<properties> | ||
<quarkus.native.enabled>true</quarkus.native.enabled> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>${native.surefire.skip}</skipTests> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
<native.image.path> | ||
${project.build.directory}/${project.build.finalName}-runner | ||
</native.image.path> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
Oops, something went wrong.