Skip to content

Commit

Permalink
(promql-to-dd-go) add new flag to control sleep duration between runs
Browse files Browse the repository at this point in the history
Previous, the sleep duration between each data pull/push and the query window was using the same setting/flag.

This PR introduces a new flag to control sleep duration separately and
default to 20s.
  • Loading branch information
taonic committed Jan 24, 2024
1 parent a7101f2 commit f172d77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cloud/observability/promql-to-dd-go/cmd/promqltodd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
matrixPrefix := set.String("matrix-prefix", "temporal_cloud_", "Prefix of the metrics to be queried and send to Datadog")
stepDuration := set.Int("step-duration-seconds", 60, "The step between metrics")
queryInterval := set.Int("query-interval-seconds", 600, "Interval between each Prometheus query")
sleepDuration := set.Int("sleep-duration-seconds", 60, "Sleep duration between each data submission")

if err := set.Parse(os.Args[1:]); err != nil {
log.Fatalf("failed parsing args: %s", err)
Expand Down Expand Up @@ -51,6 +52,7 @@ func main() {
MetricPrefix: *matrixPrefix,
StepDuration: time.Duration(*stepDuration) * time.Second,
QueryInterval: time.Duration(*queryInterval) * time.Second,
SleepDuration: time.Duration(*sleepDuration) * time.Second,
Quantiles: []float64{0.5, 0.9, 0.95, 0.99},
}

Expand Down
5 changes: 3 additions & 2 deletions cloud/observability/promql-to-dd-go/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Worker struct {
Quantiles []float64
QueryInterval time.Duration
StepDuration time.Duration
SleepDuration time.Duration
}

const (
Expand All @@ -29,7 +30,7 @@ const (

func (w *Worker) Run() {
interrupt := interruptCh()
ticker := time.NewTicker(w.QueryInterval)
ticker := time.NewTicker(w.SleepDuration)
defer ticker.Stop()
errs := make(chan error, 1)

Expand Down Expand Up @@ -100,7 +101,7 @@ func (w *Worker) do(errorChan chan<- error) {
return
}
log.Printf("Submitted total of %d series\n", len(series))
log.Printf("Awaits next tick (interval: %.0f seconds)\n", w.QueryInterval.Seconds())
log.Printf("Awaits next tick (interval: %.0f seconds)\n", w.SleepDuration.Seconds())
}

func (w *Worker) calcRange() promapi.Range {
Expand Down

0 comments on commit f172d77

Please sign in to comment.