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 Samplers to match spec #1037

Merged
merged 20 commits into from
Aug 12, 2020
Merged

Fix Samplers to match spec #1037

merged 20 commits into from
Aug 12, 2020

Conversation

rajkumar-rangaraj
Copy link
Contributor

@rajkumar-rangaraj rajkumar-rangaraj commented Aug 10, 2020

Fixes #941 .

Changes

Please provide a brief description of the changes here. Update the
CHANGELOG.md for non-trivial changes.

  • Added SamplingDecision enum in Sampling result to match the spec. This has a 1:1 mapping with ActivityDataRequest. Created SamplingDecision enum instead of using ActivityDataRequest, to keep enum names simple and to match OT spec. This way it will be easier to write custom sampler.
    • SamplingDecision.RecordAndSampled -> ActivityDataRequest.AllDataAndRecorded
    • SamplingDecision.Record -> ActivityDataRequest.AllData
    • SamplingDecision.NotRecord -> ActivityDataRequest.PropagationData
  • Modified SimpleActivityProcessor and BatchingActivityProcessor to export data only if Activity.Recorded is true.
  • ActivityListener calls activity processor only when SamplingDecision is SamplingDecision.Record or SamplingDecision.RecordAndSampled

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

  • Design discussion issue #
  • Changes in public API reviewed

@rajkumar-rangaraj rajkumar-rangaraj requested a review from a team August 10, 2020 23:29
@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #1037 into master will decrease coverage by 0.04%.
The diff coverage is 92.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1037      +/-   ##
==========================================
- Coverage   77.12%   77.08%   -0.05%     
==========================================
  Files         221      221              
  Lines        6156     6092      -64     
==========================================
- Hits         4748     4696      -52     
+ Misses       1408     1396      -12     
Impacted Files Coverage Δ
src/OpenTelemetry/Trace/SamplingParameters.cs 76.92% <ø> (ø)
src/OpenTelemetry/Trace/TracerProviderBuilder.cs 89.18% <57.14%> (ø)
src/OpenTelemetry/Trace/SamplingResult.cs 52.38% <75.00%> (+7.93%) ⬆️
src/OpenTelemetry/Trace/ActivitySourceAdapter.cs 95.12% <100.00%> (+0.25%) ⬆️
src/OpenTelemetry/Trace/AlwaysOffSampler.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/Trace/AlwaysOnSampler.cs 100.00% <100.00%> (ø)
...c/OpenTelemetry/Trace/BatchingActivityProcessor.cs 93.79% <100.00%> (ø)
src/OpenTelemetry/Trace/ParentOrElseSampler.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/Trace/ProbabilitySampler.cs 89.47% <100.00%> (ø)
src/OpenTelemetry/Trace/SimpleActivityProcessor.cs 70.83% <100.00%> (+1.26%) ⬆️
... and 33 more

/// <summary>
/// Enumeration to define sampling decision.
/// </summary>
public enum Decision
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about having this name under OpenTelemetry.Trace:

  1. Decision could be used by other namespaces given it is a common word.
  2. It is not clear literally what does OpenTelemetry.Trace.Decision mean.

This is what OpenTelemetry Python is doing and we might borrow some idea.

Copy link
Member

Choose a reason for hiding this comment

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

My suggestion would be:

  1. Introduce OpenTelemetry.Trace.Sampling namespace.
  2. Put the Sampler base class, Decision and all the samplers under that namespace.
  3. Folks who don't use sampler explicitly don't need to have using OpenTelemetry.Trace.Sampling.
  4. Folks who use sampler or write sampler will need to have using OpenTelemetry.Trace.Sampling.

An alternative approach would be calling this class SamplingDecision, but that seems to be worse?

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @reyang it's a bit too generic to have in a common namespace. I think SamplingDecision is a good change to make regardless of where it goes. Decision alone is hyper-generic 🤣

Copy link
Member

@reyang reyang Aug 11, 2020

Choose a reason for hiding this comment

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

I would prefer SamplingDecision as the class name if we agree to move the current samplers from src/Trace/Samplers to src/Trace and remove the OpenTelemetry.Trace.Samplers namespace 😃

(the movement of existing samplers doesn't have to be in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the current samplers from src/Trace/Samplers to src/Trace and removed the OpenTelemetry.Trace.Samplers namespace. Using SamplingDecision as the enum name.

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.

Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

@cijothomas cijothomas merged commit 7943d96 into open-telemetry:master Aug 12, 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.

Fix Samplers to match spec.
4 participants