Skip to content

Add ratman_switch_received_{frames, bytes}_total metrics (+ fix a typo)

embr requested to merge feature/moar-metrics into develop

Issue Fix

Part of #56 (closed)

Description

Adds metrics for the number and cumulative size of received frames.

Also, the prometheus_client crate tries to be clever and stick suffixes on metric names, which meant we accidentally had a metric named ratman_dispatch_bytes_bytes_total (with _bytes added twice).

Alternative(s) considered

I asked @spacekookie, who said the switch is probably the right place to put these metrics.

There's a bit of repetition in the metrics helpers between the switch and dispatch (RecipientType/IdentityType is a literal copy-paste job), which I'm not super fond of, but I'm not sure if it's worth generalising this right now. Can do if y'all think that's a better idea though.

Type

Choose one: Feature

Screenshots (if applicable)

$ http localhost:8090/_/metrics
# HELP ratman_routes_current Number of routes currently in the table.
# TYPE ratman_routes_current gauge
ratman_routes_current{kind="local"} 3
ratman_routes_current{kind="remote"} 1
# HELP ratman_dispatch_messages Total number of messages dispatched.
# TYPE ratman_dispatch_messages counter
ratman_dispatch_messages_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 4
# HELP ratman_dispatch_frames Total number of frames dispatched.
# TYPE ratman_dispatch_frames counter
ratman_dispatch_frames_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 4
ratman_dispatch_frames_total{recp_type="flood",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 562
ratman_dispatch_frames_total{recp_type="flood",recp_id="7D47-AE70-ECFF-D921-8EDA-1B1F-1D9F-4017-1A9F-6F41-71A3-E411-F3C0-FA54-315D-E95E"} 562
ratman_dispatch_frames_total{recp_type="flood",recp_id="43CC-8612-0100-E6CD-F06A-1049-948E-3DA3-94B8-3E7B-C131-BA1D-2570-2D1B-4C2D-A2CA"} 562
# HELP ratman_dispatch_bytes Total size of dispatched frames.
# TYPE ratman_dispatch_bytes counter
# UNIT ratman_dispatch_bytes bytes
ratman_dispatch_bytes_total{recp_type="flood",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 25290
ratman_dispatch_bytes_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 248
ratman_dispatch_bytes_total{recp_type="flood",recp_id="7D47-AE70-ECFF-D921-8EDA-1B1F-1D9F-4017-1A9F-6F41-71A3-E411-F3C0-FA54-315D-E95E"} 25290
ratman_dispatch_bytes_total{recp_type="flood",recp_id="43CC-8612-0100-E6CD-F06A-1049-948E-3DA3-94B8-3E7B-C131-BA1D-2570-2D1B-4C2D-A2CA"} 25290
# HELP ratman_switch_frames Total number of received frames.
# TYPE ratman_switch_frames counter
ratman_switch_frames_total{sender_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE",recp_type="flood",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 258
ratman_switch_frames_total{sender_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE",recp_type="standard",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 2
# HELP ratman_switch_bytes Total size of received frames.
# TYPE ratman_switch_bytes counter
# UNIT ratman_switch_bytes bytes
ratman_switch_bytes_total{sender_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE",recp_type="flood",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 11610
ratman_switch_bytes_total{sender_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE",recp_type="standard",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 124
# HELP ratman_proto_announcements Total number of announcements sent.
# TYPE ratman_proto_announcements counter
ratman_proto_announcements_total 843
# HELP http_requests Total number of HTTP requests.
# TYPE http_requests counter
http_requests_total{method="GET",path="/_/metrics",status="200"} 7
# EOF
Edited by embr

Merge request reports