Propagating Ruby Trace Context
This documentation is for
datadog
gem v2.x. If you are looking for
ddtrace
gem v1.x documentation, see the legacy
Propagating Ruby Trace Context
documentation.
Headers extraction and injection
Datadog APM tracer supports B3 and W3C Trace Context header extraction and injection for distributed tracing.
Distributed headers injection and extraction is controlled by configuring injection and extraction styles. The following styles are supported:
- Datadog:
datadog
- B3 Multi Header:
b3multi
- B3 Single Header:
b3
- W3C Trace Context:
tracecontext
- No-op:
none
Injection styles can be configured using:
- Environment Variable:
DD_TRACE_PROPAGATION_STYLE_INJECT=datadog,b3
The value of the environment variable is a comma-separated list of header styles that are enabled for injection. The default setting is datadog,tracecontext
.
Extraction styles can be configured using:
- Environment Variable:
DD_TRACE_PROPAGATION_STYLE_EXTRACT=datadog,b3
The value of the environment variable is a comma-separated list of header styles that are enabled for extraction. The default setting is datadog,tracecontext
.
The default extraction styles are, in order, datadog
and tracecontext
.
You can also enable or disable the use of these formats in code by using Datadog.configure
:
Datadog.configure do |c|
# List of header formats that should be extracted
c.tracing.propagation_extract_style = [ 'tracecontext', 'datadog', 'b3' ]
# List of header formats that should be injected
c.tracing.propagation_inject_style = [ 'tracecontext', 'datadog' ]
end
For more information about trace context propagation configuration, read the Distributed Tracing section in the Ruby Tracing Library Configuration docs.
Further Reading
Additional helpful documentation, links, and articles: