open-telemetry / open-telemetry/opentelemetry-python
first issue
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?
I believe the issue is that the baggage.set_baggage(key, value) does not read the current context that later gets called by get_all( ). instead it creates a new Context object with the baggage entry added and returns but the newer context is never made "current"
Describe the solution you'd like
i guess use attach( ) with each context to make it current and then use detach( ) when it is complete
from opentelemetry import baggage, context, trace
tracer = trace.get_tracer(name)
global_ctx = baggage.set_baggage("context", "global")
token_global = context.attach(global_ctx)
with tracer.start_as_current_span(name="root span") as root_span:
parent_ctx = baggage.set_baggage("context", "parent")
token_parent = context.attach(parent_ctx)
with tracer.start_as_current_span(name="child span") as child_span:
child_ctx = baggage.set_baggage("context", "child")
token_child = context.attach(child_ctx)
Describe alternatives you've considered
No response
Additional Context
No response
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
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 with the Python baggage.set_baggage and get_all APIs and the context.attach/detach behavior shown in the issue. Check the existing baggage and context tests before reproducing the nested example. Done means the intended current-context behavior is established and covered for the global, parent, and child values, including context restoration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100