Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apmbench] Add trace only benchmarks #15434

Merged
merged 7 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ jobs:
echo "BENCHMARK_RUN=${{ inputs.benchmarkRun }}" >> "$GITHUB_ENV"
fi

# exclude BenchmarkTraces* from scheduled benchmarks
- if: github.event_name == 'schedule'
run: |
echo "BENCHMARK_RUN=Benchmark[^T]" >> "$GITHUB_ENV"

- name: Log in to the Elastic Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
Expand Down
47 changes: 47 additions & 0 deletions systemtest/benchtest/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ package benchtest
import (
"context"
"crypto/tls"
"io/fs"
"net/url"
"path/filepath"
"testing"

"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
Expand Down Expand Up @@ -98,6 +100,8 @@ func NewOTLPExporter(tb testing.TB) *otlptrace.Exporter {

// NewEventHandler creates a eventhandler which loads the files matching the
// passed regex.
//
// It has to use loadgen.NewEventHandler as it has access to the private `events` FS Storage.
func NewEventHandler(tb testing.TB, p string, l *rate.Limiter) *eventhandler.Handler {
serverCfg := loadgencfg.Config
h, err := loadgen.NewEventHandler(loadgen.EventHandlerParams{
Expand All @@ -114,3 +118,46 @@ func NewEventHandler(tb testing.TB, p string, l *rate.Limiter) *eventhandler.Han
}
return h
}

// NewFSEventHandler creates an eventhandler which loads the files matching the
// passed regex in fs.
func NewFSEventHandler(tb testing.TB, p string, l *rate.Limiter, fs fs.FS) *eventhandler.Handler {
serverCfg := loadgencfg.Config
h, err := newFSEventHandler(loadgen.EventHandlerParams{
Path: p,
URL: serverCfg.ServerURL.String(),
Token: serverCfg.SecretToken,
Limiter: l,
RewriteIDs: serverCfg.RewriteIDs,
RewriteTimestamps: serverCfg.RewriteTimestamps,
Headers: serverCfg.Headers,
}, fs)
if err != nil {
tb.Fatal(err)
}
return h
}

func newFSEventHandler(p loadgen.EventHandlerParams, fs fs.FS) (*eventhandler.Handler, error) {
t, err := transport.NewHTTPTransport(transport.HTTPTransportOptions{})
if err != nil {
return nil, err
}
transp := eventhandler.NewTransport(t.Client, p.URL, p.Token, p.APIKey, p.Headers)
cfg := eventhandler.Config{
Path: filepath.Join("events", p.Path),
Transport: transp,
Storage: fs,
Limiter: p.Limiter,
Rand: p.Rand,
RewriteIDs: p.RewriteIDs,
RewriteServiceNames: p.RewriteServiceNames,
RewriteServiceNodeNames: p.RewriteServiceNodeNames,
RewriteServiceTargetNames: p.RewriteServiceTargetNames,
RewriteSpanNames: p.RewriteSpanNames,
RewriteTransactionNames: p.RewriteTransactionNames,
RewriteTransactionTypes: p.RewriteTransactionTypes,
RewriteTimestamps: p.RewriteTimestamps,
}
return eventhandler.New(cfg)
}
1 change: 1 addition & 0 deletions systemtest/cmd/apmbench/events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These event files are the trace only versions of their counterparts in apm-perf, obtained by e.g. `grep -E '^{"span|^{"transaction|^{"meta' apm-python-6.7.2.ndjson > apm-python-traces-6.7.2.ndjson`. These sampled traces files are useful to benchmark tail-based sampling.
4,890 changes: 4,890 additions & 0 deletions systemtest/cmd/apmbench/events/apm-go-traces-2.0.0.ndjson

Large diffs are not rendered by default.

1,845 changes: 1,845 additions & 0 deletions systemtest/cmd/apmbench/events/apm-nodejs-traces-3.29.0.ndjson

Large diffs are not rendered by default.

4,832 changes: 4,832 additions & 0 deletions systemtest/cmd/apmbench/events/apm-python-traces-6.7.2.ndjson

Large diffs are not rendered by default.

3,345 changes: 3,345 additions & 0 deletions systemtest/cmd/apmbench/events/apm-ruby-traces-4.5.0.ndjson

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions systemtest/cmd/apmbench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main

import (
"context"
"embed"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -107,6 +108,41 @@ func benchmarkAgent(b *testing.B, l *rate.Limiter, expr string) {
})
}

// events contains custom events that are not in apm-perf.
//
//go:embed events/*.ndjson
var events embed.FS

func BenchmarkTracesAgentAll(b *testing.B, l *rate.Limiter) {
benchmarkTracesAgent(b, l, `apm-*.ndjson`)
}

func BenchmarkTracesAgentGo(b *testing.B, l *rate.Limiter) {
benchmarkTracesAgent(b, l, `apm-go*.ndjson`)
}

func BenchmarkTracesAgentNodeJS(b *testing.B, l *rate.Limiter) {
benchmarkTracesAgent(b, l, `apm-nodejs*.ndjson`)
}

func BenchmarkTracesAgentPython(b *testing.B, l *rate.Limiter) {
benchmarkTracesAgent(b, l, `apm-python*.ndjson`)
}

func BenchmarkTracesAgentRuby(b *testing.B, l *rate.Limiter) {
benchmarkTracesAgent(b, l, `apm-ruby*.ndjson`)
}

// benchmarkTracesAgent benchmarks with traces only. Useful to benchmark TBS.
func benchmarkTracesAgent(b *testing.B, l *rate.Limiter, expr string) {
h := benchtest.NewFSEventHandler(b, expr, l, events)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
h.SendBatches(context.Background())
}
})
}

func Benchmark10000AggregationGroups(b *testing.B, l *rate.Limiter) {
// Benchmark memory usage on aggregating high cardinality data.
// This should generate a lot of groups for service transaction metrics,
Expand Down Expand Up @@ -154,6 +190,11 @@ func main() {
BenchmarkAgentPython,
BenchmarkAgentRuby,
Benchmark10000AggregationGroups,
BenchmarkTracesAgentAll,
BenchmarkTracesAgentGo,
BenchmarkTracesAgentNodeJS,
BenchmarkTracesAgentPython,
BenchmarkTracesAgentRuby,
); err != nil {
log.Fatal(err)
}
Expand Down
Loading