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

Allow ending/deleting/destroying a span without having it be recorded #2389

Closed
Falmarri opened this issue Oct 28, 2023 · 5 comments
Closed
Assignees
Labels
triage/unresolved Indicates an issue that can not or will not be resolved.

Comments

@Falmarri
Copy link

I have a somewhat annoying situation in my code that's kind of hard to explain, so I won't exactly go into it unless it's necessary. But the short story is sometimes I create a span, but later realize that the span isn't actually relevant to my workflow and I want to abandon it without recording it. The reason for this is that the system can create hundreds of thousands of spans, but only a small portion are relevant, and it's very hard for me to know beforehand whether it will be relevant or not.

I realize this is far from ideal, but I'm working in the bounds of an existing 3rd party library that my code is running as an extension of, so I don't have much of an option to change. I can probably come up with a workaround, but my first thought was just to create the spans always, but only record them after knowing they interact with my flow. Maybe there could be a span->Abandon() method or something like that?

@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 28, 2023
@lalitb
Copy link
Member

lalitb commented Nov 2, 2023

Please note

  • There is no method at API surface to destroy/abandon the Span. Span once created need to end either explicitly by calling Span::End(), or automatically when it's destructor gets called.
  • At SDK level ,you can implement Sampler which make sampling/recording decision upfront when Span is started.

So, once Span is created, and not sampled by Sampler, it would get ended and eventfully exported. One of the option is to create a custom span-processor which implements tail-based sampling. And for this to work, you also need a custom exporter which implements the Recordale::SpanData() method. Or else, your custom exporter can do the filtering too. There have been some discussions in #2108.

@lalitb
Copy link
Member

lalitb commented Nov 7, 2023

@Falmarri do you have more queries, or can we close this issue ?

@ThomsonTan ThomsonTan assigned ThomsonTan and unassigned ThomsonTan Nov 7, 2023
@ThomsonTan
Copy link
Contributor

For the potential API Span::Abandon, probably raise it to the API specification repo? But it has some edge cases like whether the child spans need to be discarded as well.

@ThomsonTan ThomsonTan self-assigned this Nov 7, 2023
@marcalff
Copy link
Member

Closing, this feature is not supported by opentelemetry in general.

Instead of creating a span and later "abandon" it, also consider to delay the span creation until the application can decide if it it needed or not.

@marcalff marcalff closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
@marcalff marcalff added triage/unresolved Indicates an issue that can not or will not be resolved. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 13, 2023
@Falmarri
Copy link
Author

Instead of creating a span and later "abandon" it, also consider to delay the span creation until the application can decide if it it needed or not.

This is what I ended up doing, though it's not ideal because the next span could be one of several. And so there are a few places I have to lazily create the parent span. But it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/unresolved Indicates an issue that can not or will not be resolved.
Projects
None yet
Development

No branches or pull requests

4 participants