Skip to content

Commit

Permalink
release note
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Sep 7, 2022
1 parent c7591f3 commit ff2d76e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ddtrace/propagation/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ def _inject(span_context, headers):
return

sampling_priority = span_context.sampling_priority
sampling_priority_hex = "00000001" if sampling_priority and sampling_priority >= 1 else "00000000"
sampling_priority_hex = "01" if sampling_priority and sampling_priority >= AUTO_KEEP else "00"
# There is currently only a single version so we always start with 00
traceparent = "{}-{}-{}-{}".format(
"00",
"0000000000000000" + hex(span_context.trace_id)[2:],
"0000000000000000" + hex(span_context.trace_id)[2:], # we slice off the "0x" that hex() prepends
hex(span_context.span_id)[2:],
sampling_priority_hex,
)
Expand All @@ -566,7 +566,7 @@ def _extract(headers):
trace_id = int(trace_id_hex[-16], 16 & 0xFFFFFFFFFFFF)
span_id = int(span_id_hex, 16 & 0xFFFFFFFFFFFF)
# there's only one trace flag, which denotes sampling priority was set to keep
sampling_priority = AUTO_KEEP if trace_flags == "00000001" else 0
sampling_priority = AUTO_KEEP if trace_flags == "01" else AUTO_REJECT
else:
log.warning("unsupported traceparent version:%s", version)
return None
Expand Down Expand Up @@ -657,6 +657,10 @@ def my_controller(url, headers):
context = _B3SingleHeader._extract(normalized_headers)
if context is not None:
return context
if PROPAGATION_STYLE_W3C in config._propagation_style_extract:
context = _W3CTraceContext._extract(normalized_headers)
if context is not None:
return context
except Exception:
log.debug("error while extracting context propagation headers", exc_info=True)
return Context()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
features:
- |
Add support for injecting and extracting W3C traceparent propagation header.
See :ref:`DD_TRACE_PROPAGATION_STYLE_EXTRACT <dd-trace-propagation-style-extract>` and
:ref:`DD_TRACE_PROPAGATION_STYLE_INJECT <dd-trace-propagation-style-inject>`
configuration documentation to enable.

0 comments on commit ff2d76e

Please sign in to comment.