opentelemetry-propagator-ottrace gem contains injectors and extractors for the OTTrace context propagation format.
OT Trace Format
| Header Name | Description | Required | | ——————- | ————————————————————————————————————————————– | ——————— | |
ot-tracer-traceid | uint64 encoded as a string of 16 hex characters | yes | |
ot-tracer-spanid | uint64 encoded as a string of 16 hex characters | yes | |
ot-tracer-sampled | boolean or bit encoded as a string with the values
'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
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
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
The OT trace propagation format expects trace ids to be 64-bits. In order to interop with OpenTelemetry, trace ids need to be truncated to 64-bits before sending them on the wire. When truncating, the least significant (right-most) bits MUST be retained. For example, a trace id of
3c3039f4d78d5c02ee8e3e41b17ce105 would be truncated to
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
Configure your application to use this propagator by setting the following environment variable:
How can I get involved?
opentelemetry-propagator-ottrace gem source is on github, along with related gems including
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in GitHub Discussions 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.
opentelemetry-propagator-ottrace gem is distributed under the Apache 2.0 license. See LICENSE for more information.