Skip to content

Commit

Permalink
Updates based on additional comments from adriancole on PR envoyproxy…
Browse files Browse the repository at this point in the history
…#2787

Signed-off-by: Gary Brown <gary@brownuk.com>
  • Loading branch information
objectiser committed Mar 19, 2018
1 parent 2ea9b60 commit 7299c90
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/common/tracing/zipkin/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SpanContext {
/**
* Default constructor. Creates an empty context.
*/
SpanContext() : trace_id_(0), id_(0), parent_id_(0), is_initialized_(false), sampled_(true) {}
SpanContext() : trace_id_(0), id_(0), parent_id_(0), is_initialized_(false), sampled_(false) {}

/**
* Constructor that creates a context object from the supplied trace, span and
Expand Down
2 changes: 1 addition & 1 deletion source/common/tracing/zipkin/zipkin_core_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class Span : public ZipkinBase {
* Default constructor. Creates an empty span.
*/
Span()
: trace_id_(0), name_(), id_(0), debug_(false), sampled_(true), monotonic_start_time_(0),
: trace_id_(0), name_(), id_(0), debug_(false), sampled_(false), monotonic_start_time_(0),
tracer_(nullptr) {}

/**
Expand Down
1 change: 1 addition & 0 deletions test/common/tracing/zipkin/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ TEST(ZipkinTracerTest, finishSpan) {

// Creates a root-span with a CS annotation
SpanPtr span = tracer.startSpan(config, "my_span", timestamp);
span->setSampled(true);

// Finishing a root span with a CS annotation must add a CR annotation
span->finish();
Expand Down
26 changes: 24 additions & 2 deletions test/common/tracing/zipkin/zipkin_tracer_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ TEST_F(ZipkinDriverTest, PropagateB3NotSampledWithFalse) {

// Only context header set is B3 sampled to indicate trace should not be sampled (using legacy
// 'false' value)
const std::string notSampled = "false";
request_headers_.insertXB3Sampled().value(notSampled);
const std::string sampled = "false";
request_headers_.insertXB3Sampled().value(sampled);
Tracing::SpanPtr span =
driver_->startSpan(config_, request_headers_, operation_name_, start_time_);

Expand All @@ -285,6 +285,28 @@ TEST_F(ZipkinDriverTest, PropagateB3NotSampledWithFalse) {
request_headers_.XB3Sampled()->value().getString()) == 0);
}

TEST_F(ZipkinDriverTest, PropagateB3SampledWithTrue) {
setupValidDriver();

EXPECT_EQ(nullptr, request_headers_.XB3SpanId());
EXPECT_EQ(nullptr, request_headers_.XB3TraceId());

// Only context header set is B3 sampled to indicate trace should be sampled (using legacy
// 'true' value)
const std::string sampled = "true";
request_headers_.insertXB3Sampled().value(sampled);
Tracing::SpanPtr span =
driver_->startSpan(config_, request_headers_, operation_name_, start_time_);

request_headers_.removeXB3Sampled();

span->injectContext(request_headers_);

// Check B3 sampled flag is set to sample
EXPECT_TRUE(ZipkinCoreConstants::get().SAMPLED.compare(
request_headers_.XB3Sampled()->value().getString()) == 0);
}

TEST_F(ZipkinDriverTest, ZipkinSpanTest) {
setupValidDriver();

Expand Down

0 comments on commit 7299c90

Please sign in to comment.