Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w3c(phase 3): ensure last datadog parent id is always recorded #3631

Merged
merged 12 commits into from
Jun 7, 2024
Prev Previous commit
Next Next commit
define constant and lint
  • Loading branch information
mabdinur committed May 8, 2024
commit 4a807ac75418d8d483d8241fd1f39e7fd17f9f8b
4 changes: 3 additions & 1 deletion lib/datadog/tracing/distributed/propagation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ def extract(data)
if (tracecontext_digest = propagator.extract(data))
# Only parse if it represent the same trace as the successfully extracted one
next unless tracecontext_digest.trace_id == extracted_trace_digest.trace_id

# Preserve the last datadog parent id in `trace_distributed_tags`
if tracecontext_digest.span_id != extracted_trace_digest.span_id && tracecontext_digest.trace_distributed_tags&.keys(Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID)
extracted_trace_digest.trace_distributed_tags ||= {}
extracted_trace_digest.trace_distributed_tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID] = tracecontext_digest.trace_distributed_tags.fetch(Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID, Tracing::Metadata::Ext::Distributed::DD_PARENT_ID_DEFAULT)
extracted_trace_digest.trace_distributed_tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID] =
tracecontext_digest.trace_distributed_tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID]
end
# Preserve the `tracestate`
extracted_trace_digest = extracted_trace_digest.merge(
mabdinur marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/distributed/trace_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def extract(data)
end

tags ||= {}
tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID] = ts_parent_id || Tracing::Metadata::Ext::Distributed::DD_PARENT_ID_DEFAULT
tags[Tracing::Metadata::Ext::Distributed::TAG_DD_PARENT_ID] = ts_parent_id || '0000000000000000'

TraceDigest.new(
span_id: parent_id,
Expand Down
Loading