You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-06-27 00:21:15 +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:
committed by
GitHub
parent
d75e268053
commit
e88a091a72
@ -43,11 +43,11 @@ func (t *testSpanProcessor) OnStart(parent context.Context, s sdktrace.ReadWrite
|
||||
// a more meaningful way.
|
||||
{
|
||||
Key: "ParentTraceID",
|
||||
Value: attribute.StringValue(psc.TraceID.String()),
|
||||
Value: attribute.StringValue(psc.TraceID().String()),
|
||||
},
|
||||
{
|
||||
Key: "ParentSpanID",
|
||||
Value: attribute.StringValue(psc.SpanID.String()),
|
||||
Value: attribute.StringValue(psc.SpanID().String()),
|
||||
},
|
||||
}
|
||||
s.AddEvent("OnStart", trace.WithAttributes(kv...))
|
||||
@ -79,10 +79,10 @@ func TestRegisterSpanProcessor(t *testing.T) {
|
||||
|
||||
tid, _ := trace.TraceIDFromHex("01020304050607080102040810203040")
|
||||
sid, _ := trace.SpanIDFromHex("0102040810203040")
|
||||
parent := trace.SpanContext{
|
||||
parent := trace.NewSpanContext(trace.SpanContextConfig{
|
||||
TraceID: tid,
|
||||
SpanID: sid,
|
||||
}
|
||||
})
|
||||
ctx := trace.ContextWithRemoteSpanContext(context.Background(), parent)
|
||||
|
||||
tr := tp.Tracer("SpanProcessor")
|
||||
@ -114,14 +114,14 @@ func TestRegisterSpanProcessor(t *testing.T) {
|
||||
c++
|
||||
case "ParentTraceID":
|
||||
gotValue := kv.Value.AsString()
|
||||
if gotValue != parent.TraceID.String() {
|
||||
t.Errorf("%s: attributes: got %s, want %s\n", name, gotValue, parent.TraceID)
|
||||
if gotValue != parent.TraceID().String() {
|
||||
t.Errorf("%s: attributes: got %s, want %s\n", name, gotValue, parent.TraceID())
|
||||
}
|
||||
tidOK = true
|
||||
case "ParentSpanID":
|
||||
gotValue := kv.Value.AsString()
|
||||
if gotValue != parent.SpanID.String() {
|
||||
t.Errorf("%s: attributes: got %s, want %s\n", name, gotValue, parent.SpanID)
|
||||
if gotValue != parent.SpanID().String() {
|
||||
t.Errorf("%s: attributes: got %s, want %s\n", name, gotValue, parent.SpanID())
|
||||
}
|
||||
sidOK = true
|
||||
default:
|
||||
|
Reference in New Issue
Block a user