1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Make SpanContext Immutable (#1573)

* Make SpanContext Immutable

* Adds NewSpanContext() constructor and SpanContextConfig{} struct for
constructing a new SpanContext when all fields are known
* Adds With<field>() methods to SpanContext for deriving a SpanContext
with a single field changed.
* Updates all uses of SpanContext to use the new API

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Update CHANGELOG.md

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Add tests for new SpanContext constructor and derivation

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Address PR feedback

* Fix new uses of SpanContext from main
This commit is contained in:
Anthony Mirabella
2021-03-09 11:17:29 -05:00
committed by GitHub
parent d75e268053
commit e88a091a72
37 changed files with 554 additions and 343 deletions

View File

@@ -60,11 +60,11 @@ type outOfThinAirPropagator struct {
var _ propagation.TextMapPropagator = outOfThinAirPropagator{}
func (p outOfThinAirPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context {
sc := trace.SpanContext{
sc := trace.NewSpanContext(trace.SpanContextConfig{
TraceID: traceID,
SpanID: spanID,
TraceFlags: 0,
}
})
require.True(p.t, sc.IsValid())
return trace.ContextWithRemoteSpanContext(ctx, sc)
}