opentelemetry-cpp icon indicating copy to clipboard operation
opentelemetry-cpp copied to clipboard

comment on Scope class is not accurate regarding span ended

Open brucedlg opened this issue 1 year ago • 2 comments

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 avatar Oct 23 '24 20:10 brucedlg

@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).

lalitb avatar Oct 30 '24 21:10 lalitb

This issue was marked as stale due to lack of activity.

github-actions[bot] avatar Jan 04 '25 01:01 github-actions[bot]