github.com/ethersphere/bee/v2@v2.2.0/pkg/storer/internal/transaction/metrics.go (about) 1 // Copyright 2024 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 transaction 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 MethodCalls *prometheus.CounterVec 14 MethodDuration *prometheus.HistogramVec 15 } 16 17 // newMetrics is a convenient constructor for creating new metrics. 18 func newMetrics() metrics { 19 const subsystem = "transaction" 20 21 return metrics{ 22 MethodCalls: prometheus.NewCounterVec( 23 prometheus.CounterOpts{ 24 Namespace: m.Namespace, 25 Subsystem: subsystem, 26 Name: "method_calls", 27 Help: "The number of method calls.", 28 }, 29 []string{"method", "status"}, 30 ), 31 MethodDuration: prometheus.NewHistogramVec( 32 prometheus.HistogramOpts{ 33 Namespace: m.Namespace, 34 Subsystem: subsystem, 35 Name: "method_duration", 36 Help: "The duration each method call took.", 37 }, 38 []string{"method", "status"}, 39 ), 40 } 41 }