This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 74e7c850f971 CAMEL-21622: Add camel.route.id attribute to
camel-telemetry spans
74e7c850f971 is described below
commit 74e7c850f97167d74bfd581b50e8767696791893
Author: Salvatore Mongiardo <[email protected]>
AuthorDate: Tue Jun 16 15:07:47 2026 +0200
CAMEL-21622: Add camel.route.id attribute to camel-telemetry spans
The opentelemetry2 component uses camel-telemetry (not camel-tracing)
as its base framework. The original CAMEL-21622 fix only added
camel.route.id to camel-tracing, so spans produced by the otel2
component are missing this attribute.
Port the same logic: read Exchange.getFromRouteId() in
AbstractSpanDecorator.beforeTracingEvent() and set it as a span tag.
---
.../src/main/java/org/apache/camel/telemetry/TagConstants.java | 1 +
.../org/apache/camel/telemetry/decorators/AbstractSpanDecorator.java | 5 +++++
.../apache/camel/telemetry/decorators/AbstractSpanDecoratorTest.java | 2 ++
3 files changed, 8 insertions(+)
diff --git
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TagConstants.java
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TagConstants.java
index f73742d30382..5ca42942d9e0 100644
---
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TagConstants.java
+++
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TagConstants.java
@@ -21,6 +21,7 @@ public class TagConstants {
public static final String ERROR = "error";
public static final String COMPONENT = "component";
public static final String EXCHANGE_ID = "exchangeId";
+ public static final String ROUTE_ID = "camel.route.id";
public static final String OP = "op";
diff --git
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/decorators/AbstractSpanDecorator.java
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/decorators/AbstractSpanDecorator.java
index 5995ad3ed32b..352b3974fd4c 100644
---
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/decorators/AbstractSpanDecorator.java
+++
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/decorators/AbstractSpanDecorator.java
@@ -114,6 +114,11 @@ public abstract class AbstractSpanDecorator implements
SpanDecorator {
span.setTag(TagConstants.URL_SCHEME, scheme);
span.setTag(TagConstants.EXCHANGE_ID, exchange.getExchangeId());
+ final String routeId;
+ if (exchange != null && (routeId = exchange.getFromRouteId()) != null)
{
+ span.setTag(TagConstants.ROUTE_ID, routeId);
+ }
+
// Including the endpoint URI provides access to any options that may
// have been provided, for subsequent analysis
String uri = endpoint.toString(); // toString will sanitize
diff --git
a/components/camel-telemetry/src/test/java/org/apache/camel/telemetry/decorators/AbstractSpanDecoratorTest.java
b/components/camel-telemetry/src/test/java/org/apache/camel/telemetry/decorators/AbstractSpanDecoratorTest.java
index b16cf9f28341..5bcf53a26b91 100644
---
a/components/camel-telemetry/src/test/java/org/apache/camel/telemetry/decorators/AbstractSpanDecoratorTest.java
+++
b/components/camel-telemetry/src/test/java/org/apache/camel/telemetry/decorators/AbstractSpanDecoratorTest.java
@@ -60,6 +60,7 @@ public class AbstractSpanDecoratorTest {
Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
Mockito.when(endpoint.toString()).thenReturn(TEST_URI);
+ Mockito.when(exchange.getFromRouteId()).thenReturn("myRouteId");
SpanDecorator decorator = new AbstractSpanDecorator() {
@Override
@@ -81,6 +82,7 @@ public class AbstractSpanDecoratorTest {
assertEquals("test", span.tags().get(TagConstants.URL_SCHEME));
assertEquals("uri", span.tags().get(TagConstants.URL_PATH));
assertEquals("query=hello", span.tags().get(TagConstants.URL_QUERY));
+ assertEquals("myRouteId", span.tags().get(TagConstants.ROUTE_ID));
}
@Test