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

Respect sampled bit in probability sampler #798

Merged
merged 11 commits into from
Feb 20, 2020
Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Feb 19, 2020

Fixes #787

@dyladan dyladan added the bug Something isn't working label Feb 19, 2020
@dyladan dyladan added this to the Beta milestone Feb 19, 2020
@dyladan
Copy link
Member Author

dyladan commented Feb 19, 2020

/cc @Flarna

@Flarna
Copy link
Member

Flarna commented Feb 20, 2020

I think we should respect the trace flag not only in the true case.

Maybe move this check to the tracer and call the sampler only for root spans?

@dyladan
Copy link
Member Author

dyladan commented Feb 20, 2020

I think we should respect the trace flag not only in the true case.

Maybe move this check to the tracer and call the sampler only for root spans?

I don't want to move the logic to the tracer because you could theoretically want to implement a sampler that does not respect trace flags (perhaps you want to use some tracestate entry instead). I revised the logic, PTAL.

@dyladan dyladan self-assigned this Feb 20, 2020
@Flarna
Copy link
Member

Flarna commented Feb 20, 2020

Looks good. I agree that keeping it out of tracer is the better choice.

The checks in processors seem to be redundant as unsampled spans are not forwarded to processors anyway.

@dyladan
Copy link
Member Author

dyladan commented Feb 20, 2020

@Flarna I removed the isSampled check from the span processors. I looked through the spec and don't see anywhere it says the span processor should be checking. I verified that you are correct, unsampled spans are indeed not sent to the span processor. I think whoever implemented the span processors was probably just being safe.

/cc @mayurkale22 WDYT about this decision?

@codecov-io
Copy link

codecov-io commented Feb 20, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@fc287d3). Click here to learn what that means.
The diff coverage is 75%.

@@            Coverage Diff            @@
##             master     #798   +/-   ##
=========================================
  Coverage          ?   92.74%           
=========================================
  Files             ?      242           
  Lines             ?    10801           
  Branches          ?     1060           
=========================================
  Hits              ?    10017           
  Misses            ?      784           
  Partials          ?        0
Impacted Files Coverage Δ
packages/opentelemetry-api/src/metrics/Metric.ts 100% <ø> (ø)
packages/opentelemetry-metrics/src/Metric.ts 95.12% <ø> (ø)
...y-api/test/noop-implementations/noop-meter.test.ts 100% <100%> (ø)
...metry-core/src/trace/sampler/ProbabilitySampler.ts 94.11% <66.66%> (ø)

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

Overall lgtm, added a few comments

@dyladan dyladan requested a review from mayurkale22 February 20, 2020 18:08
Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm except one thing with undefined checking,

@dyladan dyladan merged commit 5228dfa into master Feb 20, 2020
@dyladan dyladan deleted the trace-flags-sampled branch February 20, 2020 22:25
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProbabilitySampler doesn't honor W3C sampled flag
5 participants