opentelemetry-propagator-ottrace
The opentelemetry-propagator-ottrace
gem contains injectors and extractors for the
OTTrace context propagation format.
OT Trace Format
Header Name | Description | Required |
---|---|---|
ot-tracer-traceid |
64-bit; 16 hex digits (extract and inject) or 128-bit; 32 hex digits (extract) | yes |
ot-tracer-spanid |
64-bit; 16 hex digits | yes |
ot-tracer-sampled |
boolean or bit encoded as a string with the values 'true' ,'false' , '1' , or '0' |
no |
ot-baggage-* |
repeated string to string key-value baggage items; keys are prefixed with ot-baggage- and the corresponding value is the raw string. |
if baggage is present |
Sampled Flag vs Bit
The ot-tracer-sampled
header is a boolean
encoded string however the Golang SDK incorrectly sets the ot-tracer-sampled
header to a bit
flag.
This and other language SDKs compensate for this by supporting both a bit
and boolean
encoded strings upon extraction:
This issue was fixed however this SDK supports both for backward compatibility with older versions of the Golang propagator.
Interop and trace ids
OTTrace was changed to be interoperable with other format so it is supposed to 8 or 16 byte array values for the trace-id.
In order to do that Lightstep released a version of the OTTrace propagators in OpenTracing SDKs that left padded 64-bit headers to 128-bits using an additional 64-bit of 0s.
The reality of the world is not every application upgraded to support 16 byte array propagation format, but this propagator must still convert legacy 64-bit trace ids to match the W3C Trace Context Trace ID 16 byte array.
In addition to that it must be interoperable with legacy OTTracers, which expect 64-bit headers so this propagator truncates the value from a 128-bit to a 64-bit value before inject it into the carrier.
This propagator is compatible with 64-bit or 128-bit trace ids when extracting the parent context, however it truncates the trace ids down to 64-bit trace ids when injecting the context.
Baggage Notes
Baggage keys and values are validated according to rfc7230. Any keys or values that would result in invalid HTTP headers will be silently dropped during inject.
OT Baggage is represented as multiple headers where the
names are carrier dependent. For this reason, they are omitted from the fields
method. This behavior should be taken into account if your application relies
on the fields
functionality. See the specification for
more details.
What is OpenTelemetry?
OpenTelemetry is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries.
OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools.
How does this gem fit in?
This gem can be used with any OpenTelemetry SDK implementation. This can be the official opentelemetry-sdk
gem or any other concrete implementation.
How do I get started?
Install the gem using:
gem install opentelemetry-propagator-ottrace
Or, if you use bundler, include opentelemetry-propagator-ottrace
in your Gemfile
.
Configure your application to use this propagator by setting the following environment variable:
OTEL_PROPAGATORS=ottrace
How can I get involved?
The opentelemetry-propagator-ottrace
gem source is on github, along with related gems including opentelemetry-api
and opentelemetry-sdk
.
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our GitHub Discussions, Slack Channel or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page.
License
The opentelemetry-propagator-ottrace
gem is distributed under the Apache 2.0 license. See LICENSE for more information.