Skip to content

Parent-or-else Sampler#142

Merged
reyang merged 10 commits intoopen-telemetry:masterfrom
ziqizh:parent-or-else
Jul 9, 2020
Merged

Parent-or-else Sampler#142
reyang merged 10 commits intoopen-telemetry:masterfrom
ziqizh:parent-or-else

Conversation

@ziqizh
Copy link
Copy Markdown
Contributor

@ziqizh ziqizh commented Jun 30, 2020

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

@codecov
Copy link
Copy Markdown

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

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

@pyohannes
Copy link
Copy Markdown
Contributor

@reyang this should be ready to merge.

}
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE No newline at end of file
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.

nit: would you add an empty line before EOF?

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.

bool is_recording;
bool sampled_flag;
};
/**
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.

nit: probably add an empty line here.

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.

Done.

@reyang
Copy link
Copy Markdown
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
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.

4 participants