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:41 UTC
(camel) branch camel-4.0.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-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push:
new 53c201bfd92 CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values. (#12891)
53c201bfd92 is described below
commit 53c201bfd926f00ec50a919389c257a50c631908
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 aa5baec9d4f..65e8a4cf52b 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);