Skip to content

Commit

Permalink
Simplify trace_context tests (open-telemetry#2108)
Browse files Browse the repository at this point in the history
* Simplify trace_context tests

Refactor the propagation/trace_context tests to be targeted at testing
the propagator functionality only and remove extraneous dependencies.

Fix the TraceContext Inject method from injecting the tracestate header
if no value exists.

* Add changes to changelog
  • Loading branch information
MrAlias authored Jul 21, 2021
1 parent 56d4201 commit 4935949
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 189 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- OS type detector now sets the correct `dragonflybsd` value for DragonFly BSD. (#2092)
- The OTel span status is correctly transformed into the OTLP status in the `go.opentelemetry.io/otel/exporters/otlp/otlptrace` package.
This fix will by default set the status to `Unset` if it is not explicitly set to `Ok` or `Error`. (#2099 #2102)
- The `Inject` method for the `"go.opentelemetry.io/otel/propagation".TraceContext` type no longer injects empty `tracestate` values. (#2108)

### Security

Expand Down
4 changes: 3 additions & 1 deletion propagation/trace_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func (tc TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) {
return
}

carrier.Set(tracestateHeader, sc.TraceState().String())
if ts := sc.TraceState().String(); ts != "" {
carrier.Set(tracestateHeader, ts)
}

// Clear all flags other than the trace-context supported sampling bit.
flags := sc.TraceFlags() & trace.FlagsSampled
Expand Down
Loading

0 comments on commit 4935949

Please sign in to comment.