open-telemetry / open-telemetry/opentelemetry-java

Span activation should activate parent context

Open
#4,214 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request
Dominant language
Java
Stars
2.5k
Forks
1k
Avg merge
3d 17h
Merged PRs (30d)
58

Description

Is your feature request related to a problem? Please describe.

Baggage propagation is not intuitive.

Describe the solution you'd like

I would like to be able to access the baggage, even if I omit the extractedContext.makeCurrent() statement below:

        Context extractedContext = textMapPropagator.extract(Context.current(), req, EXTRACT_PROPERTIES_FROM_HEADER);
        try (Scope ignore = extractedContext.makeCurrent()) {
            Span serverSpan = tracer.spanBuilder(handlerMethodName(req, handlerMethodPerInfo))
                                    .setParent(extractedContext)
                                    .setSpanKind(SERVER)
                                    .startSpan();

            try (final Scope scope = serverSpan.makeCurrent()) {
               //here I have access to baggage using Baggage.current()
            } finally {
                serverSpan.end();
            }
        }

Describe the solution you'd like

I already passed extractedContext to the span and activated it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Context.extract(...), makeCurrent(), SpanBuilder.setParent(...), and Baggage.current() sequence shown in the issue, then inspect the SDK's context and span-activation entry points. Determine and test the intended parent-context behavior; done means the requested baggage access works without the separate extractedContext.makeCurrent() scope, with lifecycle behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.