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

Parent-or-else Sampler #142

Merged
merged 10 commits into from
Jul 9, 2020
Merged

Parent-or-else Sampler #142

merged 10 commits into from
Jul 9, 2020

Conversation

ziqizh
Copy link
Contributor

@ziqizh ziqizh commented Jun 30, 2020

Create a ParentOrElse sampler and corresponding test cases described in the spec.

@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #142 into master will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #142      +/-   ##
==========================================
+ Coverage   93.61%   93.75%   +0.13%     
==========================================
  Files          71       74       +3     
  Lines        1754     1792      +38     
==========================================
+ Hits         1642     1680      +38     
  Misses        112      112              
Impacted Files Coverage Δ
.../opentelemetry/sdk/trace/samplers/parent_or_else.h 100.00% <100.00%> (ø)
sdk/src/trace/samplers/parent_or_else.cc 100.00% <100.00%> (ø)
sdk/test/trace/parent_or_else_sampler_test.cc 100.00% <100.00%> (ø)

sdk/src/trace/samplers/parent_or_else.cc Outdated Show resolved Hide resolved
sdk/test/trace/parent_or_else_sampler_test.cc Outdated Show resolved Hide resolved
@ziqizh ziqizh marked this pull request as ready for review July 1, 2020 22:55
@ziqizh ziqizh requested a review from a team July 1, 2020 22:55
@ziqizh ziqizh changed the title Parent or else Parent-or-else Sampler Jul 6, 2020
* A placeholder class that stores the states of a span.
* Will be replaced by the real SpanContext class once it is implemented.
*/
class Sampler::SpanContext
Copy link
Contributor

Choose a reason for hiding this comment

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


private:
std::shared_ptr<Sampler> delegate_sampler_;
std::string description_;
Copy link
Contributor

Choose a reason for hiding this comment

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

We could make both members const, as there's no way to change them.

{
return {Decision::NOT_RECORD, nullptr};
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could flatten this out, to increase readability:

if (parent_context == nullptr)
{
  return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes);
}

if (parent_context->sampled_flag)
{
  return {Decision::RECORD_AND_SAMPLE, nullptr};
}

return {Decision::NOT_RECORD, nullptr};

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. Extracting the SpanContext class will happen in a separate PR.

@pyohannes
Copy link
Contributor

@reyang this should be ready to merge.

}
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Copy link
Member

Choose a reason for hiding this comment

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

nit: would you add an empty line before EOF?

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.

bool is_recording;
bool sampled_flag;
};
/**
Copy link
Member

Choose a reason for hiding this comment

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

nit: probably add an empty line here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@reyang
Copy link
Member

reyang commented Jul 9, 2020

Please rebase after fixing the nits.

@reyang reyang merged commit d2f979b into open-telemetry:master Jul 9, 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.

4 participants