diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc')
-rw-r--r-- | src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc b/src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc new file mode 100644 index 000000000..1c32bd5a8 --- /dev/null +++ b/src/jaegertracing/opentelemetry-cpp/sdk/test/trace/always_off_sampler_test.cc @@ -0,0 +1,42 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include <gtest/gtest.h> +#include "opentelemetry/sdk/trace/samplers/always_off.h" +#include "opentelemetry/trace/span_context_kv_iterable_view.h" + +using opentelemetry::sdk::trace::AlwaysOffSampler; +using opentelemetry::sdk::trace::Decision; +using opentelemetry::trace::SpanContext; +namespace trace_api = opentelemetry::trace; + +TEST(AlwaysOffSampler, ShouldSample) +{ + AlwaysOffSampler sampler; + + trace_api::TraceId trace_id; + trace_api::SpanKind span_kind = trace_api::SpanKind::kInternal; + + using M = std::map<std::string, int>; + M m1 = {{}}; + + using L = std::vector<std::pair<SpanContext, std::map<std::string, std::string>>>; + L l1 = {{SpanContext(false, false), {}}, {SpanContext(false, false), {}}}; + + opentelemetry::common::KeyValueIterableView<M> view{m1}; + trace_api::SpanContextKeyValueIterableView<L> links{l1}; + + auto sampling_result = + sampler.ShouldSample(SpanContext::GetInvalid(), trace_id, "", span_kind, view, links); + + ASSERT_EQ(Decision::DROP, sampling_result.decision); + ASSERT_EQ(nullptr, sampling_result.attributes); + ASSERT_EQ("", sampling_result.trace_state->ToHeader()); +} + +TEST(AlwaysOffSampler, GetDescription) +{ + AlwaysOffSampler sampler; + + ASSERT_EQ("AlwaysOffSampler", sampler.GetDescription()); +} |