Skip to content

Commit

Permalink
Add TestSpanStartConfigAttributeMutability (#5591)
Browse files Browse the repository at this point in the history
Follow up to #5567. Test the immutability of configured attributes.

Co-authored-by: Sam Xie <[email protected]>
  • Loading branch information
MrAlias and XSAM authored Jul 10, 2024
1 parent 1077d23 commit e8c22e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions trace/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e8c22e6

Please sign in to comment.