Skip to content

Commit

Permalink
feat add option to run indefinitely
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichalek132 committed Sep 27, 2024
1 parent 5b08980 commit 018dc83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/avalanche.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {
remotePprofURLs := kingpin.Flag("remote-pprof-urls", "a list of urls to download pprofs during the remote write: --remote-pprof-urls=http://127.0.0.1:10902/debug/pprof/heap --remote-pprof-urls=http://127.0.0.1:10902/debug/pprof/profile").URLList()
remotePprofInterval := kingpin.Flag("remote-pprof-interval", "how often to download pprof profiles. When not provided it will download a profile once before the end of the test.").Duration()
remoteBatchSize := kingpin.Flag("remote-batch-size", "how many samples to send with each remote_write API request.").Default("2000").Int()
remoteRequestCount := kingpin.Flag("remote-requests-count", "how many requests to send in total to the remote_write API.").Default("100").Int()
remoteRequestCount := kingpin.Flag("remote-requests-count", "How many requests to send in total to the remote_write API. Set to -1 to run indefinitely.").Default("100").Int()
remoteReqsInterval := kingpin.Flag("remote-write-interval", "delay between each remote write request.").Default("100ms").Duration()
remoteTenant := kingpin.Flag("remote-tenant", "Tenant ID to include in remote_write send").Default("0").String()
tlsClientInsecure := kingpin.Flag("tls-client-insecure", "Skip certificate check on tls connection").Default("false").Bool()
Expand Down
4 changes: 2 additions & 2 deletions metrics/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ func (c *Client) write(ctx context.Context) error {
log.Printf("Sending: %v timeseries, %v samples, %v timeseries per request, %v delay between requests\n", len(tss), c.config.RequestCount, c.config.BatchSize, c.config.RequestInterval)
ticker := time.NewTicker(c.config.RequestInterval)
defer ticker.Stop()
for ii := 0; ii < c.config.RequestCount; ii++ {
for ii := 0; c.config.RequestCount == -1 || ii < c.config.RequestCount; ii++ {
if ctx.Err() != nil {
return ctx.Err()
}

// Download the pprofs during half of the iteration to get avarege readings.
// Do that only when it is not set to take profiles at a given interval.
if len(c.config.PprofURLs) > 0 && ii == c.config.RequestCount/2 {
if len(c.config.PprofURLs) > 0 && c.config.RequestCount != -1 && ii == c.config.RequestCount/2 {
wgPprof.Add(1)
go func() {
download.URLs(c.config.PprofURLs, time.Now().Format("2-Jan-2006-15:04:05"))
Expand Down

0 comments on commit 018dc83

Please sign in to comment.