Skip to content

apmbench: support api key #16830

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions systemtest/benchtest/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func NewEventHandler(tb testing.TB, p string, l *rate.Limiter) *eventhandler.Han
Path: p,
URL: serverCfg.ServerURL.String(),
Token: serverCfg.SecretToken,
APIKey: serverCfg.APIKey,
Limiter: l,
RewriteIDs: serverCfg.RewriteIDs,
RewriteTimestamps: serverCfg.RewriteTimestamps,
Expand All @@ -132,6 +133,7 @@ func NewFSEventHandler(tb testing.TB, p string, l *rate.Limiter, fs fs.FS) *even
Path: p,
URL: serverCfg.ServerURL.String(),
Token: serverCfg.SecretToken,
APIKey: serverCfg.APIKey,
Limiter: l,
RewriteIDs: serverCfg.RewriteIDs,
RewriteTimestamps: serverCfg.RewriteTimestamps,
Expand Down
6 changes: 4 additions & 2 deletions systemtest/benchtest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ func Run(allBenchmarks ...BenchmarkFunc) error {
agents := agentsList[0]
serverURL := loadgencfg.Config.ServerURL.String()
secretToken := loadgencfg.Config.SecretToken
if err := warmup(agents, benchConfig.WarmupTime, serverURL, secretToken); err != nil {
apiKey := loadgencfg.Config.APIKey
if err := warmup(agents, benchConfig.WarmupTime, serverURL, secretToken, apiKey); err != nil {
return fmt.Errorf("warm-up failed with %d agents: %v", agents, err)
}
}
Expand Down Expand Up @@ -255,14 +256,15 @@ func Run(allBenchmarks ...BenchmarkFunc) error {

// warmup sends events to the remote APM Server using the specified number of
// agents for the specified duration.
func warmup(agents int, duration time.Duration, url, token string) error {
func warmup(agents int, duration time.Duration, url, token, apiKey string) error {
rl := loadgen.GetNewLimiter(loadgencfg.Config.EventRate.Burst, loadgencfg.Config.EventRate.Interval)
h, err := loadgen.NewEventHandler(loadgen.EventHandlerParams{
Logger: zap.NewNop(),
Protocol: "apm/http",
Path: `apm-*.ndjson`,
URL: url,
Token: token,
APIKey: apiKey,
Limiter: rl,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion systemtest/benchtest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func Test_warmup(t *testing.T) {
}))

t.Cleanup(srv.Close)
err := warmup(c.agents, c.duration, srv.URL, "")
err := warmup(c.agents, c.duration, srv.URL, "", "")
assert.NoError(t, err)
assert.Greater(t, received.Load(), uint64(c.agents))
})
Expand Down