-
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
12 changed files
with
165 additions
and
23 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
docs/src/main/asciidoc/telemetry-micrometer-to-opentelemetry.adoc
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,53 @@ | ||
//// | ||
This guide is maintained in the main Quarkus repository | ||
and pull requests should be submitted there: | ||
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc | ||
//// | ||
[id=telemetry-micrometer-opentelemetry] | ||
= Micrometer and OpenTelemetry extension | ||
include::_attributes.adoc[] | ||
:diataxis-type: reference | ||
:categories: observability | ||
:summary: Guide to send Micrometer data to OpenTelemetry. | ||
:topics: observability,opentelemetry,metrics,micrometer,tracing,logs | ||
:extensions: io.quarkus:quarkus-micrometer-opentelemetry-bridge | ||
|
||
This extension provides support for both `Micrometer` and `OpenTelemetry` in Quarkus applications. It streamlines integration by incorporating both extensions along with a bridge that enables sending Micrometer metrics via OpenTelemetry. | ||
|
||
[NOTE] | ||
==== | ||
- The xref:telemetry-micrometer.adoc[Micrometer Guide] is available for detailed information about the Micrometer extension. | ||
- The xref:opentelemetry.adoc[OpenTelemetry Guide] provides information about the OpenTelemetry extension. | ||
==== | ||
|
||
The bridge is much more than the simple OTLP registry found in Quarkiverse. In this extension, the OpenTelemetry SDK provides a Micrometer registry implementation. | ||
|
||
This allows the normal use of the Micrometer API, but have the metrics handled by the OpenTelemetry extension. All the configurations of the OpenTelemetry extension are available for this bridge. | ||
|
||
The bridge enables to forward to OpenTelemetry all the automatic instrumentation metrics generated by Micrometer in Quarkus, as well as custom user metrics. | ||
|
||
== Usage | ||
|
||
If you already have your Quarkus project configured, you can add the `quarkus-micrometer-opentelemetry` extension to your project by running the following command in your project base directory: | ||
|
||
:add-extension-extensions: micrometer-opentelemetry | ||
include::{includes}/devtools/extension-add.adoc[] | ||
|
||
This will add the following to your build file: | ||
|
||
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] | ||
.pom.xml | ||
---- | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-micrometer-opentelemetry</artifactId> | ||
</dependency> | ||
---- | ||
|
||
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] | ||
.build.gradle | ||
---- | ||
implementation("io.quarkus:quarkus-micrometer-opentelemetry") | ||
---- | ||
|
||
|
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
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
2 changes: 1 addition & 1 deletion
2
...etry/deployment/JvmCompatibilityTest.java → ...t/compatibility/JvmCompatibilityTest.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
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
84 changes: 84 additions & 0 deletions
84
...quarkus/micrometer/opentelemetry/deployment/compatibility/RestClientUriParameterTest.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,84 @@ | ||
package io.quarkus.micrometer.opentelemetry.deployment.compatibility; | ||
|
||
import io.opentelemetry.sdk.metrics.data.HistogramPointData; | ||
import io.quarkus.micrometer.opentelemetry.deployment.common.InMemoryMetricExporter; | ||
import io.quarkus.micrometer.opentelemetry.deployment.common.InMemoryMetricExporterProvider; | ||
import io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter; | ||
import io.quarkus.rest.client.reactive.Url; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class RestClientUriParameterTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot( | ||
jar -> jar.addClasses(Resource.class, Client.class) | ||
.addClasses(InMemoryMetricExporter.class, | ||
InMemoryMetricExporterProvider.class, | ||
MetricDataFilter.class)) | ||
.overrideConfigKey("quarkus.redis.devservices.enabled", "false") | ||
.overrideConfigKey("quarkus.rest-client.\"client\".url", "http://does-not-exist.io"); | ||
|
||
@Inject | ||
InMemoryMetricExporter metricExporter; | ||
|
||
@RestClient | ||
Client client; | ||
|
||
@ConfigProperty(name = "quarkus.http.test-port") | ||
Integer testPort; | ||
|
||
@Test | ||
public void testOverride() { | ||
String result = client.getById("http://localhost:" + testPort, "bar"); | ||
assertEquals("bar", result); | ||
|
||
metricExporter.assertCountDataPointsAtLeastOrEqual("http.client.requests", null, 1); | ||
assertEquals(1, metricExporter.find("http.client.requests") | ||
.tag("uri", "/example/{id}") | ||
.lastReadingDataPoint(HistogramPointData.class).getCount()); | ||
} | ||
|
||
@Path("/example") | ||
@RegisterRestClient(baseUri = "http://dummy") | ||
public interface Client { | ||
|
||
@GET | ||
@Path("/{id}") | ||
String getById(@Url String baseUri, @PathParam("id") String id); | ||
} | ||
|
||
@Path("/example") | ||
public static class Resource { | ||
|
||
@RestClient | ||
Client client; | ||
|
||
@GET | ||
@Path("/{id}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String example() { | ||
return "bar"; | ||
} | ||
|
||
@GET | ||
@Path("/call") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String call() { | ||
return client.getById("http://localhost:8080", "1"); | ||
} | ||
} | ||
} |
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
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