open-telemetry / open-telemetry/opentelemetry-python
Support propagating span, trace ids via environment variable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the SDK's span-start and context-propagation entry points, then examine how environment variables reach remote Linux workers. Clarify the required environment representation, lifecycle, isolation, and caveats before implementation. Done requires an agreed design and tests covering propagation from a parent process into a worker-created span.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100