Hello everybody, A customer of ours is planning to use Google PubSub for their Camel projects. As they are using OpenTelemetry, they need to propagate tracing data through PubSub messages.
As including camel-google-pubsub-starter and camel-opentelemetry2-starter did not work out of the box and initially attempted to propagate the "traceparent" Exchange header using interceptors. While they succeeded in attaching the header to published PubSub messages and reading it back from consumed messages, they found that this had no effect on OpenTelemetry and a new trace was created for each Exchange. After a bit of digging, we found that OpenTelemetry hooks into RoutePolicySupport.onExchangeBegin() and RoutePolicySupport.onExchangeDone() and any write access to the Exchange headers is too late in the Exchange's lifecycle to have any effect. Since we couldn't find a way to hook into the camel-google-pubsub component's behavior, our workaround was to clone the component, adding a couple of lines to add handling for the "traceparent" header. A POC is found at: https://github.com/bridgerdier/pubsub-trace-propagation Actual changes: * https://github.com/bridgerdier/pubsub-trace-propagation/blob/d69503510c0929cc98e7a5be9d0133ea202a2c6a/src/main/java/de/predic8/customers/pubsubtracepropagation/pubsubopentelemetry/CamelOpentelemetryMessagereceiver.java#L53 * https://github.com/bridgerdier/pubsub-trace-propagation/blob/d69503510c0929cc98e7a5be9d0133ea202a2c6a/src/main/java/de/predic8/customers/pubsubtracepropagation/pubsubopentelemetry/GooglePubsubOpentelemetryConsumer.java#L181 * https://github.com/bridgerdier/pubsub-trace-propagation/blob/d69503510c0929cc98e7a5be9d0133ea202a2c6a/src/main/java/de/predic8/customers/pubsubtracepropagation/pubsubopentelemetry/GooglePubsubOpentelemetryProducer.java#L75 Since this solution is intrusive and not really maintainable, we would be very grateful for a way to support using OpenTelemetry with the google-pubsub component out-of-the-box. The preferred solution would probably run along the lines of mapping all Exchange headers to Message attributes and vice versa. https://cloud.google.com/pubsub/docs/publisher#using-attributes I am however not very well versed in PubSub semantics or Camel/Tracing internals, so there might be a better way to achieve the desired result. Thanks in advance, Valentin Brückel [cid:0da6f921-4d0b-4fe9-aec3-993cac979ecb] predic8 GmbH Koblenzer Str. 65 53173 Bonn predic8.de<https://www.predic8.de/> Tel: +4<https://predic8-wiki.atlassian.net/wiki/spaces/inet/pages/372670466/Outlook#>9 (0) 228 5552576-0 Fax: +49 (0) 228 5552576-50 Amtsgericht Bonn HRB 16152 Geschäftsführer: Thomas Bayer, Tobias Polley