This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 625b89b0853 CAMEL-21302: Use OTEL_ as prefix for these special
exchange property keys.
625b89b0853 is described below
commit 625b89b0853947a11dcb8660f0b64ec0880b477a
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Oct 23 10:43:40 2024 +0200
CAMEL-21302: Use OTEL_ as prefix for these special exchange property keys.
---
.../apache/camel/component/direct/DirectProducer.java | 5 ++---
.../java/org/apache/camel/tracing/ActiveSpanManager.java | 16 ++++++++--------
.../java/org/apache/camel/ExchangeConstantProvider.java | 4 ++--
.../src/main/java/org/apache/camel/Exchange.java | 6 ++++--
.../main/java/org/apache/camel/ExchangePropertyKey.java | 13 ++++++++-----
.../org/apache/camel/saga/InMemorySagaCoordinator.java | 4 ++--
.../modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc | 3 +++
7 files changed, 29 insertions(+), 22 deletions(-)
diff --git
a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
index c1ff8d6a706..721e86b0eca 100644
---
a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
+++
b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java
@@ -96,8 +96,8 @@ public class DirectProducer extends DefaultAsyncProducer {
} else {
//Ensure we can close the CLIENT Scope created by this
DirectProducer
//in the same thread
- if (exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN)
!= null) {
-
exchange.setProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE, Boolean.TRUE);
+ if
(exchange.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN) != null) {
+
exchange.setProperty(ExchangePropertyKey.OTEL_CLOSE_CLIENT_SCOPE, Boolean.TRUE);
}
return consumer.getAsyncProcessor().process(exchange,
callback);
}
@@ -105,7 +105,6 @@ public class DirectProducer extends DefaultAsyncProducer {
} catch (InterruptedException e) {
LOG.info("Interrupted while processing the exchange");
Thread.currentThread().interrupt();
-
exchange.setException(e);
callback.done(true);
return true;
diff --git
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
index db2ba8a59ae..2e581101956 100644
---
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
+++
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
@@ -41,7 +41,7 @@ public final class ActiveSpanManager {
* @return The current active span, or null if none exists
*/
public static SpanAdapter getSpan(Exchange exchange) {
- Holder holder = exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN,
Holder.class);
+ Holder holder =
exchange.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN, Holder.class);
if (holder != null) {
return holder.getSpan();
}
@@ -56,15 +56,15 @@ public final class ActiveSpanManager {
* @param span The span
*/
public static void activate(Exchange exchange, SpanAdapter span) {
- if (exchange.getProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE,
Boolean.FALSE, Boolean.class)) {
+ if (exchange.getProperty(ExchangePropertyKey.OTEL_CLOSE_CLIENT_SCOPE,
Boolean.FALSE, Boolean.class)) {
//Check if we need to close the CLIENT scope created by
//DirectProducer in async mode before we create a new INTERNAL
scope
//for the next DirectConsumer
endScope(exchange);
- exchange.removeProperty(ExchangePropertyKey.CLOSE_CLIENT_SCOPE);
+
exchange.removeProperty(ExchangePropertyKey.OTEL_CLOSE_CLIENT_SCOPE);
}
- exchange.setProperty(ExchangePropertyKey.ACTIVE_SPAN,
- new
Holder(exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN, Holder.class),
span));
+ exchange.setProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN,
+ new
Holder(exchange.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN,
Holder.class), span));
if (Boolean.TRUE.equals(exchange.getContext().isUseMDCLogging())) {
MDC.put(MDC_TRACE_ID, span.traceId());
MDC.put(MDC_SPAN_ID, span.spanId());
@@ -79,10 +79,10 @@ public final class ActiveSpanManager {
* @param exchange The exchange
*/
public static void deactivate(Exchange exchange) {
- Holder holder = exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN,
Holder.class);
+ Holder holder =
exchange.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN, Holder.class);
if (holder != null) {
Holder parent = holder.getParent();
- exchange.setProperty(ExchangePropertyKey.ACTIVE_SPAN, parent);
+ exchange.setProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN, parent);
holder.closeScope();
if (Boolean.TRUE.equals(exchange.getContext().isUseMDCLogging())) {
@@ -106,7 +106,7 @@ public final class ActiveSpanManager {
* @param exchange The exchange
*/
public static void endScope(Exchange exchange) {
- Holder holder = exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN,
Holder.class);
+ Holder holder =
exchange.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN, Holder.class);
if (holder != null) {
holder.closeScope();
}
diff --git
a/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
b/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
index 40b33cd2a98..498abea265f 100644
---
a/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
+++
b/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
@@ -15,7 +15,6 @@ public class ExchangeConstantProvider {
static {
Map<String, String> map = new HashMap<>(160);
map.put("ACCEPT_CONTENT_TYPE", "CamelAcceptContentType");
- map.put("ACTIVE_SPAN", "OpenTracing.activeSpan");
map.put("AGGREGATED_COLLECTION_GUARD",
"CamelAggregatedCollectionGuard");
map.put("AGGREGATED_COMPLETED_BY", "CamelAggregatedCompletedBy");
map.put("AGGREGATED_CORRELATION_KEY", "CamelAggregatedCorrelationKey");
@@ -37,7 +36,6 @@ public class ExchangeConstantProvider {
map.put("CHARSET_NAME", "CamelCharsetName");
map.put("CIRCUIT_BREAKER_STATE", "CamelCircuitBreakerState");
map.put("CLAIM_CHECK_REPOSITORY", "CamelClaimCheckRepository");
- map.put("CLOSE_CLIENT_SCOPE", "OpenTracing.closeClientScope");
map.put("COMPILE_SCRIPT", "CamelCompileScript");
map.put("CONTENT_ENCODING", "Content-Encoding");
map.put("CONTENT_LENGTH", "Content-Length");
@@ -125,6 +123,8 @@ public class ExchangeConstantProvider {
map.put("OFFSET", "CamelOffset");
map.put("ON_COMPLETION", "CamelOnCompletion");
map.put("ON_COMPLETION_ROUTE_IDS", "CamelOnCompletionRouteIds");
+ map.put("OTEL_ACTIVE_SPAN", "OpenTracing.activeSpan");
+ map.put("OTEL_CLOSE_CLIENT_SCOPE", "OpenTracing.closeClientScope");
map.put("OVERRULE_FILE_NAME", "CamelOverruleFileName");
map.put("PARENT_UNIT_OF_WORK", "CamelParentUnitOfWork");
map.put("RECEIVED_TIMESTAMP", "CamelReceivedTimestamp");
diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java
b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
index 028c6773a3c..d794a2ab1a4 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
@@ -67,8 +67,6 @@ import org.apache.camel.spi.annotations.ConstantProvider;
@ConstantProvider("org.apache.camel.ExchangeConstantProvider")
public interface Exchange extends VariableAware {
- String ACTIVE_SPAN = "OpenTracing.activeSpan";
- String CLOSE_CLIENT_SCOPE = "OpenTracing.closeClientScope";
String AUTHENTICATION = "CamelAuthentication";
String AUTHENTICATION_FAILURE_POLICY_ID =
"CamelAuthenticationFailurePolicyId";
@Deprecated(since = "2.20.0")
@@ -333,6 +331,10 @@ public interface Exchange extends VariableAware {
String XSLT_FATAL_ERROR = "CamelXsltFatalError";
String XSLT_WARNING = "CamelXsltWarning";
+ // special for camel-tracing/open-telemetry
+ String OTEL_ACTIVE_SPAN = "OpenTracing.activeSpan";
+ String OTEL_CLOSE_CLIENT_SCOPE = "OpenTracing.closeClientScope";
+
/**
* Returns the {@link ExchangePattern} (MEP) of this exchange.
*
diff --git
a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
index 9146fd8780d..167eb3d8bb5 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
@@ -23,8 +23,6 @@ import org.apache.camel.spi.CircuitBreakerConstants;
*/
public enum ExchangePropertyKey {
- ACTIVE_SPAN(Exchange.ACTIVE_SPAN),
- CLOSE_CLIENT_SCOPE(Exchange.CLOSE_CLIENT_SCOPE),
AGGREGATED_COMPLETED_BY(Exchange.AGGREGATED_COMPLETED_BY),
AGGREGATED_CORRELATION_KEY(Exchange.AGGREGATED_CORRELATION_KEY),
AGGREGATED_SIZE(Exchange.AGGREGATED_SIZE),
@@ -76,7 +74,10 @@ public enum ExchangePropertyKey {
STREAM_CACHE_UNIT_OF_WORK(Exchange.STREAM_CACHE_UNIT_OF_WORK),
TO_ENDPOINT(Exchange.TO_ENDPOINT),
TRY_ROUTE_BLOCK(Exchange.TRY_ROUTE_BLOCK),
- UNIT_OF_WORK_EXHAUSTED(Exchange.UNIT_OF_WORK_EXHAUSTED);
+ UNIT_OF_WORK_EXHAUSTED(Exchange.UNIT_OF_WORK_EXHAUSTED),
+ // special for camel-tracing/open-telemetry
+ OTEL_ACTIVE_SPAN(Exchange.OTEL_ACTIVE_SPAN),
+ OTEL_CLOSE_CLIENT_SCOPE(Exchange.OTEL_CLOSE_CLIENT_SCOPE);
private final String name;
@@ -90,8 +91,6 @@ public enum ExchangePropertyKey {
public static ExchangePropertyKey asExchangePropertyKey(String name) {
switch (name) {
- case Exchange.ACTIVE_SPAN:
- return ACTIVE_SPAN;
case Exchange.AGGREGATED_COMPLETED_BY:
return AGGREGATED_COMPLETED_BY;
case Exchange.AGGREGATED_CORRELATION_KEY:
@@ -194,6 +193,10 @@ public enum ExchangePropertyKey {
return TRY_ROUTE_BLOCK;
case Exchange.UNIT_OF_WORK_EXHAUSTED:
return UNIT_OF_WORK_EXHAUSTED;
+ case Exchange.OTEL_ACTIVE_SPAN:
+ return OTEL_ACTIVE_SPAN;
+ case Exchange.OTEL_CLOSE_CLIENT_SCOPE:
+ return OTEL_CLOSE_CLIENT_SCOPE;
default:
return null;
}
diff --git
a/core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java
b/core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java
index 0b91c6a52ea..067744af536 100644
---
a/core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java
+++
b/core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java
@@ -233,9 +233,9 @@ public class InMemorySagaCoordinator implements
CamelSagaCoordinator {
answer.getMessage().setHeader(Exchange.SAGA_LONG_RUNNING_ACTION,
getId());
// preserve span from parent, so we can link this new exchange to the
parent span for distributed tracing
- Object span = parent != null ?
parent.getProperty(ExchangePropertyKey.ACTIVE_SPAN) : null;
+ Object span = parent != null ?
parent.getProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN) : null;
if (span != null) {
- answer.setProperty(ExchangePropertyKey.ACTIVE_SPAN, span);
+ answer.setProperty(ExchangePropertyKey.OTEL_ACTIVE_SPAN, span);
}
Map<String, Object> values = optionValues.get(step);
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
index 45ba2b3da35..32324f817b9 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
@@ -10,6 +10,9 @@ from both 4.0 to 4.1 and 4.1 to 4.2.
Added `setLazyBeanStrategy`/`getLazyBeanStrategy` methods to
`org.apache.camel.spi.CamelBeanPostProcessor`.
+Renamed `Exchange.ACTIVE_SPAN` to `Exchange.OTEL_ACTIVE_SPAN`.
+Renamed `ExchangePropertyKey.ACTIVE_SPAN` to
`ExchangePropertyKey.OTEL_ACTIVE_SPAN`.
+
=== camel-management
The `queueSize` attribute on endpoints which are `ManagedBrowseableEndpoint`
is changed from returning a `Long` value