From 04aba17fc9c266d3ac6fa93938a89af4765f8f63 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 16 Sep 2020 19:16:29 -0700 Subject: [PATCH 1/3] Update sample decision name based on spec update --- sdk/include/opentelemetry/sdk/trace/sampler.h | 4 +- .../sdk/trace/samplers/always_off.h | 6 +- .../sdk/trace/samplers/parent_or_else.h | 2 +- .../sdk/trace/samplers/probability.h | 2 +- sdk/src/trace/samplers/parent_or_else.cc | 82 +++++++++---------- sdk/src/trace/samplers/probability.cc | 6 +- sdk/src/trace/tracer.cc | 2 +- sdk/test/trace/always_off_sampler_test.cc | 62 +++++++------- sdk/test/trace/parent_or_else_sampler_test.cc | 4 +- sdk/test/trace/probability_sampler_test.cc | 6 +- sdk/test/trace/tracer_test.cc | 2 +- 11 files changed, 89 insertions(+), 89 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 2308ae7080..29bf54723c 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -24,9 +24,9 @@ enum class Decision { // IsRecording() == false, span will not be recorded and all events and attributes will be // dropped. - NOT_RECORD, + IGNORE, // IsRecording() == true, but Sampled flag MUST NOT be set. - RECORD, + RECORD_ONLY, // IsRecording() == true AND Sampled flag` MUST be set. RECORD_AND_SAMPLE }; diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h index 894b8ed598..f392249f1f 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h @@ -10,14 +10,14 @@ namespace trace namespace trace_api = opentelemetry::trace; /** - * The always off sampler always returns NOT_RECORD, effectively disabling + * The always off sampler always returns IGNORE, effectively disabling * tracing functionality. */ class AlwaysOffSampler : public Sampler { public: /** - * @return Returns NOT_RECORD always + * @return Returns IGNORE always */ SamplingResult ShouldSample(const trace_api::SpanContext * /*parent_context*/, trace_api::TraceId /*trace_id*/, @@ -25,7 +25,7 @@ class AlwaysOffSampler : public Sampler trace_api::SpanKind /*span_kind*/, const trace_api::KeyValueIterable & /*attributes*/) noexcept override { - return {Decision::NOT_RECORD, nullptr}; + return {Decision::IGNORE, nullptr}; } /** diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h index ce16f7e9c6..14bdf95744 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h @@ -20,7 +20,7 @@ class ParentOrElseSampler : public Sampler explicit ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept; /** The decision either respects the parent span's sampling decision or delegates to * delegateSampler for root spans - * @return Returns NOT_RECORD always + * @return Returns IGNORE always */ SamplingResult ShouldSample(const trace_api::SpanContext *parent_context, trace_api::TraceId trace_id, diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/probability.h b/sdk/include/opentelemetry/sdk/trace/samplers/probability.h index 9ad8e7f0ea..a866eef861 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/probability.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/probability.h @@ -24,7 +24,7 @@ class ProbabilitySampler : public Sampler explicit ProbabilitySampler(double probability); /** - * @return Returns either RECORD_AND_SAMPLE or NOT_RECORD based on current + * @return Returns either RECORD_AND_SAMPLE or IGNORE based on current * sampler configuration and provided parent_context / tracer_id. tracer_id * is used as a pseudorandom value in conjunction with the predefined * threshold to determine whether this trace should be sampled diff --git a/sdk/src/trace/samplers/parent_or_else.cc b/sdk/src/trace/samplers/parent_or_else.cc index 29026a0167..3b375550fc 100644 --- a/sdk/src/trace/samplers/parent_or_else.cc +++ b/sdk/src/trace/samplers/parent_or_else.cc @@ -1,41 +1,41 @@ -#include "opentelemetry/sdk/trace/samplers/parent_or_else.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace trace -{ -ParentOrElseSampler::ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept - : delegate_sampler_(delegate_sampler), - description_("ParentOrElse{" + std::string{delegate_sampler->GetDescription()} + "}") -{} - -SamplingResult ParentOrElseSampler::ShouldSample( - const trace_api::SpanContext *parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept -{ - if (parent_context == nullptr) - { - // If no parent (root span) exists returns the result of the delegateSampler - return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes); - } - - // If parent exists: - if (parent_context->IsSampled()) - { - return {Decision::RECORD_AND_SAMPLE, nullptr}; - } - - return {Decision::NOT_RECORD, nullptr}; -} - -nostd::string_view ParentOrElseSampler::GetDescription() const noexcept -{ - return description_; -} -} // namespace trace -} // namespace sdk -OPENTELEMETRY_END_NAMESPACE +#include "opentelemetry/sdk/trace/samplers/parent_or_else.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace trace +{ +ParentOrElseSampler::ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept + : delegate_sampler_(delegate_sampler), + description_("ParentOrElse{" + std::string{delegate_sampler->GetDescription()} + "}") +{} + +SamplingResult ParentOrElseSampler::ShouldSample( + const trace_api::SpanContext *parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + const trace_api::KeyValueIterable &attributes) noexcept +{ + if (parent_context == nullptr) + { + // If no parent (root span) exists returns the result of the delegateSampler + return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes); + } + + // If parent exists: + if (parent_context->IsSampled()) + { + return {Decision::RECORD_AND_SAMPLE, nullptr}; + } + + return {Decision::IGNORE, nullptr}; +} + +nostd::string_view ParentOrElseSampler::GetDescription() const noexcept +{ + return description_; +} +} // namespace trace +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/trace/samplers/probability.cc b/sdk/src/trace/samplers/probability.cc index 0fd45644e4..c279654861 100644 --- a/sdk/src/trace/samplers/probability.cc +++ b/sdk/src/trace/samplers/probability.cc @@ -98,19 +98,19 @@ SamplingResult ProbabilitySampler::ShouldSample( } else { - return {Decision::NOT_RECORD, nullptr}; + return {Decision::IGNORE, nullptr}; } } if (threshold_ == 0) - return {Decision::NOT_RECORD, nullptr}; + return {Decision::IGNORE, nullptr}; if (CalculateThresholdFromBuffer(trace_id) <= threshold_) { return {Decision::RECORD_AND_SAMPLE, nullptr}; } - return {Decision::NOT_RECORD, nullptr}; + return {Decision::IGNORE, nullptr}; } nostd::string_view ProbabilitySampler::GetDescription() const noexcept diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 8c7e2a4b59..9f2c8ab635 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -52,7 +52,7 @@ nostd::shared_ptr Tracer::StartSpan( // TODO: replace nullptr with parent context in span context auto sampling_result = sampler_->ShouldSample(nullptr, trace_api::TraceId(), name, options.kind, attributes); - if (sampling_result.decision == Decision::NOT_RECORD) + if (sampling_result.decision == Decision::IGNORE) { auto span = nostd::shared_ptr{ new (std::nothrow) trace_api::NoopSpan{this->shared_from_this()}}; diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index f987185c2b..87f8371de5 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -1,31 +1,31 @@ -#include "opentelemetry/context/threadlocal_context.h" -#include "opentelemetry/sdk/trace/samplers/always_off.h" - -#include - -using opentelemetry::sdk::trace::AlwaysOffSampler; -using opentelemetry::sdk::trace::Decision; - -TEST(AlwaysOffSampler, ShouldSample) -{ - AlwaysOffSampler sampler; - - opentelemetry::trace::TraceId trace_id; - opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; - - using M = std::map; - M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; - - auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); - - ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); - ASSERT_EQ(nullptr, sampling_result.attributes); -} - -TEST(AlwaysOffSampler, GetDescription) -{ - AlwaysOffSampler sampler; - - ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); -} +#include "opentelemetry/context/threadlocal_context.h" +#include "opentelemetry/sdk/trace/samplers/always_off.h" + +#include + +using opentelemetry::sdk::trace::AlwaysOffSampler; +using opentelemetry::sdk::trace::Decision; + +TEST(AlwaysOffSampler, ShouldSample) +{ + AlwaysOffSampler sampler; + + opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; + + using M = std::map; + M m1 = {{}}; + opentelemetry::trace::KeyValueIterableView view{m1}; + + auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); + + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(nullptr, sampling_result.attributes); +} + +TEST(AlwaysOffSampler, GetDescription) +{ + AlwaysOffSampler sampler; + + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); +} diff --git a/sdk/test/trace/parent_or_else_sampler_test.cc b/sdk/test/trace/parent_or_else_sampler_test.cc index 7e376fd91e..ab1c2193b9 100644 --- a/sdk/test/trace/parent_or_else_sampler_test.cc +++ b/sdk/test/trace/parent_or_else_sampler_test.cc @@ -29,7 +29,7 @@ TEST(ParentOrElseSampler, ShouldSample) auto sampling_result = sampler_off.ShouldSample(nullptr, trace_id, "", span_kind, view); auto sampling_result2 = sampler_on.ShouldSample(nullptr, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result2.decision); // Case 2: Parent exists and SampledFlag is true @@ -40,7 +40,7 @@ TEST(ParentOrElseSampler, ShouldSample) // Case 3: Parent exists and SampledFlag is false auto sampling_result4 = sampler_on.ShouldSample(&parent_context_nonsampled, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::NOT_RECORD, sampling_result4.decision); + ASSERT_EQ(Decision::IGNORE, sampling_result4.decision); } TEST(ParentOrElseSampler, GetDescription) diff --git a/sdk/test/trace/probability_sampler_test.cc b/sdk/test/trace/probability_sampler_test.cc index cd4815aa46..02105e5b44 100644 --- a/sdk/test/trace/probability_sampler_test.cc +++ b/sdk/test/trace/probability_sampler_test.cc @@ -75,7 +75,7 @@ TEST(ProbabilitySampler, ShouldSampleWithoutContext) sampling_result = s1.ShouldSample(nullptr, valid_trace_id, "", span_kind, view); - ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); ProbabilitySampler s2(0.50000001); @@ -89,7 +89,7 @@ TEST(ProbabilitySampler, ShouldSampleWithoutContext) sampling_result = s3.ShouldSample(nullptr, valid_trace_id, "", span_kind, view); - ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); ProbabilitySampler s4(0.50000000); @@ -117,7 +117,7 @@ TEST(ProbabilitySampler, ShouldSampleWithContext) auto sampling_result = s1.ShouldSample(&c1, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::NOT_RECORD, sampling_result.decision); + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); sampling_result = s1.ShouldSample(&c2, trace_id, "", span_kind, view); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index ce46c862bb..5f91eaf471 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -156,7 +156,7 @@ TEST(Tracer, StartSpanSampleOff) tracer_off->StartSpan("span 2")->End(); // The span doesn't write any span data because the sampling decision is alway - // NOT_RECORD. + // IGNORE. ASSERT_EQ(0, spans_received->size()); } From 04f0bc808e2c431d982cc15979f867d11fd97f44 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 16 Sep 2020 19:43:05 -0700 Subject: [PATCH 2/3] Revert unexpected line ending change --- sdk/src/trace/samplers/parent_or_else.cc | 82 +++++++++++------------ sdk/test/trace/always_off_sampler_test.cc | 62 ++++++++--------- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/sdk/src/trace/samplers/parent_or_else.cc b/sdk/src/trace/samplers/parent_or_else.cc index 3b375550fc..cffa3032b8 100644 --- a/sdk/src/trace/samplers/parent_or_else.cc +++ b/sdk/src/trace/samplers/parent_or_else.cc @@ -1,41 +1,41 @@ -#include "opentelemetry/sdk/trace/samplers/parent_or_else.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace trace -{ -ParentOrElseSampler::ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept - : delegate_sampler_(delegate_sampler), - description_("ParentOrElse{" + std::string{delegate_sampler->GetDescription()} + "}") -{} - -SamplingResult ParentOrElseSampler::ShouldSample( - const trace_api::SpanContext *parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept -{ - if (parent_context == nullptr) - { - // If no parent (root span) exists returns the result of the delegateSampler - return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes); - } - - // If parent exists: - if (parent_context->IsSampled()) - { - return {Decision::RECORD_AND_SAMPLE, nullptr}; - } - - return {Decision::IGNORE, nullptr}; -} - -nostd::string_view ParentOrElseSampler::GetDescription() const noexcept -{ - return description_; -} -} // namespace trace -} // namespace sdk -OPENTELEMETRY_END_NAMESPACE +#include "opentelemetry/sdk/trace/samplers/parent_or_else.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace trace +{ +ParentOrElseSampler::ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept + : delegate_sampler_(delegate_sampler), + description_("ParentOrElse{" + std::string{delegate_sampler->GetDescription()} + "}") +{} + +SamplingResult ParentOrElseSampler::ShouldSample( + const trace_api::SpanContext *parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + const trace_api::KeyValueIterable &attributes) noexcept +{ + if (parent_context == nullptr) + { + // If no parent (root span) exists returns the result of the delegateSampler + return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes); + } + + // If parent exists: + if (parent_context->IsSampled()) + { + return {Decision::RECORD_AND_SAMPLE, nullptr}; + } + + return {Decision::IGNORE, nullptr}; +} + +nostd::string_view ParentOrElseSampler::GetDescription() const noexcept +{ + return description_; +} +} // namespace trace +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 87f8371de5..679427e6b8 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -1,31 +1,31 @@ -#include "opentelemetry/context/threadlocal_context.h" -#include "opentelemetry/sdk/trace/samplers/always_off.h" - -#include - -using opentelemetry::sdk::trace::AlwaysOffSampler; -using opentelemetry::sdk::trace::Decision; - -TEST(AlwaysOffSampler, ShouldSample) -{ - AlwaysOffSampler sampler; - - opentelemetry::trace::TraceId trace_id; - opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; - - using M = std::map; - M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; - - auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); - - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); - ASSERT_EQ(nullptr, sampling_result.attributes); -} - -TEST(AlwaysOffSampler, GetDescription) -{ - AlwaysOffSampler sampler; - - ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); -} +#include "opentelemetry/context/threadlocal_context.h" +#include "opentelemetry/sdk/trace/samplers/always_off.h" + +#include + +using opentelemetry::sdk::trace::AlwaysOffSampler; +using opentelemetry::sdk::trace::Decision; + +TEST(AlwaysOffSampler, ShouldSample) +{ + AlwaysOffSampler sampler; + + opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; + + using M = std::map; + M m1 = {{}}; + opentelemetry::trace::KeyValueIterableView view{m1}; + + auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); + + ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(nullptr, sampling_result.attributes); +} + +TEST(AlwaysOffSampler, GetDescription) +{ + AlwaysOffSampler sampler; + + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); +} From c94fc18788a0d33e144b3b1b577359b0624cbb8d Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 16 Sep 2020 20:30:27 -0700 Subject: [PATCH 3/3] Experimenting renaming Decision::IGNORE to Decision::DROP --- sdk/include/opentelemetry/sdk/trace/sampler.h | 2 +- sdk/include/opentelemetry/sdk/trace/samplers/always_off.h | 6 +++--- .../opentelemetry/sdk/trace/samplers/parent_or_else.h | 2 +- sdk/include/opentelemetry/sdk/trace/samplers/probability.h | 2 +- sdk/src/trace/samplers/parent_or_else.cc | 2 +- sdk/src/trace/samplers/probability.cc | 6 +++--- sdk/src/trace/tracer.cc | 2 +- sdk/test/trace/always_off_sampler_test.cc | 2 +- sdk/test/trace/parent_or_else_sampler_test.cc | 4 ++-- sdk/test/trace/probability_sampler_test.cc | 6 +++--- sdk/test/trace/tracer_test.cc | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 29bf54723c..5fe12de26b 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -24,7 +24,7 @@ enum class Decision { // IsRecording() == false, span will not be recorded and all events and attributes will be // dropped. - IGNORE, + DROP, // IsRecording() == true, but Sampled flag MUST NOT be set. RECORD_ONLY, // IsRecording() == true AND Sampled flag` MUST be set. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h index f392249f1f..dbce35d8da 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h @@ -10,14 +10,14 @@ namespace trace namespace trace_api = opentelemetry::trace; /** - * The always off sampler always returns IGNORE, effectively disabling + * The always off sampler always returns DROP, effectively disabling * tracing functionality. */ class AlwaysOffSampler : public Sampler { public: /** - * @return Returns IGNORE always + * @return Returns DROP always */ SamplingResult ShouldSample(const trace_api::SpanContext * /*parent_context*/, trace_api::TraceId /*trace_id*/, @@ -25,7 +25,7 @@ class AlwaysOffSampler : public Sampler trace_api::SpanKind /*span_kind*/, const trace_api::KeyValueIterable & /*attributes*/) noexcept override { - return {Decision::IGNORE, nullptr}; + return {Decision::DROP, nullptr}; } /** diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h index 14bdf95744..c6b6e1255b 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent_or_else.h @@ -20,7 +20,7 @@ class ParentOrElseSampler : public Sampler explicit ParentOrElseSampler(std::shared_ptr delegate_sampler) noexcept; /** The decision either respects the parent span's sampling decision or delegates to * delegateSampler for root spans - * @return Returns IGNORE always + * @return Returns DROP always */ SamplingResult ShouldSample(const trace_api::SpanContext *parent_context, trace_api::TraceId trace_id, diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/probability.h b/sdk/include/opentelemetry/sdk/trace/samplers/probability.h index a866eef861..cda0db4e51 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/probability.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/probability.h @@ -24,7 +24,7 @@ class ProbabilitySampler : public Sampler explicit ProbabilitySampler(double probability); /** - * @return Returns either RECORD_AND_SAMPLE or IGNORE based on current + * @return Returns either RECORD_AND_SAMPLE or DROP based on current * sampler configuration and provided parent_context / tracer_id. tracer_id * is used as a pseudorandom value in conjunction with the predefined * threshold to determine whether this trace should be sampled diff --git a/sdk/src/trace/samplers/parent_or_else.cc b/sdk/src/trace/samplers/parent_or_else.cc index cffa3032b8..e61bc38b2c 100644 --- a/sdk/src/trace/samplers/parent_or_else.cc +++ b/sdk/src/trace/samplers/parent_or_else.cc @@ -29,7 +29,7 @@ SamplingResult ParentOrElseSampler::ShouldSample( return {Decision::RECORD_AND_SAMPLE, nullptr}; } - return {Decision::IGNORE, nullptr}; + return {Decision::DROP, nullptr}; } nostd::string_view ParentOrElseSampler::GetDescription() const noexcept diff --git a/sdk/src/trace/samplers/probability.cc b/sdk/src/trace/samplers/probability.cc index c279654861..9462fc5572 100644 --- a/sdk/src/trace/samplers/probability.cc +++ b/sdk/src/trace/samplers/probability.cc @@ -98,19 +98,19 @@ SamplingResult ProbabilitySampler::ShouldSample( } else { - return {Decision::IGNORE, nullptr}; + return {Decision::DROP, nullptr}; } } if (threshold_ == 0) - return {Decision::IGNORE, nullptr}; + return {Decision::DROP, nullptr}; if (CalculateThresholdFromBuffer(trace_id) <= threshold_) { return {Decision::RECORD_AND_SAMPLE, nullptr}; } - return {Decision::IGNORE, nullptr}; + return {Decision::DROP, nullptr}; } nostd::string_view ProbabilitySampler::GetDescription() const noexcept diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 9f2c8ab635..60b00f191c 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -52,7 +52,7 @@ nostd::shared_ptr Tracer::StartSpan( // TODO: replace nullptr with parent context in span context auto sampling_result = sampler_->ShouldSample(nullptr, trace_api::TraceId(), name, options.kind, attributes); - if (sampling_result.decision == Decision::IGNORE) + if (sampling_result.decision == Decision::DROP) { auto span = nostd::shared_ptr{ new (std::nothrow) trace_api::NoopSpan{this->shared_from_this()}}; diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 679427e6b8..28a6c5fb3c 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -19,7 +19,7 @@ TEST(AlwaysOffSampler, ShouldSample) auto sampling_result = sampler.ShouldSample(nullptr, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(Decision::DROP, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); } diff --git a/sdk/test/trace/parent_or_else_sampler_test.cc b/sdk/test/trace/parent_or_else_sampler_test.cc index ab1c2193b9..cf7a208aa8 100644 --- a/sdk/test/trace/parent_or_else_sampler_test.cc +++ b/sdk/test/trace/parent_or_else_sampler_test.cc @@ -29,7 +29,7 @@ TEST(ParentOrElseSampler, ShouldSample) auto sampling_result = sampler_off.ShouldSample(nullptr, trace_id, "", span_kind, view); auto sampling_result2 = sampler_on.ShouldSample(nullptr, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(Decision::DROP, sampling_result.decision); ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result2.decision); // Case 2: Parent exists and SampledFlag is true @@ -40,7 +40,7 @@ TEST(ParentOrElseSampler, ShouldSample) // Case 3: Parent exists and SampledFlag is false auto sampling_result4 = sampler_on.ShouldSample(&parent_context_nonsampled, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result4.decision); + ASSERT_EQ(Decision::DROP, sampling_result4.decision); } TEST(ParentOrElseSampler, GetDescription) diff --git a/sdk/test/trace/probability_sampler_test.cc b/sdk/test/trace/probability_sampler_test.cc index 02105e5b44..6e617db3b1 100644 --- a/sdk/test/trace/probability_sampler_test.cc +++ b/sdk/test/trace/probability_sampler_test.cc @@ -75,7 +75,7 @@ TEST(ProbabilitySampler, ShouldSampleWithoutContext) sampling_result = s1.ShouldSample(nullptr, valid_trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(Decision::DROP, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); ProbabilitySampler s2(0.50000001); @@ -89,7 +89,7 @@ TEST(ProbabilitySampler, ShouldSampleWithoutContext) sampling_result = s3.ShouldSample(nullptr, valid_trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(Decision::DROP, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); ProbabilitySampler s4(0.50000000); @@ -117,7 +117,7 @@ TEST(ProbabilitySampler, ShouldSampleWithContext) auto sampling_result = s1.ShouldSample(&c1, trace_id, "", span_kind, view); - ASSERT_EQ(Decision::IGNORE, sampling_result.decision); + ASSERT_EQ(Decision::DROP, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); sampling_result = s1.ShouldSample(&c2, trace_id, "", span_kind, view); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 5f91eaf471..498d22e6fc 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -156,7 +156,7 @@ TEST(Tracer, StartSpanSampleOff) tracer_off->StartSpan("span 2")->End(); // The span doesn't write any span data because the sampling decision is alway - // IGNORE. + // DROP. ASSERT_EQ(0, spans_received->size()); }