opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Support propagating span, trace ids via environment variable

Open dshivashankar1994 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Yes. I have a custom multi-processor which is capable of launching workers in remote hosts for processing. In such cases the python context is not propagated and only the environment variables are propagated. Because of this, the parent-child relation is not properly maintained if a function invokes another function over these remote-workers.

Describe the solution you'd like The request is to support setting the span-id, trace-id etc., in the environment whenever span is started and propagate, process them from the environment.

Describe alternatives you've considered Passing the span id, trace id in serialized fashion while to these workers over network is not possible as these workers are linux workers and don't have a port to communicate.

Additional context I've prepared a small PoC for my work. A pre-step is, checking the environment for any existing span-id/trace-id set. If exists, create a span out of it and store in the context and use the context while creating span. While starting span, I set the span-id, trace-id etc., in the environment. I'm not sure of the value this brings to the table. But still wanted to bring this to discussion to see if there are any caveats in such behavior and to understand why OT never supported such env propagation.

dshivashankar1994 avatar May 22 '23 10:05 dshivashankar1994

to understand why OT never supported such env propagation

Because it should be added to the spec first. See https://github.com/open-telemetry/opentelemetry-specification/issues/740 and https://github.com/open-telemetry/opentelemetry-python/pull/2110

srikanthccv avatar May 22 '23 15:05 srikanthccv

This recently landed! https://github.com/open-telemetry/opentelemetry-specification/pull/4454

Cursory exploration suggests that the Python SDKs don't (yet?) support this, but I may be missing something.

StephenWithPH avatar Sep 16 '25 00:09 StephenWithPH