1
0
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:
Tyler Yahn
2024-07-10 12:02:01 -07:00
committed by GitHub
parent 1077d23fd1
commit e8c22e6e71

View File

@@ -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)