You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
Added Benchmarks around events (#2405)
* Added Benchmarks around events Also fixed the attribute benchmarks to reflect the # of attributes in the test * Fix test txt, and too new a version of time Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package trace_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
@@ -44,6 +45,7 @@ func BenchmarkSpanWithAttributes_4(b *testing.B) {
|
|||||||
span.SetAttributes(
|
span.SetAttributes(
|
||||||
attribute.Bool("key1", false),
|
attribute.Bool("key1", false),
|
||||||
attribute.String("key2", "hello"),
|
attribute.String("key2", "hello"),
|
||||||
|
attribute.Int64("key3", 123),
|
||||||
attribute.Float64("key4", 123.456),
|
attribute.Float64("key4", 123.456),
|
||||||
)
|
)
|
||||||
span.End()
|
span.End()
|
||||||
@@ -61,9 +63,11 @@ func BenchmarkSpanWithAttributes_8(b *testing.B) {
|
|||||||
span.SetAttributes(
|
span.SetAttributes(
|
||||||
attribute.Bool("key1", false),
|
attribute.Bool("key1", false),
|
||||||
attribute.String("key2", "hello"),
|
attribute.String("key2", "hello"),
|
||||||
|
attribute.Int64("key3", 123),
|
||||||
attribute.Float64("key4", 123.456),
|
attribute.Float64("key4", 123.456),
|
||||||
attribute.Bool("key21", false),
|
attribute.Bool("key21", false),
|
||||||
attribute.String("key22", "hello"),
|
attribute.String("key22", "hello"),
|
||||||
|
attribute.Int64("key23", 123),
|
||||||
attribute.Float64("key24", 123.456),
|
attribute.Float64("key24", 123.456),
|
||||||
)
|
)
|
||||||
span.End()
|
span.End()
|
||||||
@@ -114,6 +118,67 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkSpanWithEvents_4(b *testing.B) {
|
||||||
|
traceBenchmark(b, "Benchmark Start With 4 Events", func(b *testing.B, t trace.Tracer) {
|
||||||
|
ctx := context.Background()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, span := t.Start(ctx, "/foo")
|
||||||
|
span.AddEvent("event1")
|
||||||
|
span.AddEvent("event2")
|
||||||
|
span.AddEvent("event3")
|
||||||
|
span.AddEvent("event4")
|
||||||
|
span.End()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkSpanWithEvents_8(b *testing.B) {
|
||||||
|
traceBenchmark(b, "Benchmark Start With 4 Events", func(b *testing.B, t trace.Tracer) {
|
||||||
|
ctx := context.Background()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, span := t.Start(ctx, "/foo")
|
||||||
|
span.AddEvent("event1")
|
||||||
|
span.AddEvent("event2")
|
||||||
|
span.AddEvent("event3")
|
||||||
|
span.AddEvent("event4")
|
||||||
|
span.AddEvent("event5")
|
||||||
|
span.AddEvent("event6")
|
||||||
|
span.AddEvent("event7")
|
||||||
|
span.AddEvent("event8")
|
||||||
|
span.End()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkSpanWithEvents_WithStackTrace(b *testing.B) {
|
||||||
|
traceBenchmark(b, "Benchmark Start With 4 Attributes", func(b *testing.B, t trace.Tracer) {
|
||||||
|
ctx := context.Background()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, span := t.Start(ctx, "/foo")
|
||||||
|
span.AddEvent("event1", trace.WithStackTrace(true))
|
||||||
|
span.End()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func BenchmarkSpanWithEvents_WithTimestamp(b *testing.B) {
|
||||||
|
traceBenchmark(b, "Benchmark Start With 4 Attributes", func(b *testing.B, t trace.Tracer) {
|
||||||
|
ctx := context.Background()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, span := t.Start(ctx, "/foo")
|
||||||
|
span.AddEvent("event1", trace.WithTimestamp(time.Unix(0, 0)))
|
||||||
|
span.End()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkTraceID_DotString(b *testing.B) {
|
func BenchmarkTraceID_DotString(b *testing.B) {
|
||||||
t, _ := trace.TraceIDFromHex("0000000000000001000000000000002a")
|
t, _ := trace.TraceIDFromHex("0000000000000001000000000000002a")
|
||||||
sc := trace.NewSpanContext(trace.SpanContextConfig{TraceID: t})
|
sc := trace.NewSpanContext(trace.SpanContextConfig{TraceID: t})
|
||||||
|
|||||||
Reference in New Issue
Block a user