Skip to content

Commit d70708e

Browse files
committed
Otel exporters doc
1 parent 71c8d21 commit d70708e

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

docs/src/main/asciidoc/opentelemetry.adoc

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,90 @@ When creating manual instrumentation, while naming metrics or attributes you sho
251251

252252
== Exporters
253253

254-
=== Default
254+
=== The Default
255255

256-
The Quarkus OpenTelemetry extension uses its own signal exporters built on top of Vert.x for optimal performance and maintainability.
256+
The Quarkus OpenTelemetry extension uses its own signal exporters built on top of Vert.x for optimal performance and maintainability. All *Quarkus built in exporters use the OTLP protocol* through a couple of data senders, using `grpc` (the default) and `http/protobuf`.
257257

258-
The exporter is automatically wired with CDI, that's why the `quarkus.otel.traces.exporter` and `quarkus.otel.metrics.exporter` properties default to `cdi`.
258+
The active exporter is automatically wired by CDI, that's why the `quarkus.otel.traces.exporter`, `quarkus.otel.metrics.exporter` and `quarkus.otel.logs.exporter` properties default value is `cdi`. This is not because of the protocol being used in the data transfer but because of how the exporters are wired.
259259

260-
The `quarkus.otel.exporter.otlp.protocol` defaults to `grpc` but `http/protobuf` can also be used.
260+
CDI (Context Dependency Injection) will manage the exporters to use, according to the selected protocol or when applications implement their own CDI exporter, like in tests.
261+
262+
The `quarkus.otel.exporter.otlp.protocol` property instructs Quarkus to switch the senders and defaults to `grpc` but `http/protobuf` can also be used.
261263

262264
NOTE: If you change the protocol, you also need to change the port in the endpoint. The default port for `grpc` is `4317` and for `http/protobuf` is `4318`.
263265

266+
=== Using CDI to produce a test exporter
267+
268+
Leaving the default as CDI is particularly useful for tests. In the following example a Span exporter class is wired with CDI and then the telemetry can be used in test code.
269+
270+
Creating a custom `SpanExporter` bean:
271+
272+
[source,java]
273+
----
274+
@ApplicationScoped
275+
static class InMemorySpanExporterProducer {
276+
@Produces
277+
@Singleton
278+
InMemorySpanExporter inMemorySpanExporter() {
279+
return InMemorySpanExporter.create();
280+
}
281+
}
282+
----
283+
284+
Where `InMemorySpanExporter` is a class from the OpenTelemetry test utilities dependency:
285+
286+
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
287+
.pom.xml
288+
----
289+
<dependency>
290+
<groupId>io.opentelemetry</groupId>
291+
<artifactId>opentelemetry-sdk-testing</artifactId>
292+
<scope>test</scope>
293+
</dependency>
294+
----
295+
296+
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
297+
.build.gradle
298+
----
299+
implementation("io.opentelemetry:opentelemetry-sdk-testing")
300+
----
301+
302+
The bean of that class can be injected to access the telemetry data. This is an example to obtain the spans:
303+
304+
[source, java]
305+
----
306+
@Inject
307+
InMemorySpanExporter inMemorySpanExporter;
308+
309+
//...
310+
311+
List<SpanData> finishedSpanItems = inMemorySpanExporter.getFinishedSpanItems();
312+
----
313+
314+
If this is used on an integration test project, you should access the class from inside the running process and not from the test class.
315+
A viable option could be to expose that data through a rest endpoint method:
316+
317+
[source,java]
318+
----
319+
@GET
320+
@Path("/export")
321+
public List<SpanData> exportTraces() {
322+
return inMemorySpanExporter.getFinishedSpanItems()
323+
.stream()
324+
.filter(sd -> !sd.getName().contains("export")) <1>
325+
.collect(Collectors.toList());
326+
}
327+
----
328+
<1> This excludes calls to the export endpoint itself.
329+
330+
For more details please take a look to the https://github.com/quarkusio/quarkus/blob/main/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/ExporterResource.java[ExporterResource] in the Quarkus integration tests.
331+
332+
=== The OpenTelemetry OTLP exporter
333+
334+
This is currently not supported in quarkus. Configuration example for traces: `quarkus.otel.tracing.exporter=otlp`.
335+
336+
However, it's also not needed because Quarkus own default exporters will send data using the OTLP protocol.
337+
264338
=== On Quarkiverse
265339
Additional exporters will be available in the Quarkiverse https://docs.quarkiverse.io/quarkus-opentelemetry-exporter/dev/index.html[quarkus-opentelemetry-exporter] project.
266340

0 commit comments

Comments
 (0)