github.com/ethersphere/bee/v2@v2.2.0/pkg/pss/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 pss
     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  	TotalMessagesSentCounter prometheus.Counter
    14  	MessageMiningDuration    prometheus.Gauge
    15  }
    16  
    17  func newMetrics() metrics {
    18  	subsystem := "pss"
    19  
    20  	return metrics{
    21  		TotalMessagesSentCounter: prometheus.NewCounter(prometheus.CounterOpts{
    22  			Namespace: m.Namespace,
    23  			Subsystem: subsystem,
    24  			Name:      "total_message_sent",
    25  			Help:      "Total messages sent.",
    26  		}),
    27  		MessageMiningDuration: prometheus.NewGauge(prometheus.GaugeOpts{
    28  			Namespace: m.Namespace,
    29  			Subsystem: subsystem,
    30  			Name:      "mining_duration",
    31  			Help:      "Time duration to mine a message.",
    32  		}),
    33  	}
    34  }
    35  
    36  func (s *pss) Metrics() []prometheus.Collector {
    37  	return m.PrometheusCollectorsFromFields(s.metrics)
    38  }