Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow @WithSpan to start a new Trace #1036

Open
jkwatson opened this issue Aug 17, 2020 · 8 comments
Open

Feature Request: Allow @WithSpan to start a new Trace #1036

jkwatson opened this issue Aug 17, 2020 · 8 comments
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request

Comments

@jkwatson
Copy link
Contributor

Currently, if you use the @WithSpan annotation, it will always join in the current trace, if there is one in scope. It would be useful to be able to tell the agent that we don't want to preserve the parenting, but create a new TraceId for the span.

This can be useful if you want background jobs that are spawned based on a request to appear as their own trace, rather than joining in the existing trace.

Bonus points: an option to Link the new span to the one that spawned it.

@jkwatson jkwatson added the enhancement New feature or request label Aug 17, 2020
@iNikem
Copy link
Contributor

iNikem commented Aug 18, 2020

@jkwatson do you want that before GA or we can deliver it after GA?

@jkwatson
Copy link
Contributor Author

No strong opinions from my side. I'm happy to write the manual instrumentation without the annotation...I can't speak for other not-so-deep-into-the-project users, though.

@azizabah
Copy link

azizabah commented Mar 7, 2023

I know this conversation was quite a while ago but we are running into a specific situation in our code base where this would be incredibly helpful. Currently we have an issue where jobs being kicked off by an internal scheduler in the service are all being grouped as a single "trace" when we would really like to split them up and being able to add a simple "@WithTrace" (or a parameter in @WithSpan) to it would be immensely useful.

@trask
Copy link
Member

trask commented Mar 8, 2023

hey @azizabah, just wanted to check if you already know how to solve this using OpenTelemetry API, and are just looking for a more convenient way via annotation?

@azizabah
Copy link

azizabah commented Mar 8, 2023

@trask - No I'm not aware of how to solve it. I was reading here: https://opentelemetry.io/docs/instrumentation/java/manual/ but everything seemed to be focused on spans and not traces so I wasn't sure what the path forward would be.

@trask
Copy link
Member

trask commented Mar 8, 2023

try this:

try (Scope ignored = Context.root().makeCurrent()) {
  // creating a new span in here will create a new trace since it won't find a "current" span
}

@trask trask added the contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome label Aug 26, 2023
@trask
Copy link
Member

trask commented Aug 26, 2023

I'm not sure how many configuration options we want to add to @WithSpan (although I think I would support this particular option)

@zeitlinger @jack-berg this could be a good use case for a convenience API somewhere in between @WithSpan and opentelemetry-api

linking to open-telemetry/opentelemetry-java-contrib#759

@mateuszrzeszutek
Copy link
Member

Another duplicate of this issue: open-telemetry/opentelemetry-java#5837

(although I think I would support this particular option)

Agreed 👍
And just to be clear, this issue fits the scope of the project. The maintainers aren't planning to implement it, but would welcome and help review if someone else wants to implement and contribute it to the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants