Skip to content

Commit

Permalink
Merge branch 'main' into mv-trace-code
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Jul 16, 2024
2 parents db9ae89 + ae6d29f commit d2a4fe2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ To read more about tracing, see go.opentelemetry.io/otel/trace.
To read more about metrics, see go.opentelemetry.io/otel/metric.
To read more about logs, see go.opentelemetry.io/otel/log.
To read more about propagation, see go.opentelemetry.io/otel/propagation and
go.opentelemetry.io/otel/baggage.
*/
Expand Down
43 changes: 26 additions & 17 deletions sdk/trace/batch_span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,23 +627,32 @@ func TestBatchSpanProcessorConcurrentSafe(t *testing.T) {
wg.Wait()
}

func BenchmarkSpanProcessor(b *testing.B) {
tp := sdktrace.NewTracerProvider(
sdktrace.WithBatcher(
tracetest.NewNoopExporter(),
sdktrace.WithMaxExportBatchSize(10),
))
tracer := tp.Tracer("bench")
ctx := context.Background()

b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
for j := 0; j < 10; j++ {
_, span := tracer.Start(ctx, "bench")
span.End()
}
func BenchmarkSpanProcessorOnEnd(b *testing.B) {
for _, bb := range []struct {
batchSize int
spansCount int
}{
{batchSize: 10, spansCount: 10},
{batchSize: 10, spansCount: 100},
{batchSize: 100, spansCount: 10},
{batchSize: 100, spansCount: 100},
} {
b.Run(fmt.Sprintf("batch: %d, spans: %d", bb.batchSize, bb.spansCount), func(b *testing.B) {
bsp := sdktrace.NewBatchSpanProcessor(
tracetest.NewNoopExporter(),
sdktrace.WithMaxExportBatchSize(bb.batchSize),
)
snap := tracetest.SpanStub{}.Snapshot()

b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
// Ensure the export happens for every run
for j := 0; j < bb.spansCount; j++ {
bsp.OnEnd(snap)
}
}
})
}
}

Expand Down

0 comments on commit d2a4fe2

Please sign in to comment.