/
metrics.go
37 lines (31 loc) · 912 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
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debugapi
import (
"github.com/ethsana/sana"
"github.com/ethsana/sana/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
func newMetricsRegistry() (r *prometheus.Registry) {
r = prometheus.NewRegistry()
// register standard metrics
r.MustRegister(
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{
Namespace: metrics.Namespace,
}),
prometheus.NewGoCollector(),
prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: metrics.Namespace,
Name: "info",
Help: "Sana information.",
ConstLabels: prometheus.Labels{
"version": sana.Version,
},
}),
)
return r
}
func (s *Service) MustRegisterMetrics(cs ...prometheus.Collector) {
s.metricsRegistry.MustRegister(cs...)
}