You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/01/24 10:28:51 UTC
(camel) branch camel-3.22.x updated: CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values. (#12891)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.22.x by this push:
new 502fb044687 CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values. (#12891)
502fb044687 is described below
commit 502fb0446874a3dc479bc52dbd1da3710498b9c7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 24 11:28:06 2024 +0100
CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values. (#12891)
---
.../camel/observation/MicrometerObservationTracer.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/components/camel-observation/src/main/java/org/apache/camel/observation/MicrometerObservationTracer.java b/components/camel-observation/src/main/java/org/apache/camel/observation/MicrometerObservationTracer.java
index e670cf69220..fc2c5c790dd 100644
--- a/components/camel-observation/src/main/java/org/apache/camel/observation/MicrometerObservationTracer.java
+++ b/components/camel-observation/src/main/java/org/apache/camel/observation/MicrometerObservationTracer.java
@@ -72,14 +72,20 @@ public class MicrometerObservationTracer extends org.apache.camel.tracing.Tracer
throw new UnsupportedOperationException("You can't extract when sending a message");
case SPAN_KIND_SERVER:
RequestReplyReceiverContext<Object, Message> replyReceiverContext
- = new RequestReplyReceiverContext<>((carrier, key) -> String.valueOf(adapter.get(key)));
+ = new RequestReplyReceiverContext<>((carrier, key) -> {
+ Object val = adapter.get(key);
+ return val != null ? val.toString() : null;
+ });
replyReceiverContext.setResponse(exchange.getMessage());
replyReceiverContext.setCarrier(exchange.getIn());
return replyReceiverContext;
case CONSUMER:
case SPAN_KIND_CLIENT:
ReceiverContext<Message> receiverContext
- = new ReceiverContext<>((carrier, key) -> String.valueOf(adapter.get(key)));
+ = new ReceiverContext<>((carrier, key) -> {
+ Object val = adapter.get(key);
+ return val != null ? val.toString() : null;
+ });
receiverContext.setCarrier(exchange.getIn());
return receiverContext;
default:
@@ -144,8 +150,10 @@ public class MicrometerObservationTracer extends org.apache.camel.tracing.Tracer
// Because Camel allows to close scopes multiple times
TracingObservationHandler.TracingContext tracingContext
= parentObservation.getContextView().get(TracingObservationHandler.TracingContext.class);
- Span parentSpan = tracingContext.getSpan();
- scope = tracer.withSpan(parentSpan);
+ if (tracingContext != null) {
+ Span parentSpan = tracingContext.getSpan();
+ scope = tracer.withSpan(parentSpan);
+ }
}
if (parentObservation != null) {
observation.parentObservation(parentObservation);