Skip to content

Commit

Permalink
Add telemetry OTLP bench to apmbench
Browse files Browse the repository at this point in the history
Use a otel collector contrib fork for a patch
  • Loading branch information
carsonip committed Feb 15, 2024
1 parent e5857ce commit f9702fd
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 66 deletions.
102 changes: 102 additions & 0 deletions cmd/apmbench/bench_otlp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package main

import (
"runtime"
"testing"
"time"

"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/common"
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/logs"
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/metrics"
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/traces"
"golang.org/x/time/rate"

loadgencfg "github.com/elastic/apm-perf/internal/loadgen/config"
)

func commonConfigWithHTTPPath(httpPath string) common.Config {
insecure := !loadgencfg.Config.Secure

serverURL := loadgencfg.Config.ServerURL
endpoint := serverURL.Host
if serverURL.Port() == "" {
switch serverURL.Scheme {
case "http":
endpoint += ":80"
insecure = true
case "https":
endpoint += ":443"
}
}

secretToken := loadgencfg.Config.SecretToken
apiKey := loadgencfg.Config.APIKey
headers := make(map[string]string)
for k, v := range loadgencfg.Config.Headers {
headers[k] = v
}
if secretToken != "" || apiKey != "" {
if apiKey != "" {
// higher priority to APIKey auth
headers["Authorization"] = "ApiKey " + apiKey
} else {
headers["Authorization"] = "Bearer " + secretToken
}
}

return common.Config{
WorkerCount: runtime.GOMAXPROCS(0),
Rate: 0,
TotalDuration: 0,
ReportingInterval: 0,
SkipSettingGRPCLogger: true,
CustomEndpoint: endpoint,
Insecure: insecure,
UseHTTP: false,
HTTPPath: httpPath,
Headers: headers,
ResourceAttributes: nil,
TelemetryAttributes: nil,
CaFile: "",
ClientAuth: common.ClientAuth{},
}
}

func BenchmarkTelemetrygenOTLPLogs(b *testing.B, l *rate.Limiter) {
config := logs.Config{
Config: commonConfigWithHTTPPath("/v1/logs"),
NumLogs: b.N,
Body: "test",
}
if err := logs.Start(&config); err != nil {
b.Fatal(err)
}
}

func BenchmarkTelemetrygenOTLPTraces(b *testing.B, l *rate.Limiter) {
config := traces.Config{
Config: commonConfigWithHTTPPath("/v1/traces"),
NumTraces: b.N,
NumChildSpans: 1,
PropagateContext: false,
ServiceName: "foo",
StatusCode: "0",
Batch: true,
LoadSize: 0,
SpanDuration: 123 * time.Microsecond,
}
if err := traces.Start(&config); err != nil {
b.Fatal(err)
}
}

func BenchmarkTelemetrygenOTLPMetrics(b *testing.B, l *rate.Limiter) {
config := metrics.Config{
Config: commonConfigWithHTTPPath("/v1/metrics"),
NumMetrics: b.N,
MetricType: "Sum",
}
if err := metrics.Start(&config); err != nil {
b.Fatal(err)
}
}
3 changes: 3 additions & 0 deletions cmd/apmbench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func main() {
BenchmarkAgentPython,
BenchmarkAgentRuby,
Benchmark10000AggregationGroups,
BenchmarkTelemetrygenOTLPTraces,
BenchmarkTelemetrygenOTLPLogs,
BenchmarkTelemetrygenOTLPMetrics,
); err != nil {
logger.Fatal("failed to run benchmarks", zap.Error(err))
}
Expand Down
58 changes: 36 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
module github.com/elastic/apm-perf

go 1.20
go 1.21

toolchain go1.21.6

require (
github.com/klauspost/compress v1.17.1
github.com/spf13/cobra v1.7.0
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen v0.0.0-00010101000000-000000000000
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5
go.elastic.co/apm/v2 v2.4.5
go.elastic.co/ecszap v1.0.2
go.elastic.co/fastjson v1.3.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0
go.opentelemetry.io/otel/sdk v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1
go.opentelemetry.io/otel/sdk v1.23.1
go.uber.org/zap v1.26.0
golang.org/x/sync v0.4.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.59.0
golang.org/x/sync v0.5.0
golang.org/x/time v0.5.0
google.golang.org/grpc v1.61.0
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -28,30 +31,41 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/elastic/go-sysinfo v1.11.1 // indirect
github.com/elastic/go-windows v1.0.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.opentelemetry.io/collector/pdata v1.1.0 // indirect
go.opentelemetry.io/collector/semconv v0.94.1 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.23.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.23.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/sdk/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/protobuf v1.32.0 // indirect
howett.net/plist v1.0.0 // indirect
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen => github.com/carsonip/opentelemetry-collector-contrib/cmd/telemetrygen v0.94.1-0.20240215144729-b3fab3f97ccb
Loading

0 comments on commit f9702fd

Please sign in to comment.