Questo contenuto non è disponibile nella lingua selezionata.

Chapter 93. OpenTelemetry


Since Camel 3.5

The OpenTelemetry component is used for tracing and timing the incoming and outgoing Camel messages using OpenTelemetry.

Events (spans) are captured for incoming and outgoing messages that are sent to/from Camel.

93.1. Configuration

The configuration properties for the OpenTelemetry tracer are:

Expand
OptionDefaultDescription

excludePatterns

 

Sets exclude pattern(s) that will disable tracing for Camel messages that matches the pattern. The content is a Set<String> where the key is a pattern. The pattern uses the rules from Intercept.

encoding

false

Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.

93.1.1. Configuration

Add the camel-opentelemetry component in your POM, in addition to any specific dependencies associated with the chosen OpenTelemetry compliant Tracer.

To explicitly configure OpenTelemetry support, instantiate the OpenTelemetryTracer and initialize the camel context. You can optionally specify a Tracer, or alternatively it can be implicitly discovered using the Registry

OpenTelemetryTracer otelTracer = new OpenTelemetryTracer();
// By default it uses the DefaultTracer, but you can override it with a specific OpenTelemetry Tracer implementation.
otelTracer.setTracer(...);
// And then initialize the context
otelTracer.init(camelContext);
Copy to Clipboard Toggle word wrap

93.2. Spring Boot

Add the camel-opentelemetry-starter dependency, and then turn on the OpenTracing by annotating the main class with @CamelOpenTelemetry.

The OpenTelemetryTracer is implicitly obtained from the camel context’s Registry, unless a OpenTelemetryTracer bean has been defined by the application.

93.3. Java Agent

Download the latest version of Java agent.

This package includes the instrumentation agent as well as instrumentations 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 \
     -jar myapp.jar
Copy to Clipboard Toggle word wrap

By default, the OpenTelemetry Java agent uses OTLP exporter configured to send data to OpenTelemetry collector at http://localhost:4317.

Configuration parameters are passed as Java system properties (-D flags) or as environment variables. See Configuring the agent and OpenTelemetry auto-configurationfor the full list of configuration items. For example:

java -javaagent:path/to/opentelemetry-javaagent.jar \
     -Dotel.service.name=your-service-name \
     -Dotel.traces.exporter=jaeger \
     -jar myapp.jar
Copy to Clipboard Toggle word wrap

93.4. Spring Boot Auto-Configuration

Add the following dependency to your pom.xml for this component:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-opentelemetry-starter</artifactId>
  <version>3.20.1.redhat-00031</version>
  <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap

The component supports 2 options, which are listed below.

Expand
NameDescriptionDefaultType

camel.opentelemetry.encoding

Activate or deactivate the dash encoding in headers (required by JMS) for messaging.

 

Boolean

camel.opentelemetry.exclude-patterns

Sets exclude pattern(s) that will disable the tracing for the Camel messages that matches the pattern.

 

Set

93.5. MDC Logging

When MDC Logging is enabled for the active Camel context, the Trace ID and Span ID are added and removed from the MDC for each route, where the keys are trace_id and span_id, respectively.

Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat