-
Notifications
You must be signed in to change notification settings - Fork 455
/
metrics.go
54 lines (50 loc) · 2.49 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: AGPL-3.0-only
package continuoustest
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
// TestMetrics holds generic metrics tracked by tests. The common metrics are used to enforce the same
// metric names and labels to track the same information across different tests.
type TestMetrics struct {
writesTotal *prometheus.CounterVec
writesFailedTotal *prometheus.CounterVec
queriesTotal *prometheus.CounterVec
queriesFailedTotal *prometheus.CounterVec
queryResultChecksTotal *prometheus.CounterVec
queryResultChecksFailedTotal *prometheus.CounterVec
}
func NewTestMetrics(testName string, reg prometheus.Registerer) *TestMetrics {
return &TestMetrics{
writesTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_writes_total",
Help: "Total number of attempted write requests.",
ConstLabels: map[string]string{"test": testName},
}, []string{"type"}),
writesFailedTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_writes_failed_total",
Help: "Total number of failed write requests.",
ConstLabels: map[string]string{"test": testName},
}, []string{"status_code", "type"}),
queriesTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_queries_total",
Help: "Total number of attempted query requests.",
ConstLabels: map[string]string{"test": testName},
}, []string{"type"}),
queriesFailedTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_queries_failed_total",
Help: "Total number of failed query requests.",
ConstLabels: map[string]string{"test": testName},
}, []string{"type"}),
queryResultChecksTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_query_result_checks_total",
Help: "Total number of query results checked for correctness.",
ConstLabels: map[string]string{"test": testName},
}, []string{"type"}),
queryResultChecksFailedTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "mimir_continuous_test_query_result_checks_failed_total",
Help: "Total number of query results failed when checking for correctness.",
ConstLabels: map[string]string{"test": testName},
}, []string{"type"}),
}
}