Commit 4db15b0
Eric Price
feat(monitoring): add per-channel and per-client byte metrics
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.1 parent 6ddd6a3 commit 4db15b0
26 files changed
Lines changed: 539 additions & 39 deletions
File tree
- miner-apps
- jd-client/src/lib
- channel_manager
- downstream
- translator/src/lib
- sv1
- downstream
- sv1_server
- sv2/channel_manager
- pool-apps/pool/src/lib
- channel_manager
- downstream
- stratum-apps/src
- monitoring
- network_helpers
- utils
Lines changed: 11 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 100 | + | |
| 101 | + | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
| |||
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
| 114 | + | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
453 | 454 | | |
454 | 455 | | |
455 | 456 | | |
456 | | - | |
| 457 | + | |
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| |||
716 | 717 | | |
717 | 718 | | |
718 | 719 | | |
719 | | - | |
| 720 | + | |
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
| |||
911 | 912 | | |
912 | 913 | | |
913 | 914 | | |
914 | | - | |
| 915 | + | |
915 | 916 | | |
916 | 917 | | |
917 | 918 | | |
| |||
1111 | 1112 | | |
1112 | 1113 | | |
1113 | 1114 | | |
1114 | | - | |
| 1115 | + | |
1115 | 1116 | | |
1116 | 1117 | | |
1117 | 1118 | | |
| |||
1334 | 1335 | | |
1335 | 1336 | | |
1336 | 1337 | | |
1337 | | - | |
| 1338 | + | |
1338 | 1339 | | |
1339 | 1340 | | |
1340 | 1341 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| 178 | + | |
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
| |||
314 | 317 | | |
315 | 318 | | |
316 | 319 | | |
| 320 | + | |
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
| |||
685 | 689 | | |
686 | 690 | | |
687 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
688 | 714 | | |
689 | 715 | | |
690 | 716 | | |
| |||
693 | 719 | | |
694 | 720 | | |
695 | 721 | | |
| 722 | + | |
696 | 723 | | |
697 | 724 | | |
698 | 725 | | |
699 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
700 | 740 | | |
701 | 741 | | |
702 | 742 | | |
| |||
806 | 846 | | |
807 | 847 | | |
808 | 848 | | |
| 849 | + | |
809 | 850 | | |
810 | 851 | | |
811 | 852 | | |
812 | 853 | | |
813 | 854 | | |
814 | 855 | | |
815 | 856 | | |
| 857 | + | |
816 | 858 | | |
817 | 859 | | |
818 | 860 | | |
| |||
867 | 909 | | |
868 | 910 | | |
869 | 911 | | |
| 912 | + | |
870 | 913 | | |
871 | 914 | | |
872 | 915 | | |
873 | 916 | | |
874 | 917 | | |
875 | 918 | | |
876 | 919 | | |
| 920 | + | |
877 | 921 | | |
878 | 922 | | |
879 | 923 | | |
| |||
1169 | 1213 | | |
1170 | 1214 | | |
1171 | 1215 | | |
1172 | | - | |
| 1216 | + | |
1173 | 1217 | | |
1174 | 1218 | | |
1175 | 1219 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
589 | | - | |
| 589 | + | |
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| 256 | + | |
255 | 257 | | |
256 | 258 | | |
257 | 259 | | |
| |||
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
| 281 | + | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
283 | 286 | | |
| 287 | + | |
284 | 288 | | |
285 | 289 | | |
286 | 290 | | |
| |||
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
| 335 | + | |
331 | 336 | | |
332 | 337 | | |
333 | 338 | | |
| |||
459 | 464 | | |
460 | 465 | | |
461 | 466 | | |
462 | | - | |
| 467 | + | |
463 | 468 | | |
464 | 469 | | |
465 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | | - | |
37 | | - | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
270 | 275 | | |
271 | 276 | | |
272 | 277 | | |
| 278 | + | |
273 | 279 | | |
274 | 280 | | |
| 281 | + | |
275 | 282 | | |
276 | 283 | | |
277 | 284 | | |
| |||
282 | 289 | | |
283 | 290 | | |
284 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
285 | 299 | | |
286 | 300 | | |
287 | 301 | | |
| |||
293 | 307 | | |
294 | 308 | | |
295 | 309 | | |
| 310 | + | |
296 | 311 | | |
297 | 312 | | |
298 | 313 | | |
| |||
305 | 320 | | |
306 | 321 | | |
307 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
308 | 329 | | |
309 | 330 | | |
310 | 331 | | |
| |||
0 commit comments