Skip to content
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

fix(metric type): Use rate instead of count when submitting metric to Datadog #58

Merged
merged 1 commit into from
Aug 10, 2023
Merged
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
4 changes: 2 additions & 2 deletions cloud/observability/promql-to-dd-go/worker/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func PromHistogramToDatadogGauge(name string, quantile float64, matrix model.Mat
return matrixToSeries(name, metricType, matrix)
}

func PromCountToDatadogCount(name string, matrix model.Matrix) []datadogV2.MetricSeries {
func PromCountToDatadogRate(name string, matrix model.Matrix) []datadogV2.MetricSeries {
name = strings.TrimSuffix(name, "_count") + "_rate1m"
metricType := datadogV2.METRICINTAKETYPE_COUNT
metricType := datadogV2.METRICINTAKETYPE_RATE
return matrixToSeries(name, metricType, matrix)
}

Expand Down
2 changes: 1 addition & 1 deletion cloud/observability/promql-to-dd-go/worker/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Ptr[T any](v T) *T {
return &v
}

func TestPromMatrixToDatadogSeries(t *testing.T) {
func TestPromHistogramToDatadogGauge(t *testing.T) {
testCases := []struct {
name string
metricName string
Expand Down
10 changes: 5 additions & 5 deletions cloud/observability/promql-to-dd-go/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ func (w *Worker) do(errorChan chan<- error) {
}
log.Printf("Received %d histogram series\n", len(histogramSeries))

// counters
counterSeries := []datadogV2.MetricSeries{}
// rates
rateSeries := []datadogV2.MetricSeries{}
for _, counterName := range counters {
promql := fmt.Sprintf(RatePromQL, counterName)
matrix, err := w.QueryMetrics(promql, queryRange)
if err != nil {
errorChan <- err
return
}
counterSeries = append(counterSeries, PromCountToDatadogCount(counterName, matrix)...)
rateSeries = append(rateSeries, PromCountToDatadogRate(counterName, matrix)...)
}
log.Printf("Received %d counter series\n", len(counterSeries))
log.Printf("Received %d rate series\n", len(rateSeries))

log.Printf("Submitting to Datadog\n")
series := append(histogramSeries, counterSeries...)
series := append(histogramSeries, rateSeries...)
err = w.SubmitMetrics(series)
if err != nil {
errorChan <- err
Expand Down
Loading