forked from open-telemetry/opentelemetry-cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Oliver Zhang
committed
Jun 22, 2020
1 parent
fab9d74
commit fff8bda
Showing
2 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "opentelemetry/sdk/trace/always_on_sampler.h" | ||
#include "opentelemetry/nostd/span.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
using namespace opentelemetry::sdk::trace; | ||
using namespace opentelemetry::nostd; | ||
|
||
TEST(AlwaysOnSampler, ShouldSample) | ||
{ | ||
AlwaysOnSampler sampler; | ||
|
||
// A buffer of trace_id with no specific meaning | ||
constexpr uint8_t buf[] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7}; | ||
|
||
trace_api::TraceId trace_id_invalid; | ||
trace_api::TraceId trace_id_valid(buf); | ||
|
||
auto sampling_result = sampler.ShouldSample(nullptr, trace_id_invalid, "invalid trace id test", | ||
trace_api::SpanKind::kServer, span<AttributeKeyValue>()); | ||
|
||
ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result.decision); | ||
ASSERT_EQ(0, sampling_result.attributes->size()); | ||
|
||
sampling_result = sampler.ShouldSample(nullptr, trace_id_valid, "valid trace id test", | ||
trace_api::SpanKind::kServer, span<AttributeKeyValue>()); | ||
|
||
ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result.decision); | ||
ASSERT_EQ(0, sampling_result.attributes->size()); | ||
} | ||
|
||
TEST(AlwaysOnSampler, GetDescription) | ||
{ | ||
AlwaysOnSampler sampler; | ||
|
||
ASSERT_EQ("AlwaysOnSampler", sampler.GetDescription()); | ||
} |