-
Notifications
You must be signed in to change notification settings - Fork 560
Add sampler header file #118
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
89ce9f7
add sampler header file
e65cf5c
add param and comments
7b20dc1
change class definition
81cb054
add Decision enum
b206ced
add Decision enum
cdfcd3d
add ShouldSample params and placeholder
1f972e0
add ShouldSample params and placeholder
5097b2e
Merge branch 'sampling-api-header' of github.com:ziqizh/opentelemetry…
279ef0e
minor tweaks
bc14502
add sampler header file
f705b35
add param and comments
8111e93
change class definition
e4ac250
add Decision enum
48d4695
add Decision enum
7c4ac5a
minor tweaks
6fd2568
resolve conflict
5fcf4af
resolve conflict
ef00c7f
Merge branch 'sampling-api-header' of github.com:ziqizh/opentelemetry…
503edb6
change enum to enum class
7c204b8
change sampling result to struct
6d4632b
change param
71f8d9d
add AttributeKeyValue placeholder
590be00
add namespace
8d43a4a
style fix
7586d1d
Merge branch 'master' into sampling-api-header
0f1e88d
minor change
205d468
minor change
8ecce7e
add comments
1645769
Merge remote-tracking branch 'upstream/master' into sampling-api-header
885c7b4
add comments
15f2b2a
add comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #pragma once | ||
|
|
||
| #include "opentelemetry/common/attribute_value.h" | ||
| #include "opentelemetry/trace/span.h" | ||
| #include "opentelemetry/trace/trace_id.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace trace | ||
| { | ||
| namespace trace_api = opentelemetry::trace; | ||
|
|
||
| /** | ||
| * A sampling Decision for a Span to be created. | ||
| */ | ||
| enum class Decision | ||
| { | ||
| // IsRecording() == false, span will not be recorded and all events and attributes will be | ||
| // dropped. | ||
| NOT_RECORD, | ||
|
ziqizh marked this conversation as resolved.
|
||
| // IsRecording() == true, but Sampled flag MUST NOT be set. | ||
| RECORD, | ||
| // IsRecording() == true AND Sampled flag` MUST be set. | ||
| RECORD_AND_SAMPLE | ||
| }; | ||
|
|
||
| /** | ||
| * The output of ShouldSample. | ||
| * It contains a sampling Decision and a set of Span Attributes. | ||
| */ | ||
| struct SamplingResult | ||
| { | ||
| Decision decision; | ||
| // A set of span Attributes that will also be added to the Span. Can be nullptr. | ||
| std::unique_ptr<std::map<std::string, openelemetry::common::AttributeValue>> attributes; | ||
| }; | ||
|
|
||
| /** | ||
| * The Sampler interface allows users to create custom samplers which will return a | ||
| * SamplingResult based on information that is typically available just before the Span was created. | ||
| */ | ||
| class Sampler | ||
|
pyohannes marked this conversation as resolved.
|
||
| { | ||
| public: | ||
| // TODO: Remove this placeholder with real class | ||
| class SpanContext; | ||
| virtual ~Sampler() = default; | ||
| /** | ||
| * Called during Span creation to make a sampling decision. | ||
| * | ||
| * @param parent_context a const pointer of the SpanContext of a parent Span. | ||
| * null if this is a root span. | ||
| * @param trace_id the TraceId for the new Span. This will be identical to that in | ||
| * the parentContext, unless this is a root span. | ||
| * @param name the name of the new Span. | ||
| * @param spanKind the trace_api::SpanKind of the Span. | ||
| * @param attributes list of AttributeValue with their keys. | ||
| * @param links TODO: Collection of links that will be associated with the Span to be created. | ||
|
ziqizh marked this conversation as resolved.
|
||
| * @return sampling result whether span should be sampled or not. | ||
| * @since 0.1.0 | ||
| */ | ||
|
|
||
| virtual SamplingResult ShouldSample(const SpanContext *parent_context, | ||
| trace_api::TraceId trace_id, | ||
| nostd::string_view name, | ||
| trace_api::SpanKind span_kind, | ||
| const KeyValueIterable &attributes) noexcept = 0; | ||
|
|
||
| /** | ||
| * Returns the sampler name or short description with the configuration. | ||
| * This may be displayed on debug pages or in the logs. | ||
| * | ||
| * @return the description of this Sampler. | ||
| */ | ||
| virtual std::string GetDescription() const noexcept = 0; | ||
| }; | ||
| } // namespace trace | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.