---
title: (Legacy) Propagating Ruby Trace Context
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > APM > Application Instrumentation > Trace Context Propagation >
  (Legacy) Propagating Ruby Trace Context
---

# (Legacy) Propagating Ruby Trace Context

{% alert level="danger" %}
This documentation is for `ddtrace` gem v1.x. If you are using the `datadog` gem v2.0 or later, see the latest [Propagating Ruby Trace Context](https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation.md) documentation.
{% /alert %}

### Headers extraction and injection{% #headers-extraction-and-injection %}

Datadog APM tracer supports [B3](https://github.com/openzipkin/b3-propagation) and [W3C Trace Context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format) 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`.

If multiple extraction styles are enabled extraction attempt is done on the order those styles are configured and first successful extracted value is used.

The default extraction styles are, in order, `datadog`, `b3multi`, `b3`, and `tracecontext`.

You can also enable or disable the use of these formats in code by using `Datadog.configure`:

```ruby
Datadog.configure do |c|
  # List of header formats that should be extracted
  c.tracing.distributed_tracing.propagation_extract_style = [ 'tracecontext', 'datadog', 'b3' ]

  # List of header formats that should be injected
  c.tracing.distributed_tracing.propagation_inject_style = [ 'tracecontext', 'datadog' ]
end
```

For more information about trace context propagation configuration, read [the Distributed Tracing section](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/ruby.md#distributed-tracing) in the Ruby Tracing Library Configuration docs.

## Further Reading{% #further-reading %}

- [Monitor OpenTelemetry-instrumented apps with support for W3C Trace Context](https://www.datadoghq.com/blog/monitor-otel-with-w3c-trace-context/)
- [Interoperability of OpenTelemetry API and Datadog instrumented traces](https://docs.datadoghq.com/opentelemetry/guide/otel_api_tracing_interoperability.md)
