Skip to content

Commit

Permalink
Add benchmark for turning readonly spans into their proto struct (#5601)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Jul 12, 2024
1 parent 8f965b6 commit cdee720
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions exporters/otlp/otlptrace/internal/tracetransform/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,33 @@ func TestSpanDataNilResource(t *testing.T) {
}.Snapshots())
})
}

func BenchmarkSpans(b *testing.B) {
records := []tracesdk.ReadOnlySpan{
tracetest.SpanStub{
Attributes: []attribute.KeyValue{
attribute.String("a", "b"),
attribute.String("b", "b"),
attribute.String("c", "b"),
attribute.String("d", "b"),
},
Links: []tracesdk.Link{
{},
{},
{},
{},
{},
},
}.Snapshot(),
}

b.ResetTimer()
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
var out []*tracepb.ResourceSpans
for pb.Next() {
out = Spans(records)
}
_ = out
})
}

0 comments on commit cdee720

Please sign in to comment.