open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Feature Request: Allow @WithSpan to start a new Trace and create a span link to the original Trace
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Is your feature request related to a problem? Please describe.
When we have a big operation producing a huge trace, we sometimes would like to decouple some operations into a separate trace by using WithSpan(inheritContext = false ). However, we still want to refer to the trace that caused it.
Describe the solution you'd like
I would like to propose WithSpan(inheritContext = false, addPreviousSpanAsLink = true). When inheritContext == true, then addPreviousSpanAsLink is ignored.
Describe alternatives you've considered
Right now, we do need to manually create spans just to add span links.
Additional context
No response
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 by locating the @WithSpan annotation and the handling of inheritContext. Trace how a new trace is started and how span links are currently created, then determine the affected tests or entry points. Done means the proposed addPreviousSpanAsLink option links the original span only when inheritContext is false, while the existing behavior remains unchanged otherwise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100