Opentelemetry2
Since Camel 4.11
This module is the implementation of the common camel-telemetry interface based on OpenTelemetry technology. The name used here as camel-opentelemetry2 is done to distinguish on the existing camel-opentelemetry which was based on an older Camel tracing specification. You’re invited to start replacing the older camel-opentelemetry with this one instead as it may become the default component in future version of Camel.
this component has slight differences compared to the camel-openetelemetry and is meant to solve a few inconsistencies identified. |
Configuration
The configuration properties for the OpenTelemetry2 tracer are:
| Option | Default | Description |
|---|---|---|
| Sets exclude pattern that will disable tracing for those spans that matches the pattern. The variable is a comma separated values of filters to execute (eg, | |
|
| Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern property to filter out Processors |
| false | Add the generated telemetry |
Using with standalone Camel
If you use camel-main as standalone Camel, then you can enable and use OpenTelemetry without Java code.
Add camel-opentelemetry2 component in your POM, and configure in application.properties:
camel.opentelemetry2.enabled = true
# you can configure the other options
# camel.opentelemetry2.traceProcessors = true When starting the application, you may need to configure a few OpenTelemetry SDK variables, as you can see in te following example:
$ java -Dotel.metrics.exporter=none -Dotel.logs.exporter=none -jar my-app.jar Java Agent
Your application will require a Java agent in order to get the traces generated by the Camel application and push to the tracing server.
| certain runtimes (ie, Quarkus) may provide an inner client which pushes traces to the server. Make sure to read each specific Camel runtime documentation. |
Download the latest version.
This package includes the instrumentation agent as well as instrumentation for all supported libraries and all available data exporters. The package provides a completely automatic, out-of-the-box experience. Enable the instrumentation agent using the -javaagent flag to the JVM.
java -javaagent:path/to/opentelemetry-javaagent.jar \
-Dotel. ... \
-jar myapp.jar By default, the OpenTelemetry Java agent uses OTLP exporter configured to send data to OpenTelemetry collector at http://localhost:4318.
Configuration parameters are passed as Java system properties (-D flags) or as environment variables. See the configuration documentation for the full list of configuration items. For example:
java -javaagent:path/to/opentelemetry-javaagent.jar \
-Dotel.service.name=your-service-name \
-Dotel.traces.exporter=otlp \
-jar myapp.jar Collect OpenTelemetry traces
OpenTelemetry is a tracing protocol which is implemented by several vendors. You can use the Jaeger project which provides an open source all in one tracing application. See details how to run it in Jaeger getting started guide.
MDC logging
You can leverage the traceHeadersInclusion to include the generated CAMEL_TRACE_ID and CAMEL_SPAN_ID into the Camel Exchange and together with camel-mdc you can make those headers available in the MDC context (via camel.mdc.customHeaders=CAMEL_TRACE_ID,CAMEL_SPAN_ID configuration). This is the idiomatic way in Camel.
As an alternative, you can add Mapped Diagnostic Context tracing information (ie, trace_id and span_id) adding the specific Opentelemetry Logger MDC auto instrumentation. The logging configuration depends on the logging framework you’re using.