-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathmetrics.go
39 lines (31 loc) · 905 Bytes
/
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
package metrics
import (
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type BlockIdType string
var (
MetricsNamespace = "blob_api"
BlockIdTypeHash BlockIdType = "hash"
BlockIdTypeBeacon BlockIdType = "beacon"
BlockIdTypeInvalid BlockIdType = "invalid"
)
type Metricer interface {
RecordBlockIdType(t BlockIdType)
}
type metricsRecorder struct {
inputType *prometheus.CounterVec
}
func NewMetrics(registry *prometheus.Registry) Metricer {
factory := metrics.With(registry)
return &metricsRecorder{
inputType: factory.NewCounterVec(prometheus.CounterOpts{
Namespace: MetricsNamespace,
Name: "block_id_type",
Help: "The type of block id used to request a block",
}, []string{"type"}),
}
}
func (m *metricsRecorder) RecordBlockIdType(t BlockIdType) {
m.inputType.WithLabelValues(string(t)).Inc()
}