feat(monitoring): expose per-channel share work to Prometheus - #820
Open
gimballock wants to merge 1 commit into
Open
feat(monitoring): expose per-channel share work to Prometheus#820gimballock wants to merge 1 commit into
gimballock wants to merge 1 commit into
Conversation
`sv2_client_channel_hashrate` reports `nominal_hashrate` — the value the miner declared when opening the channel, not what it produced. That number has been wrong in three separate ways already (stratum-mining#242, stratum-mining#262, stratum-mining#670), and stratum-mining#248 was resolved by deleting a metric that likewise reported configuration as measurement. Expose `sv2_client_channel_share_work_total` from the `share_work_sum` the channel already accumulates, so `rate()` over it gives measured work per second alongside the declared figure. Labels mirror `sv2_client_channel_hashrate` exactly, so the existing stale-label bookkeeping removes both together when a channel goes away; no new label dimension is introduced. The value is cumulative per channel, and a per-channel series ending when that miner disconnects is the intended behaviour for a per-miner view. Client-side only. The server-side structs carry `acknowledged_work_sum` and `validated_work_sum` rather than `share_work_sum`, and choosing between them — or exposing the divergence, which is the operationally interesting part — is a separate question best not answered incidentally here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
gimballock
marked this pull request as ready for review
September 8, 2026 18:10
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.
sv2_client_channel_hashratereportsnominal_hashrate— the value a miner declared when opening the channel, not what it produced. A dashboard built on it shows nameplate for a throttled or dead miner.That number has been wrong in three separate ways already (#242 — not updated on
SetTarget; #262 — stale whenenable_vardiff = false; #670 — idle downstreams inflating the aggregate). And #248 was resolved by deletingsv2_client_channel_shares_per_minute, which likewise reported a configuration value as a measurement.Change
Expose
sv2_client_channel_share_work_totalfrom theshare_work_sumeach channel already accumulates.rate()over it gives measured work per second, alongside the declared figure rather than replacing it — the divergence between the two is itself useful.Labels mirror
sv2_client_channel_hashrateexactly, so the existing stale-label bookkeeping removes both together when a channel goes away. No new label dimension, so the per-channel series count goes from 10 to 11 rather than multiplying.The value is cumulative per channel. A per-channel series ending when that miner disconnects is the intended behaviour for a per-miner view, so no process-level accounting is needed here — unlike #802, which fixes a total that must outlive the channel that produced it.
On adding a series
This does add one series per channel, which is worth stating plainly given cardinality is under discussion elsewhere. Two things bound it: it introduces no new label dimension, and the far larger per-channel cost is the eight pre-seeded
shares_rejectedcodes, which are a total rather than a per-channel quantity and could move to process scope. I'd like to propose that separately. Net, the direction is a reduction; this is the one addition I think earns its place, because the alternative is a hashrate panel that cannot distinguish a throttled miner from a healthy one.Scope
Client-side only. The server-side structs carry
acknowledged_work_sumandvalidated_work_sumrather thanshare_work_sum. Choosing between them — or exposing their divergence, which is arguably the more interesting signal, because it is work we validated that upstream did not acknowledge — is a separate question I'd rather not answer incidentally here.Label hygiene is also out of scope.
client_idchurns on every reconnect and fragments a miner's history, which affects every per-channel metric equally. Worth addressing across all of them at once rather than diverging one.Naming
_totalbecause the value is cumulative, matching the convention already used forsv2_client_shares_accepted_total(also a cumulativeGauge). It also keepsrate()andincrease()free of thePossibleNonCounterInfoannotation, which is a name-suffix heuristic. Counter-reset correction is applied by value rather than by declared type, so a monotonic gauge rates correctly, including across the resets that occur when a channel's accounting is reset.Verified
stratum-apps109/109 withmonitoringand 119/119 withasic-rs-telemetry;clippyandfmtclean; pool and miner-apps unaffected;openapi.jsonbyte-identical, because this touches no API type.The test uses deliberately distinct
nominal_hashrateandshare_work_sumvalues, and I confirmed it fails when the wrong field is wired —[100.0, 100.0]instead of[4242.0, 7.5]— because silently reporting the declared value is exactly the failure mode #248 was about.🤖 Generated with Claude Code