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

Always Off Sampler #125

Merged
merged 40 commits into from
Jun 26, 2020
Merged

Conversation

nholbrook
Copy link
Contributor

Implements AlwayOffSampler based on the sampler interface in #118.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 23, 2020

CLA Check
The committers are authorized under a signed CLA.

@nholbrook
Copy link
Contributor Author

I signed it

@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #125 into master will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   93.29%   93.37%   +0.07%     
==========================================
  Files          66       69       +3     
  Lines        1656     1676      +20     
==========================================
+ Hits         1545     1565      +20     
  Misses        111      111              
Impacted Files Coverage Δ
...lude/opentelemetry/sdk/trace/samplers/always_off.h 100.00% <100.00%> (ø)
sdk/test/trace/always_off_sampler_test.cc 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/trace/sampler.h 100.00% <0.00%> (ø)

Copy link

@jsandler18 jsandler18 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. No comments from me.

@nholbrook nholbrook marked this pull request as ready for review June 23, 2020 19:25
@nholbrook nholbrook requested a review from a team June 23, 2020 19:25
*/
SamplingResult ShouldSample(
const SpanContext *parent_context,
trace_api::TraceId trace_id,
Copy link
Member

Choose a reason for hiding this comment

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

There is potential optimization to this, by avoiding the trace_id creation (random number generation) at all. Probably worth creating an issue for tracking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll bring this up to Johannes later today.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how we could easily avoid that. The trace_id is created only once for every trace anyway. And even if an always-off sampler is active, we might still need the trace id for an outgoing context.

Also, the spec requires the trace id to be passed to a sampler.

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM.

sdk/include/opentelemetry/sdk/trace/sampler.h Outdated Show resolved Hide resolved
sdk/include/opentelemetry/sdk/trace/always_off_sampler.h Outdated Show resolved Hide resolved
sdk/include/opentelemetry/sdk/trace/always_off_sampler.h Outdated Show resolved Hide resolved
*/
SamplingResult ShouldSample(
const SpanContext *parent_context,
trace_api::TraceId trace_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how we could easily avoid that. The trace_id is created only once for every trace anyway. And even if an always-off sampler is active, we might still need the trace id for an outgoing context.

Also, the spec requires the trace id to be passed to a sampler.

@pyohannes pyohannes mentioned this pull request Jun 26, 2020
@nholbrook nholbrook force-pushed the nholbrook/always-off-sampler branch from 62e5c21 to 61c95a9 Compare June 26, 2020 15:27
@nholbrook
Copy link
Contributor Author

I've made all the requested changes and moved the sampler to sdk/trace/samplers/always_off.h following conversation with @pyohannes.

Copy link
Contributor

@pyohannes pyohannes 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 and ready to merge (@reyang).

Thanks!

@reyang reyang merged commit ed0a36e into open-telemetry:master Jun 26, 2020
nadiaciobanu pushed a commit to nadiaciobanu/opentelemetry-cpp that referenced this pull request Jul 2, 2020
@reyang reyang mentioned this pull request Aug 25, 2020
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.

6 participants