Skip to content

Commit

Permalink
writes channel id as the label for the metrics samples
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Sep 5, 2023
1 parent 8ef8b12 commit d344f27
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d344f27

Please sign in to comment.