Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/datadog/trace_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,17 @@ void TraceSegment::span_finished() {
}
}

// RFC seems to only mandate that this be set if the trace is kept.
// However, system-tests expect this to always be set.
// Add it all the time; can't hurt
if (!tracing_enabled_) {
local_root.numeric_tags[tags::internal::apm_enabled] = 0;
}

// Some tags are repeated on all spans.
for (const auto& span_ptr : spans_) {
SpanData& span = *span_ptr;
if (!tracing_enabled_) {
// RFC seems to only mandate that this be set if the trace is kept.
// However, system-tests expect this to always be set.
// Add it all the time; can't hurt
// Following incident-57980, go beyond the RFC and add it to every span so
// that every trace chunk is marked.
span.numeric_tags[tags::internal::apm_enabled] = 0;
}
if (origin_) {
span.tags[tags::internal::origin] = *origin_;
}
Expand Down
24 changes: 24 additions & 0 deletions test/test_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,30 @@ TEST_TRACER("APM tracing disabled") {
TimePoint current_time = default_clock();
auto clock = [&current_time]() { return current_time; };

SECTION("_dd.apm.enabled is added to every span") {
auto finalized_config = finalize_config(config, clock);
REQUIRE(finalized_config);
Tracer tracer{*finalized_config};

SpanConfig service_entry_config;
service_entry_config.service = "child-service";

{
auto root = tracer.create_span();
auto child = root.create_child();
auto service_entry = root.create_child(service_entry_config);
(void)child;
(void)service_entry;
}

REQUIRE(collector->chunks.size() == 1);
const auto& chunk = collector->chunks.front();
REQUIRE(chunk.size() == 3);
for (const auto& span : chunk) {
CHECK(span->numeric_tags.at(tags::internal::apm_enabled) == 0);
}
}

SECTION("sampling behaviour") {
SECTION("span with _dd.p.ts is kept") {
auto finalized_config = finalize_config(config, clock);
Expand Down
Loading