-
Notifications
You must be signed in to change notification settings - Fork 455
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
Remove unnecessary call on Span::End() #449
Conversation
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
=======================================
Coverage 94.37% 94.37%
=======================================
Files 185 185
Lines 8014 8014
=======================================
Hits 7563 7563
Misses 451 451 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test somewhere that verifies the behavior is still correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good. As @jsuereth mentioned, would be good to have unit test for this which seems missing.
auto span = get_tracer()->StartSpan("f1"); | ||
span->End(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An explicit call to End
is still necessary, not for the context memory issue, but because spans are not automatically ended anymore when the object goes out of scope (since StartSpan
returns a shared_ptr
instead of an unique_ptr
now).
This should take care of ending the span:
opentelemetry::trace::Scope scope(span);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for spans in this file, even they are shared_ptr
, there should be only one owner which is the declared auto span
, so destruction of auto span
will destruct the Span
object and End()
it accordingly. So current code should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I still think we should add the Scope
, otherwise spans will not be parented correctly (no current span will ever be set, so no parent will be set on any of the spans).
This was not broken by your change, that was already broken before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual testing for now is fine. We should try to avoid adding more examples that require manual tests though :)
End()
calls are added to Span so explicit call is no longer necessary, see #287 (comment)