Context propagation for Typescript SDK

Hello, using Temporal’s Typescript SDK (v.1.4.3). Want to start propagating context through all of my workflows so that I know how to attribute which workflows/activities are being used by which users within my teams (for the sake of cost analysis).

Was curious how it’s suggested to do so, I see some docs here (Logging and Sinks in TypeScript SDK | Temporal Documentation), but there’s not much examples I could find of how to do what I’m trying to do. Also found this forum post (Context Propagation docs - #2 by bergundy), which seems to suggest using interceptors instead of the propagators from the first link. What’s the best approach for my use case here? Are there any code samples that might help with understanding this? Thanks!

The docs you saw on logging and sinks mention opentelemetry context propagation.
If you want to propagate context that’s not tied to tracing, you would need to implement your own interceptors, as I mentioned in Context Propagation docs - #2.

Thanks for the reply. Not sure I understand, how do I differentiate between context tied to tracing vs context not tied to tracing? From what I can tell, I would want to write my own interceptor then, since the context I’m trying to propagate is related to who might be starting the workflow. Is that correct?

Yes, that is correct.

Gotcha. If I’m to do this via interceptors, what’s the use case for the propagators linked in the Logging and Sinks page?

See the opentelemetry docs here: Propagators API | OpenTelemetry