You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
Add TestSpanStartConfigAttributeMutability (#5591)
Follow up to #5567. Test the immutability of configured attributes. Co-authored-by: Sam Xie <sam@samxie.me>
This commit is contained in:
@@ -163,6 +163,19 @@ func TestNewSpanConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpanStartConfigAttributeMutability(t *testing.T) {
|
||||
a := attribute.String("a", "val")
|
||||
b := attribute.String("b", "val")
|
||||
attrs := []attribute.KeyValue{a, b}
|
||||
conf := NewSpanStartConfig(WithAttributes(attrs...))
|
||||
|
||||
// Mutating passed arg should not change configured attributes.
|
||||
attrs[0] = attribute.String("c", "val")
|
||||
|
||||
want := SpanConfig{attributes: []attribute.KeyValue{a, b}}
|
||||
assert.Equal(t, want, conf)
|
||||
}
|
||||
|
||||
func TestEndSpanConfig(t *testing.T) {
|
||||
timestamp := time.Unix(0, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user