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

fix for sampling root span #784

Merged
merged 4 commits into from
May 24, 2021
Merged

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented May 21, 2021

Fixes #782

Changes

Move span_context creation from sdk::Span to sdk::Tracer, and pass it in sdk::Span constructor. This also allows passing valid trace_id of root span to Sampler, and in accordance with how other languages implement.

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 21, 2021 16:54
@lalitb lalitb changed the title Root span sample fix for sampling root span May 21, 2021
@codecov
Copy link

codecov bot commented May 21, 2021

Codecov Report

Merging #784 (515be01) into main (5a1b189) will increase coverage by 0.04%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #784      +/-   ##
==========================================
+ Coverage   95.95%   96.00%   +0.04%     
==========================================
  Files         176      176              
  Lines        7172     7186      +14     
==========================================
+ Hits         6882     6899      +17     
+ Misses        290      287       -3     
Impacted Files Coverage Δ
sdk/src/trace/span.h 100.00% <ø> (ø)
sdk/test/trace/tracer_test.cc 99.45% <91.66%> (-0.55%) ⬇️
sdk/src/trace/span.cc 91.46% <100.00%> (+2.33%) ⬆️
sdk/src/trace/tracer.cc 87.09% <100.00%> (+15.66%) ⬆️

}
else
{
return {Decision::DROP};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert(false) here? Seems invalid trace Id should not be passed to sampler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of asserting in unit-test, better would be to fail the particular unit-test and let other tests run? Like in this case, ValidTraceIdToSampler test will fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fail this particular unit-test works too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it. Have changed it.

@lalitb lalitb merged commit 57d80f7 into open-telemetry:main May 24, 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.

Root span is not sampled correctly
3 participants