He-Pin opened a new issue, #3107: URL: https://github.com/apache/pekko/issues/3107
### Motivation Pekko Streams has no distributed tracing support. Users running Pekko in microservices cannot trace how elements flow through stream topologies. This is increasingly expected in production environments for observability. ### Proposed design (based on Akka.NET reference implementation) 1. **Trace context in Connection slots**: Extend `Connection` in `GraphInterpreter` with a trace context field. Capture `io.opentelemetry.context.Context.current()` on element push. 2. **Stage-scoped spans**: In `processPush`, start an OpenTelemetry span scoped to the stage. Span name = stage operation (e.g., `MapAsync`, `Filter`). 3. **Fan-in links**: For fan-in stages (Batch, Merge, Concat, GroupedWeightedWithin), record `ActivityLink`s from all input connections. 4. **Cross-async-boundary propagation**: Extend `OnNext` events with trace context. `BatchingActorInputBoundary` buffers contexts in parallel arrays and restores them on dequeue. 5. **Zero-cost when no listener**: When no OpenTelemetry listener is registered, all tracing code should be a no-op with negligible overhead. ### JVM-specific considerations - Use `io.opentelemetry.api.trace.Tracer` instead of .NET `ActivitySource` - Use `io.opentelemetry.context.Context` and `ThreadLocal` propagation - Consider integration with Pekko's existing `ContextPropagation` mechanism - May need a new module/dependency for `opentelemetry-api` ### Scope This is a large, cross-cutting feature (~2000+ lines across 20+ files). It should be broken into multiple PRs: 1. Core trace context in GraphInterpreter Connection 2. Stage-scoped spans in processPush 3. Fan-in link support 4. Cross-async-boundary propagation 5. Source.Queue / Sink.Queue ingress/egress tracing 6. Configuration and opt-in mechanism ### References - Akka.NET implementation: [#8160](https://github.com/akkadotnet/akka.net/pull/8160) + [#8243](https://github.com/akkadotnet/akka.net/pull/8243) - [OpenTelemetry Java SDK](https://opentelemetry.io/docs/languages/java/) -- 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]
