-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
450 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
50 changes: 0 additions & 50 deletions
50
sdk/include/opentelemetry/sdk/trace/samplers/probability.h
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h
This file contains 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,49 @@ | ||
#pragma once | ||
|
||
#include "opentelemetry/sdk/trace/sampler.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace trace | ||
{ | ||
namespace trace_api = opentelemetry::trace; | ||
/** | ||
* The TraceIdRatioBased sampler computes and returns a decision based on the | ||
* provided trace_id and the configured ratio. | ||
*/ | ||
class TraceIdRatioBasedSampler : public Sampler | ||
{ | ||
public: | ||
/** | ||
* @param ratio a required value, 1.0 >= ratio >= 0.0. If the given trace_id | ||
* falls into a given ratio of all possible trace_id values, ShouldSample will | ||
* return RECORD_AND_SAMPLE. | ||
* @throws invalid_argument if ratio is out of bounds [0.0, 1.0] | ||
*/ | ||
explicit TraceIdRatioBasedSampler(double ratio); | ||
|
||
/** | ||
* @return Returns either RECORD_AND_SAMPLE or DROP based on current | ||
* sampler configuration and provided trace_id and ratio. trace_id | ||
* is used as a pseudorandom value in conjunction with the predefined | ||
* ratio to determine whether this trace should be sampled | ||
*/ | ||
SamplingResult ShouldSample(const trace_api::SpanContext & /*parent_context*/, | ||
trace_api::TraceId trace_id, | ||
nostd::string_view /*name*/, | ||
trace_api::SpanKind /*span_kind*/, | ||
const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override; | ||
|
||
/** | ||
* @return Description MUST be TraceIdRatioBasedSampler{0.000100} | ||
*/ | ||
nostd::string_view GetDescription() const noexcept override; | ||
|
||
private: | ||
std::string description_; | ||
const uint64_t threshold_; | ||
}; | ||
} // namespace trace | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
add_library( | ||
opentelemetry_trace | ||
tracer_provider.cc tracer.cc span.cc batch_span_processor.cc | ||
samplers/parent_or_else.cc samplers/probability.cc) | ||
samplers/parent.cc samplers/trace_id_ratio.cc) | ||
|
||
target_link_libraries(opentelemetry_trace opentelemetry_common) |
16 changes: 8 additions & 8 deletions
16
sdk/src/trace/samplers/parent_or_else.cc → sdk/src/trace/samplers/parent.cc
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.