akka-tracing icon indicating copy to clipboard operation
akka-tracing copied to clipboard

Trace Propagation in distributed enviornment

Open sandeep-paliwal opened this issue 7 years ago • 6 comments

Hi, can SpanMetadata be used to propagate span information? How to do I get traceId and span Id of parent and how can they be attached to child in different process?

sandeep-paliwal avatar May 06 '17 08:05 sandeep-paliwal

Having similar question. is it possible currently to let's say propagate paren trace information from upstream, let's say play framework down to remote akka system via available APIs ?

If not what are the places to look for in code in order to try to contribute such possibility ?

mtomas avatar May 07 '17 23:05 mtomas

I got it working in following scenario. Akka actor(Producer) sends message to kafka. Another Akka actor in different process(Consumer) get the message processes it and send back acknowledgment.

Key here is to use SpanMetada correctly which is returned when request is sampled. I added this to Kafka message which when received by Consumer, uses this metadata to create parent request - trace.importMetadata(parentReq, metadata, serviceName) Now add downstream trace request as child of this parent - trace.createChild(child, parent)

Here trace is instance of TracingExtensionImpl provided by the akka-tracing lib.

Hope this helps you

sandeep-paliwal avatar May 09 '17 06:05 sandeep-paliwal

Thanks for sharing @sandeep-paliwal.

In my case I need to figure out how to map actor message to be tied under same trace started by Play framework when clients requests start of the operation via HTTP and stuff is delegated then to akka actor system. That means making sure that Play and Akka akka-tracing extension support play nicely together (is there any example or test spec for that @levkhomich ?).

Therefore I guess I need to somehow extract traceId, spanId and parentId, send it along with the message sent to actor system and do trace.importMetadata for the message I wanna trace further in actor code.

mtomas avatar May 10 '17 14:05 mtomas

Sorry for late response.

@sandeep-paliwal that's exactly how it's supposed to work.

@mtomas you can use trace.exportMetadata on request: RequestHeader because akka-tracing uses request ids generated by Play and there is an implicit conversion from RequestHeader to BaseTracingSupport.

levkhomich avatar May 11 '17 19:05 levkhomich

@levkhomich is there a way I can check if tracing has been enabled or not? Also is it possible to programatically set sampling rate or enable/disable tracing instead of controlling it from application.conf ?

sandeep-paliwal avatar May 16 '17 19:05 sandeep-paliwal

Hi! Faced the same issue? Isn't possible to store in message id of parent too?

kriloleg avatar Jun 16 '17 11:06 kriloleg