22133: Upgrades ws to address CVE-2024-37890
[arvados.git] / services / keepstore / metrics.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package keepstore
6
7 import (
8         "github.com/prometheus/client_golang/prometheus"
9 )
10
11 type volumeMetricsVecs struct {
12         ioBytes     *prometheus.CounterVec
13         errCounters *prometheus.CounterVec
14         opsCounters *prometheus.CounterVec
15 }
16
17 func newVolumeMetricsVecs(reg *prometheus.Registry) *volumeMetricsVecs {
18         m := &volumeMetricsVecs{}
19         m.opsCounters = prometheus.NewCounterVec(
20                 prometheus.CounterOpts{
21                         Namespace: "arvados",
22                         Subsystem: "keepstore",
23                         Name:      "volume_operations",
24                         Help:      "Number of volume operations",
25                 },
26                 []string{"device_id", "operation"},
27         )
28         reg.MustRegister(m.opsCounters)
29         m.errCounters = prometheus.NewCounterVec(
30                 prometheus.CounterOpts{
31                         Namespace: "arvados",
32                         Subsystem: "keepstore",
33                         Name:      "volume_errors",
34                         Help:      "Number of volume errors",
35                 },
36                 []string{"device_id", "error_type"},
37         )
38         reg.MustRegister(m.errCounters)
39         m.ioBytes = prometheus.NewCounterVec(
40                 prometheus.CounterOpts{
41                         Namespace: "arvados",
42                         Subsystem: "keepstore",
43                         Name:      "volume_io_bytes",
44                         Help:      "Volume I/O traffic in bytes",
45                 },
46                 []string{"device_id", "direction"},
47         )
48         reg.MustRegister(m.ioBytes)
49
50         return m
51 }
52
53 func (vm *volumeMetricsVecs) getCounterVecsFor(lbls prometheus.Labels) (opsCV, errCV, ioCV *prometheus.CounterVec) {
54         opsCV = vm.opsCounters.MustCurryWith(lbls)
55         errCV = vm.errCounters.MustCurryWith(lbls)
56         ioCV = vm.ioBytes.MustCurryWith(lbls)
57         return
58 }