Skip to content

Commit

Permalink
datadog: do not add None tracestate value. (#368)
Browse files Browse the repository at this point in the history
The datadog exporter sometimes attempts to add a "None" value, if the
datadog origin header doesn't exist.

This does not cause runtime errors in the most recent opentelemetry
release (tracestate protects against an invalid value), but does cause warnings:

WARNING  opentelemetry.trace.span:span.py:230 Invalid key/value pair (dd_origin, None) found.
  • Loading branch information
toumorokoshi authored Mar 11, 2021
1 parent 0917dad commit 2d9df10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Rename `IdsGenerator` to `IdGenerator`
([#350](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/350))
- `opentelemetry-exporter-datadog` Fix warning when DatadogFormat encounters a request with
no DD_ORIGIN headers ([#368](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/368)).

## [0.18b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.18b0) - 2021-02-16

Expand All @@ -21,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#345](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/345))

### Removed
- Remove `component` span attribute in instrumentations.
- Remove `component` span attribute in instrumentations.
`opentelemetry-instrumentation-aiopg`, `opentelemetry-instrumentation-dbapi` Remove unused `database_type` parameter from `trace_integration` function.
([#301](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/301))
- `opentelemetry-instrumentation-asgi` Return header values using case insensitive keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@


class DatadogFormat(TextMapPropagator):
"""Propagator for the Datadog HTTP header format.
"""
"""Propagator for the Datadog HTTP header format."""

TRACE_ID_KEY = "x-datadog-trace-id"
PARENT_ID_KEY = "x-datadog-parent-id"
Expand Down Expand Up @@ -65,12 +64,15 @@ def extract(
if trace_id is None or span_id is None:
return set_span_in_context(trace.INVALID_SPAN, context)

trace_state = []
if origin is not None:
trace_state.append((constants.DD_ORIGIN, origin))
span_context = trace.SpanContext(
trace_id=int(trace_id),
span_id=int(span_id),
is_remote=True,
trace_flags=trace_flags,
trace_state=trace.TraceState([(constants.DD_ORIGIN, origin)]),
trace_state=trace.TraceState(trace_state),
)

return set_span_in_context(
Expand Down

0 comments on commit 2d9df10

Please sign in to comment.