github.com/ethersphere/bee/v2@v2.2.0/pkg/p2p/libp2p/internal/reacher/metrics.go (about) 1 // Copyright 2021 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package reacher 6 7 import ( 8 m "github.com/ethersphere/bee/v2/pkg/metrics" 9 "github.com/prometheus/client_golang/prometheus" 10 ) 11 12 type metrics struct { 13 Pings prometheus.CounterVec 14 PingTime prometheus.HistogramVec 15 } 16 17 func newMetrics() metrics { 18 subsystem := "reacher" 19 20 return metrics{ 21 Pings: *prometheus.NewCounterVec(prometheus.CounterOpts{ 22 Namespace: m.Namespace, 23 Subsystem: subsystem, 24 Name: "pings", 25 Help: "Ping counter.", 26 }, []string{"status"}), 27 PingTime: *prometheus.NewHistogramVec(prometheus.HistogramOpts{ 28 Namespace: m.Namespace, 29 Subsystem: subsystem, 30 Name: "ping_timer", 31 Help: "Ping timer.", 32 }, []string{"status"}), 33 } 34 } 35 36 func (s *reacher) Metrics() []prometheus.Collector { 37 return m.PrometheusCollectorsFromFields(s.metrics) 38 }