Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds channel ID label to the Prometheus message_receive_bytes_total and message_send_bytes_total metrics #1078

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions p2p/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...),
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
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...),
}
}

Expand Down
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)))
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
}
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)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[no changes needed]
using fmt.Sprintf in a heavy path is something to keep an eye on in the future

tendermint/tendermint#8845 (comment)

if nr, ok := reactor.(EnvelopeReceiver); ok {
nr.ReceiveEnvelope(Envelope{
ChannelID: chID,
Expand Down