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

Remove unnecessary call on Span::End() #449

Merged
merged 5 commits into from
Dec 18, 2020

Conversation

ThomsonTan
Copy link
Contributor

End() calls are added to Span so explicit call is no longer necessary, see #287 (comment)

@ThomsonTan ThomsonTan requested a review from a team December 14, 2020 23:16
@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #449 (5099740) into master (4aa124f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #449   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files         185      185           
  Lines        8014     8014           
=======================================
  Hits         7563     7563           
  Misses        451      451           

Copy link
Contributor

@jsuereth jsuereth left a 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?

Copy link
Member

@lalitb lalitb left a 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.

Comment on lines 16 to 20
auto span = get_tracer()->StartSpan("f1");
span->End();
Copy link
Contributor

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);

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@ThomsonTan
Copy link
Contributor Author

Is there a test somewhere that verifies the behavior is still correct?

@jsuereth @lalitb seems we don't have test to cover these examples while I verified it locally. If this is correct, then we'll need add some test to make sure the examples run correctly.

@lalitb
Copy link
Member

lalitb commented Dec 16, 2020

@jsuereth @lalitb seems we don't have test to cover these examples while I verified it locally. If this is correct, then we'll need add some test to make sure the examples run correctly.

Correct, and I see you have created a issue for this.

Copy link
Contributor

@jsuereth jsuereth left a 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 :)

@lalitb lalitb merged commit c8054c5 into open-telemetry:master Dec 18, 2020
kxyr pushed a commit to open-o11y/opentelemetry-cpp that referenced this pull request Dec 22, 2020
kxyr pushed a commit to open-o11y/opentelemetry-cpp that referenced this pull request Dec 22, 2020
@ThomsonTan ThomsonTan deleted the RemoveEnd branch September 22, 2021 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants