-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telemetry OTLP bench to apmbench
Use a otel collector contrib fork for a patch
- Loading branch information
Showing
4 changed files
with
295 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.