[draft] feat(monitoring): add per-channel and per-client byte metrics#285
Open
gimballock wants to merge 1 commit intostratum-mining:mainfrom
Open
[draft] feat(monitoring): add per-channel and per-client byte metrics#285gimballock wants to merge 1 commit intostratum-mining:mainfrom
gimballock wants to merge 1 commit intostratum-mining:mainfrom
Conversation
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:
- sv2_server_channel_bytes_{received,sent}_total
- sv2_client_channel_bytes_{received,sent}_total
- sv1_client_bytes_{received,sent}_total
- All use gauge-with-reset pattern for stale label cleanup
Also updates README with new metric names and design notes on
capacity planning, anomaly detection, cost attribution, and
reflection attack detection use cases.
f819634 to
4db15b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add bytes_received/bytes_sent tracking across all three components (pool, jd-client, translator) for SV2 channels and SV1 clients.
SV2 byte tracking:
SV1 byte tracking (translator only):
Prometheus metrics:
Also updates README with new metric names and design notes on capacity planning, anomaly detection, cost attribution, and reflection attack detection use cases.