You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-12-01 23:12:29 +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
@@ -117,21 +117,21 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
|
||||
|
||||
func BenchmarkTraceID_DotString(b *testing.B) {
|
||||
t, _ := trace.TraceIDFromHex("0000000000000001000000000000002a")
|
||||
sc := trace.SpanContext{TraceID: t}
|
||||
sc := trace.NewSpanContext(trace.SpanContextConfig{TraceID: t})
|
||||
|
||||
want := "0000000000000001000000000000002a"
|
||||
for i := 0; i < b.N; i++ {
|
||||
if got := sc.TraceID.String(); got != want {
|
||||
if got := sc.TraceID().String(); got != want {
|
||||
b.Fatalf("got = %q want = %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSpanID_DotString(b *testing.B) {
|
||||
sc := trace.SpanContext{SpanID: trace.SpanID{1}}
|
||||
sc := trace.NewSpanContext(trace.SpanContextConfig{SpanID: trace.SpanID{1}})
|
||||
want := "0100000000000000"
|
||||
for i := 0; i < b.N; i++ {
|
||||
if got := sc.SpanID.String(); got != want {
|
||||
if got := sc.SpanID().String(); got != want {
|
||||
b.Fatalf("got = %q want = %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user