He-Pin opened a new issue, #3133: URL: https://github.com/apache/pekko/issues/3133
### Motivation When building microservices with distributed tracing (e.g., OpenTelemetry), trace context is typically propagated through HTTP headers, gRPC metadata, or message properties. However, when data flows through Pekko Streams operators, the trace context associated with each element is lost at stream boundaries. This breaks end-to-end trace continuity, making it difficult to correlate stream processing with upstream/downstream operations in a distributed trace. ### Proposed Enhancement Add infrastructure to carry trace context (e.g., OpenTelemetry `SpanContext` or equivalent) through Pekko Streams elements as they flow through the stream graph. This could involve: 1. **Element-level context carry**: Each element flowing through the stream carries an associated trace context that is propagated across operator boundaries 2. **Source integration**: Sources that receive elements from traced contexts (e.g., HTTP handlers, message consumers) can attach the current trace context to elements 3. **Sink/operator integration**: Sinks and operators that perform async work (e.g., `mapAsync`, `flatMapConcat`) can activate the propagated context when processing elements, ensuring child spans are correctly parented 4. **Materializer-aware propagation**: The stream materializer ensures context is maintained across sub-streams and materialized boundaries ### Considerations - The implementation should be optional and opt-in to avoid overhead for users who don't need tracing - Should integrate with existing JVM tracing ecosystems (OpenTelemetry Java SDK, Micrometer Tracing, etc.) - The JVM equivalent of .NET's `ActivityContext` would be OpenTelemetry's `Context` or similar thread-local/span-local storage ### Impact - Enables end-to-end distributed tracing across stream processing pipelines - Improves observability for stream-based microservices - Helps diagnose latency issues that span stream boundaries ### References This feature was implemented in the Akka.NET project: https://github.com/akkadotnet/akka.net/issues/8160 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
