github.com/ethersphere/bee/v2@v2.2.0/pkg/settlement/swap/metrics.go (about) 1 // Copyright 2020 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 swap 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 TotalReceived prometheus.Counter 14 TotalSent prometheus.Counter 15 ChequesReceived prometheus.Counter 16 ChequesSent prometheus.Counter 17 ChequesRejected prometheus.Counter 18 AvailableBalance prometheus.Gauge 19 } 20 21 func newMetrics() metrics { 22 subsystem := "swap" 23 24 return metrics{ 25 TotalReceived: prometheus.NewCounter(prometheus.CounterOpts{ 26 Namespace: m.Namespace, 27 Subsystem: subsystem, 28 Name: "total_received", 29 Help: "Amount of tokens received from peers (income of the node)", 30 }), 31 TotalSent: prometheus.NewCounter(prometheus.CounterOpts{ 32 Namespace: m.Namespace, 33 Subsystem: subsystem, 34 Name: "total_sent", 35 Help: "Amount of tokens sent to peers (costs paid by the node)", 36 }), 37 ChequesReceived: prometheus.NewCounter(prometheus.CounterOpts{ 38 Namespace: m.Namespace, 39 Subsystem: subsystem, 40 Name: "cheques_received", 41 Help: "Number of cheques received from peers", 42 }), 43 ChequesSent: prometheus.NewCounter(prometheus.CounterOpts{ 44 Namespace: m.Namespace, 45 Subsystem: subsystem, 46 Name: "cheques_sent", 47 Help: "Number of cheques sent to peers", 48 }), 49 ChequesRejected: prometheus.NewCounter(prometheus.CounterOpts{ 50 Namespace: m.Namespace, 51 Subsystem: subsystem, 52 Name: "cheques_rejected", 53 Help: "Number of cheques rejected", 54 }), 55 AvailableBalance: prometheus.NewGauge(prometheus.GaugeOpts{ 56 Namespace: m.Namespace, 57 Subsystem: subsystem, 58 Name: "available_balance", 59 Help: "Currently available chequebook balance.", 60 }), 61 } 62 } 63 64 func (s *Service) Metrics() []prometheus.Collector { 65 return m.PrometheusCollectorsFromFields(s.metrics) 66 }