You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2026/04/22 08:31:12 UTC

(camel) 01/04: Document how to configure and use opentelemetry-spring-boot-starter as an alternative to the OpenTelemetry agent.

This is an automated email from the ASF dual-hosted git repository.

squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6b7e7c540fbfeb3df6cbcdfa4931fb1996234f52
Author: Bjorn Beskow <bb...@callistaenterprise.se>
AuthorDate: Fri Apr 17 17:25:09 2026 +0200

    Document how to configure and use opentelemetry-spring-boot-starter as an alternative to the OpenTelemetry agent.
---
 .../src/main/docs/opentelemetry2.adoc              | 72 ++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/components/camel-opentelemetry2/src/main/docs/opentelemetry2.adoc b/components/camel-opentelemetry2/src/main/docs/opentelemetry2.adoc
index c07087421106..bb502de4e438 100644
--- a/components/camel-opentelemetry2/src/main/docs/opentelemetry2.adoc
+++ b/components/camel-opentelemetry2/src/main/docs/opentelemetry2.adoc
@@ -110,6 +110,78 @@ As an alternative, you can use the agent's built-in MDC integration.
 . Enable the https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/logger-mdc-instrumentation.md[Logger MDC auto-instrumentation]. This automatically adds `trace_id` and `span_id` to the MDC.
 . Configure your logging framework to include these MDC keys in your log format. The exact configuration depends on the logging library you use.
 
+[[OpenTelemetry-SpringBoot-starter]]
+=== Using the OpenTelemetry Spring Boot starter
+
+An alternative to the OpenTelemetry agent is to use https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/[OpenTelemetry Spring Boot starter].
+
+To ensure version alignment across all OpenTelemetry dependencies, you should
+import the opentelemetry-instrumentation-bom BOM:
+
+[source,xml]
+----
+<dependencyManagement>
+    <dependencies>
+        <dependency>
+            <groupId>io.opentelemetry.instrumentation</groupId>
+            <artifactId>opentelemetry-instrumentation-bom</artifactId>
+            <version>2.26.1</version>
+            <type>pom</type>
+            <scope>import</scope>
+        </dependency>
+    </dependencies>
+</dependencyManagement>
+----
+
+Then add the following dependency for the OpenTelemetry Spring Boot starter:
+
+[source,xml]
+----
+<dependency>
+    <groupId>io.opentelemetry.instrumentation</groupId>
+    <artifactId>opentelemetry-spring-boot-starter</artifactId>
+</dependency>
+----
+
+The starter auto-configures most aspects of the OpenTelemetry instrumentation, with two exceptions:
+No `Tracer` or `ContextPropagators` beans are autoconfigured, they need to be configured manually:
+
+[source,java]
+----
+import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.propagation.ContextPropagators;
+
+@Configuration
+public class OpenTelemetryConfiguration {
+
+  @Bean
+  public Tracer tracer(@Value("${spring.application.name}") String serviceName, OpenTelemetry openTelemetry) {
+    return openTelemetry.getTracer(serviceName);
+  }
+
+  @Bean
+  public ContextPropagators contextPropagators(OpenTelemetry openTelemetry) {
+    return openTelemetry.getPropagators();
+  }
+
+}
+----
+
+The instrumentation can be configured using the standard Spring Boot configuration mechanisms (e.g. using application.yml).
+For a complete list of options, see the official https://opentelemetry.io/docs/zero-code/java/agent/configuration/[agent configuration documentation].
+
+For example, to set the service name and exporter type:
+
+[source,yaml]
+----
+otel:
+  service:
+    name: your-service-name
+  traces:
+    exporter: otlp
+----
+
 === Span customization
 
 When you're working at a very low level, you may need to tweak your metrics and add some in-process custom `span` in order to trace some specific measure of your application. If you need this advanced use case, you can create it during your process by configuring an Opentelemetry Tracer object and share it to your route. For example, in Java DSL: