Skip to content

Commit 77fa0f0

Browse files
author
Tyler Reid
committed
Use seconds for our duration rather than nanoseconds
Signed-off-by: Tyler Reid <[email protected]>
1 parent e4144d9 commit 77fa0f0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Ensure that a ring store is configured using `-alertmanager.sharding-ring.store`, and set the flags relevant to the chosen store type.
2323
* Enable the feature using `-alertmanager.sharding-enabled`.
2424
* Note the prior addition of a new configuration option `-alertmanager.persist-interval`. This sets the interval between persisting the current alertmanager state (notification log and silences) to object storage. See the [configuration file reference](https://cortexmetrics.io/docs/configuration/configuration-file/#alertmanager_config) for more information.
25-
* [FEATURE] Ruler: Add new `-ruler.enable-query-stats` which when enabled will report the `cortex_ruler_query_seconds_total` metric that tracks the sum of the wall time of executing queries in the ruler. #4317
25+
* [FEATURE] Ruler: Add new `-ruler.enable-query-stats` which when enabled will report the `cortex_ruler_query_seconds_total` metric that tracks the sum of the wall time of executing queries in the ruler in seconds. #4317
2626
* [ENHANCEMENT] Alertmanager: Cleanup persisted state objects from remote storage when a tenant configuration is deleted. #4167
2727
* [ENHANCEMENT] Storage: Added the ability to disable Open Census within GCS client (e.g `-gcs.enable-opencensus=false`). #4219
2828
* [ENHANCEMENT] Etcd: Added username and password to etcd config. #4205

pkg/ruler/compat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func MetricsQueryFunc(qf rules.QueryFunc, queries, failedQueries prometheus.Coun
151151
// If we've been passed a counter vec we want to record the wall time spent executing this request.
152152
if queryTime != nil {
153153
startTime = time.Now()
154-
defer func() { queryTime.WithLabelValues(userID).Add(float64(time.Since(startTime))) }()
154+
defer func() { queryTime.WithLabelValues(userID).Add(time.Since(startTime).Seconds()) }()
155155
}
156156

157157
result, err := qf(ctx, qs, t)

pkg/ruler/compat_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TestMetricsQueryFuncMetrics(t *testing.T) {
248248
queryTime := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"})
249249

250250
mockFunc := func(ctx context.Context, q string, t time.Time) (promql.Vector, error) {
251-
time.Sleep(1 * time.Millisecond)
251+
time.Sleep(1 * time.Second)
252252
return promql.Vector{}, nil
253253
}
254254
qf := MetricsQueryFunc(mockFunc, queries, failures, queryTime, "userID")
@@ -257,5 +257,5 @@ func TestMetricsQueryFuncMetrics(t *testing.T) {
257257

258258
require.Equal(t, 1, int(testutil.ToFloat64(queries)))
259259
require.Equal(t, 0, int(testutil.ToFloat64(failures)))
260-
require.LessOrEqual(t, float64(1*time.Millisecond), testutil.ToFloat64(queryTime.WithLabelValues("userID")))
260+
require.LessOrEqual(t, float64(1), testutil.ToFloat64(queryTime.WithLabelValues("userID")))
261261
}

0 commit comments

Comments
 (0)