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

comment on Scope class is not accurate regarding span ended #3109

Open
brucedlg opened this issue Oct 23, 2024 · 1 comment
Open

comment on Scope class is not accurate regarding span ended #3109

brucedlg opened this issue Oct 23, 2024 · 1 comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@brucedlg
Copy link

api/include/opentelemetry/trace/scope.h has following comment on the Scope class:

/**
 * Controls how long a span is active.
 *
 * On creation of the Scope object, the given span is set to the currently
 * active span. On destruction, the given span is ended and the previously
 * active span will be the currently active span again.
 */
class Scope final

It specifies that "the given span is ended". This is not accurate. The span is not ended simply because scope object is destroyed.

Users may not explicitly call span.End() based on the comment. This could delay the end of span.

@brucedlg brucedlg added the bug Something isn't working label Oct 23, 2024
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 23, 2024
@lalitb
Copy link
Member

lalitb commented Oct 30, 2024

@brucedlg you are correct. On the destruction of scope object, the currently active span is removed from the active context, so it is no longer active. The span only ends when either:

  • Span:End() is explicitly called
  • all shared references to the span are released (triggering the span’s destructor).

@marcalff marcalff added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

3 participants