Baggage Propagation Across Process Boundaries #2274
-
Hi Otel-JS Folks! I hope y'all have been well. I am trying to understand and make sure my implementation of I created a Fastify based demo application to base my question on:
Question(s)
I look forward to hearing back! Context and My UnderstandingI read Propagation of the OTel Specification to try and understand In the sample project I am creating a baggage entry and then using the const baggageEntry: BaggageEntry = {
value: 'iAmATestValue',
};
const newBaggage = propagation.createBaggage({
'testEntry': baggageEntry
})
const newContextWithBaggage = propagation.setBaggage(context.active(), newBaggage)
propagation.inject(newContextWithBaggage,request.raw.headers) ref: https://github.com/mannyluvstacos/otel-baggage-example/blob/main/index.ts#L35-L42 This request can be forwarded onto the next process (maybe another node.js service) const rawHeadersToExtract = request.raw.headers;
const extractedPropagationContext = propagation.extract(context.active(), rawHeadersToExtract)
console.log({ extractedPropagationContext})
const extractedBaggage = propagation.getBaggage(extractedPropagationContext)
console.log({extractedBaggage})
const entryByName = extractedBaggage.getEntry('testEntry')
console.log({ entryByName }) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Hi @dyladan! I had seen the cc: @vmarchaud , Valentin, if you are available and able to speak to my questions above, I would love your feedback! Thank you again for your time. Respectfully, |
Beta Was this translation helpful? Give feedback.
-
Http instrumentation should automatically propagate baggage for outgoing http request (if
We have a concept of propagator that you can register on the api and then instrumentation will use them to know what to inject on outgoing request. In this case the
Even if you could manually, the http instrumentation should do that for you to avoid writing those lines. Normally in this log you should see the
If you want to set the new context as active, you should use |
Beta Was this translation helpful? Give feedback.
-
Hi @mannyluvstacos and @vmarchaud! I hope it's ok I'm jumping in on this interesting discussion (I am too in search of how to properly utilize the Baggage capabilities and am a bit lost..) So from what I understand setting the Baggage is a way to pass information throughout an entire trace (along all spans and over distributed trace context). So if I have Two followup questions (in case I got the gist of things) are:
Sorry if my questions are missing some basic understanding of the mechanism and thanks in advance for taking the time to read this.. |
Beta Was this translation helpful? Give feedback.
Http instrumentation should automatically propagate baggage for outgoing http request (if
HttpBaggagePropagator
is registered)We have a concept of propagator that you can register on the api and then instrumentation will use them to know what to inject on outgoing request. In this case the
HttpBaggagePropagator
will pickup baggage from the context and inject it into what is given by the http instrumentation (headers for http)