...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package metrics
16
17 import (
18 "fmt"
19
20 "github.com/prometheus/client_golang/prometheus"
21 "go.opencensus.io/stats"
22 )
23
24 var (
25 namespace = "configconnector"
26 labels = []string{"namespace", "group_version_kind", "status"}
27 )
28
29
30 var (
31 MReconcileOccupiedWorkers = stats.Int64("ReconcileOccupiedWorkers", "The number of occupied reconcile workers", stats.UnitDimensionless)
32 MReconcileTotalWorkers = stats.Int64("ReconcileTotalWorkers", "The number of total reconcile workers", stats.UnitDimensionless)
33 MReconcileRequests = stats.Int64("ReconcileRequests", "The number of reconcile requests", stats.UnitDimensionless)
34 MInternalErrors = stats.Int64("InternalErrorsTotal", "The number of internal errors", stats.UnitDimensionless)
35 MReconcileDuration = stats.Float64("ReconcileDuration", "The duration of reconcile requests", "seconds")
36 MProcessStartTime = stats.Float64("ProcessStartTimeSeconds", "Start time of the process since unix epoch in seconds", "seconds")
37 )
38
39
40 func NewAppliedResourcesCollector() *prometheus.GaugeVec {
41 return prometheus.NewGaugeVec(prometheus.GaugeOpts{
42 Namespace: namespace,
43 Name: "applied_resources_total",
44 Help: "The number of applied resources",
45 }, labels)
46 }
47
48 func NewBuildInfoCollector(version string) prometheus.Collector {
49 return prometheus.NewGaugeFunc(
50 prometheus.GaugeOpts{
51 Namespace: namespace,
52 Name: "build_info",
53 Help: fmt.Sprintf(
54 "A metric with a constant '1' value labeled by version from which %s was built.",
55 namespace,
56 ),
57 ConstLabels: prometheus.Labels{
58 "version": version,
59 },
60 },
61 func() float64 { return 1 },
62 )
63 }
64
View as plain text