Skip to content

[draft] feat(monitoring): add byte metrics with aggregate Prometheus gauges#285

Open
gimballock wants to merge 1 commit intostratum-mining:mainfrom
fossatmara:feat/bytes-metrics
Open

[draft] feat(monitoring): add byte metrics with aggregate Prometheus gauges#285
gimballock wants to merge 1 commit intostratum-mining:mainfrom
fossatmara:feat/bytes-metrics

Conversation

@gimballock
Copy link

@gimballock gimballock commented Feb 20, 2026

Add bytes_received/bytes_sent tracking across all three components
(pool, jd-client, translator) for SV2 channels and SV1 clients.

SV2 byte tracking:

  • Per-channel (bytes_received, bytes_sent) counters in pool, jd-client,
    and translator, keyed by channel_id in bytes_by_channel maps
  • Shared mining_message_channel_id() helper in protocol_message_type.rs
    to extract channel_id from parsed Mining messages
  • Raw frame payload guard (len >= 4) for channel_id extraction from
    unparsed upstream frames in jd-client and translator
  • Cleanup in all CloseChannel handlers and ChannelManagerData::reset()
  • JDC record_upstream_sent_bytes() eliminates double-lock on sends

SV1 byte tracking (translator only):

  • Arc counters in ConnectionSV1, shared with DownstreamData
  • Reader counts line.len()+1 (newline stripped by LinesCodec)
  • Writer counts serialized JSON bytes before write_all

Prometheus metrics (fixed cardinality):

  • sv2_server_bytes_{received,sent}_total — aggregate scalar Gauges
  • sv2_client_bytes_{received,sent}_total — aggregate scalar Gauges
  • sv1_client_bytes_{received,sent}_total — per-client GaugeVec
    (1:1 with TCP connections, appropriate granularity)

Per-channel byte detail remains available via the JSON REST API
(/api/v1/server/channels, /api/v1/clients/{id}/channels,
/api/v1/sv1/clients) for drill-down without inflating Prometheus
time series cardinality.

Aggregate byte totals added to ServerSummary and Sv2ClientsSummary
so /api/v1/global includes byte totals alongside hashrate and
channel counts.

@gimballock gimballock force-pushed the feat/bytes-metrics branch 2 times, most recently from 4db15b0 to 017e05a Compare February 27, 2026 03:07
@gimballock gimballock changed the title [draft] feat(monitoring): add per-channel and per-client byte metrics [draft] feat(monitoring): add byte metrics with aggregate Prometheus gauges Feb 27, 2026
Add bytes_received/bytes_sent tracking across all three components
(pool, jd-client, translator) for SV2 channels and SV1 clients.

SV2 byte tracking:
- Per-channel (bytes_received, bytes_sent) counters in pool, jd-client,
  and translator, keyed by channel_id in bytes_by_channel maps
- Shared mining_message_channel_id() helper in protocol_message_type.rs
  to extract channel_id from parsed Mining messages
- Raw frame payload guard (len >= 4) for channel_id extraction from
  unparsed upstream frames in jd-client and translator
- Cleanup in all CloseChannel handlers and ChannelManagerData::reset()
- JDC record_upstream_sent_bytes() eliminates double-lock on sends

SV1 byte tracking (translator only):
- Arc<AtomicU64> counters in ConnectionSV1, shared with DownstreamData
- Reader counts line.len()+1 (newline stripped by LinesCodec)
- Writer counts serialized JSON bytes before write_all

Prometheus metrics (fixed cardinality):
- sv2_server_bytes_{received,sent}_total — aggregate scalar Gauges
- sv2_client_bytes_{received,sent}_total — aggregate scalar Gauges
- sv1_client_bytes_{received,sent}_total — per-client GaugeVec
  (1:1 with TCP connections, appropriate granularity)

Per-channel byte detail remains available via the JSON REST API
(/api/v1/server/channels, /api/v1/clients/{id}/channels,
/api/v1/sv1/clients) for drill-down without inflating Prometheus
time series cardinality.

Aggregate byte totals added to ServerSummary and Sv2ClientsSummary
so /api/v1/global includes byte totals alongside hashrate and
channel counts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant