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
1 change: 1 addition & 0 deletions src/datadog/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/datadog/tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/datadog/trace_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
16 changes: 16 additions & 0 deletions test/test_trace_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading