diff --git a/src/datadog/tags.cpp b/src/datadog/tags.cpp index 4b2bc997..ddeca213 100644 --- a/src/datadog/tags.cpp +++ b/src/datadog/tags.cpp @@ -36,6 +36,7 @@ const std::string w3c_parent_id = "_dd.parent_id"; const std::string trace_source = "_dd.p.ts"; const std::string apm_enabled = "_dd.apm.enabled"; const std::string ksr = "_dd.p.ksr"; +const std::string sdk_otlp_export = "_dd.sdk.otlp_export"; } // namespace internal diff --git a/src/datadog/tags.h b/src/datadog/tags.h index 8d9f4d60..0c282693 100644 --- a/src/datadog/tags.h +++ b/src/datadog/tags.h @@ -41,9 +41,10 @@ extern const std::string process_id; extern const std::string language; extern const std::string runtime_id; extern const std::string w3c_parent_id; -extern const std::string trace_source; // _dd.p.ts -extern const std::string apm_enabled; // _dd.apm.enabled -extern const std::string ksr; // _dd.p.ksr +extern const std::string trace_source; // _dd.p.ts +extern const std::string apm_enabled; // _dd.apm.enabled +extern const std::string ksr; // _dd.p.ksr +extern const std::string sdk_otlp_export; // _dd.sdk.otlp_export } // namespace internal diff --git a/src/datadog/trace_segment.cpp b/src/datadog/trace_segment.cpp index fc70445c..fa0f8965 100644 --- a/src/datadog/trace_segment.cpp +++ b/src/datadog/trace_segment.cpp @@ -371,6 +371,8 @@ void TraceSegment::span_finished() { if (hostname_) { local_root.tags[tags::internal::hostname] = *hostname_; } + // Mark the chunk as sent in Datadog format, not OTLP. One per chunk. + local_root.tags[tags::internal::sdk_otlp_export] = "false"; if (decision.origin == SamplingDecision::Origin::LOCAL) { if (decision.mechanism == int(SamplingMechanism::AGENT_RATE) || decision.mechanism == int(SamplingMechanism::DEFAULT)) { diff --git a/test/test_trace_segment.cpp b/test/test_trace_segment.cpp index 37f8f94a..f89370ab 100644 --- a/test/test_trace_segment.cpp +++ b/test/test_trace_segment.cpp @@ -289,6 +289,22 @@ TEST_CASE("TraceSegment finalization of spans") { get_hostname()); } + SECTION("OTLP export marker is on the first span of the chunk only") { + auto finalized = finalize_config(config); + REQUIRE(finalized); + Tracer tracer{*finalized}; + { + auto root = tracer.create_span(); + auto child = root.create_child(); + (void)child; + } + REQUIRE(collector->chunks.size() == 1); + const auto& chunk = collector->chunks.front(); + REQUIRE(chunk.size() == 2); + REQUIRE(chunk[0]->tags.at(tags::internal::sdk_otlp_export) == "false"); + REQUIRE(chunk[1]->tags.count(tags::internal::sdk_otlp_export) == 0); + } + SECTION("x-datadog-tags") { auto finalized = finalize_config(config); REQUIRE(finalized);