github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/remotewrite/client_metrics.go (about) 1 package remotewrite 2 3 import ( 4 "fmt" 5 6 "github.com/prometheus/client_golang/prometheus" 7 ) 8 9 type clientMetrics struct { 10 reg prometheus.Registerer 11 12 sentBytes prometheus.Counter 13 responseTime *prometheus.HistogramVec 14 } 15 16 func newClientMetrics(reg prometheus.Registerer, targetName, targetAddress string) *clientMetrics { 17 labels := prometheus.Labels{ 18 "targetName": targetName, 19 "targetAddress": targetAddress, 20 } 21 22 m := &clientMetrics{reg: reg} 23 // Suffix the subsystem with queue, since there will be other sub-subsystems (eg queue) 24 subs := fmt.Sprintf("%s_client", subsystem) 25 26 m.sentBytes = prometheus.NewCounter(prometheus.CounterOpts{ 27 Namespace: namespace, 28 Subsystem: subs, 29 Name: "sent_bytes", 30 Help: "The total number of bytes of data (not metadata) sent to the remote target.", 31 ConstLabels: labels, 32 }) 33 34 m.responseTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{ 35 Namespace: namespace, 36 Subsystem: subs, 37 Name: "response_time", 38 ConstLabels: labels, 39 }, []string{"code"}) 40 41 return m 42 } 43 44 func (m clientMetrics) mustRegister() { 45 m.reg.MustRegister( 46 m.sentBytes, 47 m.responseTime, 48 ) 49 }