beskow commented on code in PR #22677:
URL: https://github.com/apache/camel/pull/22677#discussion_r3110318598
##########
components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetrySpanAdapter.java:
##########
@@ -69,6 +92,26 @@ protected Baggage getBaggage() {
return this.baggage;
}
+ /**
+ * Adds a baggage entry that will be propagated to downstream spans and
services. If this span is currently active
+ * (made current), the baggage scope is refreshed so the new entry is
immediately visible in the current context.
+ */
+ public void setBaggageEntry(String key, String value) {
+ this.baggage = this.baggage.toBuilder().put(key, value).build();
+ // If baggage is currently scoped, refresh it so the new entry takes
effect
+ if (this.baggageScope != null) {
+ this.baggageScope.close();
+ this.baggageScope = this.baggage.makeCurrent();
Review Comment:
Is that really so? If I understand the implicit contract of the
OpenTelemetrySpanAdapter, it is created and activated when the exchange starts:
org.apache.camel.telemetry.TracingRoutePolicy.onExchangeBegin() ->
org.apache.camel.telemetry.Tracer.beginEventSpan(..) ->
org.apache.camel.opentelemetry2.OpenTelemetryTracer.activate() ->
org.apache.camel.opentelemetry2.OpenTelemetrySpanAdapter.makeCurrent()
and closed on exchange completion:
org.apache.camel.support.EventHelper.notifyExchangeSent(..) ->
org.apache.camel.telemetry.Tracer.notify(..) ->
org.apache.camel.telemetry.Tracer.endEventSpan(..) ->
org.apache.camel.opentelemetry2.OpenTelemetryTracer.close() ->
org.apache.camel.opentelemetry2.OpenTelemetrySpanAdapter.close()
Hence the baggageScope is "opened" on exchange start and closed at exchange
end. If we "mutate" the baggageScope in a processor somewhere in between (by
closing the original baggageScope and replacing it with an extended scope), we
still have the same guarantee that it is closed at the end of the exchange.
Or am I misunderstanding something?
--
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]