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

Return Scope object instead of unique_ptr<Scope> from Tracer::WithActiveSpan() #788

Merged
merged 17 commits into from
May 25, 2021

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented May 23, 2021

Fixes #787

Changes

  • As mentioned in why nostd::unique_ptr<Scope> not Scope #787 , Tracer::WithActiveSpan() can avoid memory allocation on heap by returning newly created Scope object instead of unique_ptr<Scope>. The copy constructor of Scope is implicitly deleted because of unique_ptr member variable, so this ensures multiple copies are not possible for Scope.

  • Also modified etw::tracer::StartSpan() method to not make span active immediately after creating as this deviates from the specs. tracer::WithActiveSpan() should be called explicitly by instrumentation library to make it active. ( cc @maxgolov )

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team May 23, 2021 16:50
@codecov
Copy link

codecov bot commented May 23, 2021

Codecov Report

Merging #788 (e29d3d2) into main (3fa6525) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #788      +/-   ##
==========================================
+ Coverage   95.99%   96.00%   +0.01%     
==========================================
  Files         176      176              
  Lines        7186     7183       -3     
==========================================
- Hits         6898     6896       -2     
+ Misses        288      287       -1     
Impacted Files Coverage Δ
api/include/opentelemetry/trace/tracer.h 100.00% <100.00%> (ø)
api/test/trace/tracer_test.cc 100.00% <100.00%> (ø)
...include/opentelemetry/sdk/common/circular_buffer.h 100.00% <0.00%> (+2.12%) ⬆️

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.

We may want to have a secondary method to apply active-span to context that DOESN'T have auto-scope (for advanced use cases).

Like this cleanup!

@lalitb lalitb merged commit 2b080c1 into open-telemetry:main May 25, 2021
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.

why nostd::unique_ptr<Scope> not Scope
4 participants