github.com/ethersphere/bee/v2@v2.2.0/pkg/puller/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 puller 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 SyncWorkerIterCounter prometheus.Counter // counts the number of syncing iterations 14 SyncWorkerCounter prometheus.Gauge // count number of syncing jobs 15 SyncedCounter prometheus.CounterVec // number of synced chunks 16 SyncWorkerErrCounter prometheus.Counter // count number of errors 17 MaxUintErrCounter prometheus.Counter // how many times we got maxuint as topmost 18 } 19 20 func newMetrics() metrics { 21 subsystem := "puller" 22 23 return metrics{ 24 SyncWorkerIterCounter: prometheus.NewCounter(prometheus.CounterOpts{ 25 Namespace: m.Namespace, 26 Subsystem: subsystem, 27 Name: "worker_iterations", 28 Help: "Total worker iterations.", 29 }), 30 SyncWorkerCounter: prometheus.NewGauge(prometheus.GaugeOpts{ 31 Namespace: m.Namespace, 32 Subsystem: subsystem, 33 Name: "worker", 34 Help: "Total active worker jobs.", 35 }), 36 SyncedCounter: *prometheus.NewCounterVec(prometheus.CounterOpts{ 37 Namespace: m.Namespace, 38 Subsystem: subsystem, 39 Name: "synced_chunks", 40 Help: "Total synced chunks.", 41 }, []string{"type"}), 42 SyncWorkerErrCounter: prometheus.NewCounter(prometheus.CounterOpts{ 43 Namespace: m.Namespace, 44 Subsystem: subsystem, 45 Name: "worker_errors", 46 Help: "Total worker errors.", 47 }), 48 MaxUintErrCounter: prometheus.NewCounter(prometheus.CounterOpts{ 49 Namespace: m.Namespace, 50 Subsystem: subsystem, 51 Name: "max_uint_errors", 52 Help: "Total max uint errors.", 53 }), 54 } 55 } 56 57 func (p *Puller) Metrics() []prometheus.Collector { 58 return m.PrometheusCollectorsFromFields(p.metrics) 59 }