open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.99k stars 868 forks source link

Support Akka Streams #3052

Open jenoOvchi opened 3 years ago

jenoOvchi commented 3 years ago

Hi!

Is it possible to implement Akka Streams Support for opentelemetry-javaagent?

mateuszrzeszutek commented 3 years ago

Hey @jenoOvchi ,

Unfortunately we won't have the capacity to implement this ourselves, but we'll gladly accept external contributions.

laurit commented 3 years ago

@jenoOvchi What kind of support are you looking for? Context propagation to stream completion callback or something else?

unit7-0 commented 3 years ago

@laurit, We use alpakka-kafka to handle and then send new messages to kafka. Accordingly the reading of messages by the consumer and sending by the producer are further separated by asynchronous business logic. The processing flow looks something like this: kafka-consumer -> akka-stream -> kafka-producer. I saw that there is already support for context propagation at the vanilla kafka consumer/producer, but only for synchronous message processing. However, in akka streams messages are processed asynchronously, i.e. after that action in KafkaConsumerActor the batch read by the consumer from kafka is sent entirely to the actor after which the context is lost if it was in some message: KafkaConsumerActor.scala#L632. I also saw that there is already support for context propagation for actors.

I think it would be possible to try adding a tracing context to the existing context forwarding mechanism in akka streams SourceWithContext.scala, somewhere here(MessageBuilder.scala) along with the forwarding offset of the read message and then in the kafka producer we can pull this tracing context to propagate.

suzilxptr commented 7 months ago

@mateuszrzeszutek @laurit has there been any progress with this ticket since last update?

laurit commented 7 months ago

@suzilxptr no progress

pjfanning commented 1 month ago

https://github.com/kamon-io/Kamon/tree/master/instrumentation/kamon-alpakka-kafka/src/main would be a good guideline as to what is needed here