Opentelemetry2
JVM since3.22.0 Native since3.22.0
Implementation of Camel Opentelemetry based on the Camel Telemetry spec
Maven coordinates
Or add the coordinates to your existing project:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-opentelemetry2</artifactId>
</dependency> Check the User guide for more information about writing Camel Quarkus applications.
Usage
The extension automatically creates a Camel OpenTelemetryTracer and binds it to the Camel registry.
In order to send the captured traces to a tracing system, you need to configure some properties within application.properties like those below.
This extension addresses inconsistencies found in the original camel-quarkus-opentelemetry extensions and offers a more robust implementation. |
# OTLP exporter endpoint
quarkus.otel.exporter.otlp.traces.endpoint=http://localhost:4317 Refer to the Quarkus OpenTelemetry guide for a full list of configuration options.
Route endpoints can be excluded from tracing by configuring a property named quarkus.camel.opentelemetry.exclude-patterns in application.properties. For example:
# Exclude all direct & netty-http endpoints from tracing
quarkus.camel.opentelemetry2.exclude-patterns=direct:*,netty-http:* | The use of the OpenTelemetry Agent is not needed nor recommended. Quarkus Extensions and the libraries they provide, are directly instrumented. Also, the agent does not work in native mode. |
Exporters
Quarkus OpenTelemetry defaults to the standard OTLP exporter defined in OpenTelemetry. Additional exporters will be available in the Quarkiverse quarkus-opentelemetry-exporter project.
Tracing CDI bean method execution
When instrumenting the execution of CDI bean methods from Camel routes, you should annotate such methods with io.opentelemetry.extension.annotations.WithSpan. Methods annotated with @WithSpan will create a new Span and establish any required relationships with the current Trace context.
For example, to instrument a CDI bean from a Camel route, first ensure the appropriate methods are annotated with @WithSpan.
@ApplicationScoped
@Named("myBean")
public class MyBean {
@WithSpan
public String greet() {
return "Hello World!";
}
} Next, use the bean in your Camel route.
To ensure that the sequence of recorded spans is correct, you must use the full to("bean:") endpoint URI and not the shortened .bean() EIP DSL method. |
public class MyRoutes extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:executeBean")
.to("bean:myBean?method=greet");
}
} There is more information about CDI instrumentation in the Quarkus OpenTelemetry guide.
Additional Camel Quarkus configuration
| Configuration property | Type | Default |
|---|---|---|
Sets whether to disable tracing for endpoint URIs or Processor ids that match the given comma separated patterns. The pattern can take the following forms:
|
| |
Sets whether to create new OpenTelemetry spans for each Camel Processor. Use the excludePatterns property to filter out Processors. |
|
|
If set to |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.