open-telemetry / open-telemetry/opentelemetry-python

Include trace flags in spans exported by the OTLPSpanExporter

Open
#4,666 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Is your feature request related to a problem?

The opentelemetry protocol specifies that a Span can have a flags bit field, where bits 0-7 are the "trace flags" as defined in W3C Trace Context specification. Bits 8 and 9 are used to identify if a span's parent is remote.
In the OpenTelemetry python exporter package, the OTLPSpanExporter only includes bits 8 and 9, it is not including bits 0-7 with the trace flags (see the _span_flags function).

Describe the solution you'd like

Update the OTLPSpanExporter to include the trace flags in each span's flags field.

Describe alternatives you've considered

Creating a custom OTLPSpanExporterWithTraceFlags exporter that inherits from OTLPSpanExporter was considered, but that would involve duplicating the internal trace_encoder module.

Additional Context

There appears to be little consistency in how the OTLP span flags field is populated in the different language implementations. Go does it like python and only includes bits 8-9 (remote parent bits). Rust only includes the trace flag bits. While java and php include both the remote parent bits and the trace flag bits.
This issue is requesting that the python OTLPExporter implementation be update to behave like the java and php implementations and include the trace flags and remote parent bits in span flags.

Would you like to implement a fix?

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OTLPSpanExporter in exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/init.py, then inspect _span_flags in exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/trace_encoder/init.py. Check the relevant exporter tests and confirm that exported spans include both trace flag bits and remote-parent bits in flags.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.