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:09:17 UTC

(camel) branch mm-npe created (now 98f80edf11f)

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

davsclaus pushed a change to branch mm-npe
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 98f80edf11f CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values.

This branch includes the following new commits:

     new 98f80edf11f CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch mm-npe
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 98f80edf11f0002e44588e8d1970f35fce2e4da6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 24 11:09:07 2024 +0100

    CAMEL-20350: camel-observation - Fix Micrometer should use real null for null values.
---
 .../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 74f90818965..a11a84f7a1f 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);