squakez commented on PR #22677:
URL: https://github.com/apache/camel/pull/22677#issuecomment-4281691600

   We should have all the elements required to make it works. I have some POC 
that could be good. Here the deal:
   
   You can "decorate" your route with some headers (or property), for example:
   
   ```
               @Override
               public void configure() {
                   from("direct:start")
                           .routeId("start")
                           .log("A message")
                           .process(new Processor() {
                               @Override
                               public void process(Exchange exchange) throws 
Exception {
                                   exchange.getIn().setHeader("BAGGAGE_XYZ", 
"fake");
                               }
                           })
                           .process(new Processor() {
                               @Override
                               public void process(Exchange exchange) throws 
Exception {
                                   exchange.getIn().setHeader("operation", 
"fake");
                               }
                           })
                           .to("log:info");
               }
   ```
   on the otel side (hence, neither touching the general abstraction), we could 
introduce a check to evaluate the presence of those headers:
   ```
   ...
               if (extractor.get("BAGGAGE_XYZ") != null) {
                   baggage = baggage.toBuilder().put("XYZ", "my-val").build();
               }
               System.out.println("********** Span (" + spanName + ") baggage " 
+ baggage);
   
               return new OpenTelemetrySpanAdapter(builder.startSpan(), 
baggage);
   ```
   
   In this way the baggage is going to be correctly propagated:
   
   ```
   ********** Span (start) baggage {}
   ********** Span (start) baggage {camelScope=ImmutableEntry{value=true, 
metadata=ImmutableEntryMetadata{value=}}}
   ********** Span (log1-log) baggage {camelScope=ImmutableEntry{value=true, 
metadata=ImmutableEntryMetadata{value=}}}
   ********** Span (process1-process) baggage 
{camelScope=ImmutableEntry{value=true, metadata=ImmutableEntryMetadata{value=}}}
   ********** Span (process2-process) baggage {XYZ=ImmutableEntry{value=my-val, 
metadata=ImmutableEntryMetadata{value=}}, camelScope=ImmutableEntry{value=true, 
metadata=ImmutableEntryMetadata{value=}}}
   ********** Span (to1-to) baggage {XYZ=ImmutableEntry{value=my-val, 
metadata=ImmutableEntryMetadata{value=}}, camelScope=ImmutableEntry{value=true, 
metadata=ImmutableEntryMetadata{value=}}}
   ********** Span (log) baggage {XYZ=ImmutableEntry{value=my-val, 
metadata=ImmutableEntryMetadata{value=}}, camelScope=ImmutableEntry{value=true, 
metadata=ImmutableEntryMetadata{value=}}}
   ```
   I think this one could be a nice solution and it would introduce the 
possibility to "program" the baggage in whichever DSL, not necessarily in Java, 
and, above all, without the need to know the programming concepts of Otel.
   
   wdyt?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to