github.com/aakash4dev/cometbft@v0.38.2/mempool/metrics.gen.go (about)

     1  // Code generated by metricsgen. DO NOT EDIT.
     2  
     3  package mempool
     4  
     5  import (
     6  	"github.com/go-kit/kit/metrics/discard"
     7  	prometheus "github.com/go-kit/kit/metrics/prometheus"
     8  	stdprometheus "github.com/prometheus/client_golang/prometheus"
     9  )
    10  
    11  func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
    12  	labels := []string{}
    13  	for i := 0; i < len(labelsAndValues); i += 2 {
    14  		labels = append(labels, labelsAndValues[i])
    15  	}
    16  	return &Metrics{
    17  		Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
    18  			Namespace: namespace,
    19  			Subsystem: MetricsSubsystem,
    20  			Name:      "size",
    21  			Help:      "Number of uncommitted transactions in the mempool.",
    22  		}, labels).With(labelsAndValues...),
    23  		TxSizeBytes: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
    24  			Namespace: namespace,
    25  			Subsystem: MetricsSubsystem,
    26  			Name:      "tx_size_bytes",
    27  			Help:      "Histogram of transaction sizes in bytes.",
    28  
    29  			Buckets: stdprometheus.ExponentialBuckets(1, 3, 7),
    30  		}, labels).With(labelsAndValues...),
    31  		FailedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
    32  			Namespace: namespace,
    33  			Subsystem: MetricsSubsystem,
    34  			Name:      "failed_txs",
    35  			Help:      "Number of failed transactions.",
    36  		}, labels).With(labelsAndValues...),
    37  		RejectedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
    38  			Namespace: namespace,
    39  			Subsystem: MetricsSubsystem,
    40  			Name:      "rejected_txs",
    41  			Help:      "Number of rejected transactions.",
    42  		}, labels).With(labelsAndValues...),
    43  		RecheckTimes: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
    44  			Namespace: namespace,
    45  			Subsystem: MetricsSubsystem,
    46  			Name:      "recheck_times",
    47  			Help:      "Number of times transactions are rechecked in the mempool.",
    48  		}, labels).With(labelsAndValues...),
    49  		AlreadyReceivedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
    50  			Namespace: namespace,
    51  			Subsystem: MetricsSubsystem,
    52  			Name:      "already_received_txs",
    53  			Help:      "Number of duplicate transaction reception.",
    54  		}, labels).With(labelsAndValues...),
    55  	}
    56  }
    57  
    58  func NopMetrics() *Metrics {
    59  	return &Metrics{
    60  		Size:               discard.NewGauge(),
    61  		TxSizeBytes:        discard.NewHistogram(),
    62  		FailedTxs:          discard.NewCounter(),
    63  		RejectedTxs:        discard.NewCounter(),
    64  		RecheckTimes:       discard.NewCounter(),
    65  		AlreadyReceivedTxs: discard.NewCounter(),
    66  	}
    67  }