github.com/ethersphere/bee/v2@v2.2.0/pkg/pullsync/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 pullsync 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 Offered prometheus.Counter // number of chunks offered 14 Wanted prometheus.Counter // number of chunks wanted 15 MissingChunks prometheus.Counter // number of reserve get errs 16 ReceivedZeroAddress prometheus.Counter // number of delivered chunks with invalid address 17 ReceivedInvalidChunk prometheus.Counter // number of delivered chunks with invalid address 18 Delivered prometheus.Counter // number of chunk deliveries 19 SentOffered prometheus.Counter // number of chunks offered 20 SentWanted prometheus.Counter // number of chunks wanted 21 Sent prometheus.Counter // number of chunks sent 22 DuplicateRuid prometheus.Counter // number of duplicate RUID requests we got 23 LastReceived *prometheus.CounterVec // last timestamp of the received chunks per bin 24 } 25 26 func newMetrics() metrics { 27 subsystem := "pullsync" 28 29 return metrics{ 30 Offered: prometheus.NewCounter(prometheus.CounterOpts{ 31 Namespace: m.Namespace, 32 Subsystem: subsystem, 33 Name: "chunks_offered", 34 Help: "Total chunks offered.", 35 }), 36 Wanted: prometheus.NewCounter(prometheus.CounterOpts{ 37 Namespace: m.Namespace, 38 Subsystem: subsystem, 39 Name: "chunks_wanted", 40 Help: "Total chunks wanted.", 41 }), 42 MissingChunks: prometheus.NewCounter(prometheus.CounterOpts{ 43 Namespace: m.Namespace, 44 Subsystem: subsystem, 45 Name: "missing_chunks", 46 Help: "Total reserve get errors.", 47 }), 48 ReceivedZeroAddress: prometheus.NewCounter(prometheus.CounterOpts{ 49 Namespace: m.Namespace, 50 Subsystem: subsystem, 51 Name: "received_zero_address", 52 Help: "Total chunks delivered with zero address and no chunk data.", 53 }), 54 ReceivedInvalidChunk: prometheus.NewCounter(prometheus.CounterOpts{ 55 Namespace: m.Namespace, 56 Subsystem: subsystem, 57 Name: "received_invalid_chunks", 58 Help: "Total invalid chunks delivered.", 59 }), 60 Delivered: prometheus.NewCounter(prometheus.CounterOpts{ 61 Namespace: m.Namespace, 62 Subsystem: subsystem, 63 Name: "chunks_delivered", 64 Help: "Total chunks delivered.", 65 }), 66 SentOffered: prometheus.NewCounter(prometheus.CounterOpts{ 67 Namespace: m.Namespace, 68 Subsystem: subsystem, 69 Name: "chunks_sent_offered", 70 Help: "Total chunks offered to peers.", 71 }), 72 SentWanted: prometheus.NewCounter(prometheus.CounterOpts{ 73 Namespace: m.Namespace, 74 Subsystem: subsystem, 75 Name: "chunks_sent_wanted", 76 Help: "Total chunks wanted by peers.", 77 }), 78 Sent: prometheus.NewCounter(prometheus.CounterOpts{ 79 Namespace: m.Namespace, 80 Subsystem: subsystem, 81 Name: "chunks_sent", 82 Help: "Total chunks sent.", 83 }), 84 DuplicateRuid: prometheus.NewCounter(prometheus.CounterOpts{ 85 Namespace: m.Namespace, 86 Subsystem: subsystem, 87 Name: "duplicate_ruids", 88 Help: "Total duplicate RUIDs.", 89 }), 90 LastReceived: prometheus.NewCounterVec( 91 prometheus.CounterOpts{ 92 Namespace: m.Namespace, 93 Subsystem: subsystem, 94 Name: "last_received", 95 Help: `The last timestamp of the received chunks per bin.`, 96 }, []string{"bin"}), 97 } 98 } 99 100 func (s *Syncer) Metrics() []prometheus.Collector { 101 return m.PrometheusCollectorsFromFields(s.metrics) 102 }