From 8ef8b12f000de34edce0732ad85e771db29bca02 Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 5 Sep 2023 14:42:15 -0700 Subject: [PATCH 1/2] introduces the channel ID as a label to total bytes sent and received --- p2p/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/p2p/metrics.go b/p2p/metrics.go index 7c80658e5d..2d02d386b8 100644 --- a/p2p/metrics.go +++ b/p2p/metrics.go @@ -87,13 +87,13 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Subsystem: MetricsSubsystem, Name: "message_receive_bytes_total", Help: "Number of bytes of each message type received.", - }, append(labels, "message_type")).With(labelsAndValues...), + }, append(labels, "message_type", "chID")).With(labelsAndValues...), MessageSendBytesTotal: prometheus.NewCounterFrom(stdprometheus.CounterOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, Name: "message_send_bytes_total", Help: "Number of bytes of each message type sent.", - }, append(labels, "message_type")).With(labelsAndValues...), + }, append(labels, "message_type", "chID")).With(labelsAndValues...), } } From d344f2712d38e073b06fdf97d4eecf3634fc027e Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 5 Sep 2023 14:42:42 -0700 Subject: [PATCH 2/2] writes channel id as the label for the metrics samples --- p2p/peer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/p2p/peer.go b/p2p/peer.go index 49c0dd4e40..4de7148df6 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -331,7 +331,8 @@ func (p *peer) SendEnvelope(e Envelope) bool { } res := p.Send(e.ChannelID, msgBytes) if res { - p.metrics.MessageSendBytesTotal.With("message_type", metricLabelValue).Add(float64(len(msgBytes))) + p.metrics.MessageSendBytesTotal.With("message_type", + metricLabelValue, "chID", fmt.Sprintf("%#x", e.ChannelID)).Add(float64(len(msgBytes))) } return res } @@ -380,7 +381,8 @@ func (p *peer) TrySendEnvelope(e Envelope) bool { } res := p.TrySend(e.ChannelID, msgBytes) if res { - p.metrics.MessageSendBytesTotal.With("message_type", metricLabelValue).Add(float64(len(msgBytes))) + p.metrics.MessageSendBytesTotal.With("message_type", + metricLabelValue, "chID", fmt.Sprintf("%#x", e.ChannelID)).Add(float64(len(msgBytes))) } return res } @@ -532,7 +534,8 @@ func createMConnection( } } p.metrics.PeerReceiveBytesTotal.With(labels...).Add(float64(len(msgBytes))) - p.metrics.MessageReceiveBytesTotal.With("message_type", p.mlc.ValueToMetricLabel(msg)).Add(float64(len(msgBytes))) + p.metrics.MessageReceiveBytesTotal.With("message_type", + p.mlc.ValueToMetricLabel(msg), "chID", fmt.Sprintf("%#x", chID)).Add(float64(len(msgBytes))) if nr, ok := reactor.(EnvelopeReceiver); ok { nr.ReceiveEnvelope(Envelope{ ChannelID: chID,