Skip to content

Always Off Sampler#125

Merged
reyang merged 40 commits into
open-telemetry:masterfrom
ziqizh:nholbrook/always-off-sampler
Jun 26, 2020
Merged

Always Off Sampler#125
reyang merged 40 commits into
open-telemetry:masterfrom
ziqizh:nholbrook/always-off-sampler

Conversation

@nholbrook
Copy link
Copy Markdown
Contributor

Implements AlwayOffSampler based on the sampler interface in #118.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jun 23, 2020

CLA Check
The committers are authorized under a signed CLA.

@nholbrook
Copy link
Copy Markdown
Contributor Author

I signed it

@codecov
Copy link
Copy Markdown

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%> (ø)

Comment thread sdk/include/opentelemetry/sdk/trace/sampler.h
Copy link
Copy Markdown

@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.

Comment thread sdk/src/trace/always_off_sampler.cc Outdated
@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
Comment thread sdk/src/trace/always_off_sampler.cc Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/always_off_sampler.h Outdated
*/
SamplingResult ShouldSample(
const SpanContext *parent_context,
trace_api::TraceId trace_id,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread sdk/include/opentelemetry/sdk/trace/sampler.h
Comment thread sdk/include/opentelemetry/sdk/trace/always_off_sampler.h Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/always_off_sampler.h
*/
SamplingResult ShouldSample(
const SpanContext *parent_context,
trace_api::TraceId trace_id,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
GerHobbelt pushed a commit to GerHobbelt/opentelemetry-cpp that referenced this pull request Jun 17, 2025
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