Commit 5eea4b9
Implement real-time metrics collection for admin dashboard (#89)
* Initial plan
* Add missing metrics to node's MetricsRegistry
- Add messages_sent and messages_received counters
- Add average_trust_score gauge (stored as fixed-point for atomic operations)
- Add slashing_events_total counter
- Update export_prometheus to include all new metrics
- Add comprehensive tests for new metrics
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
* Integrate metrics collection in network and tournament managers
- Add message_sent counter increments in broadcast_block and broadcast_transaction
- Add message_received counter increments in handle_incoming_block and handle_incoming_transaction
- Update tournament manager to calculate and report average trust score
- Track slashing events when negative evidence is recorded
- All metrics now populated with real data from node operations
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
* Address code review feedback
- Add DEFAULT_TRUST_SCORE constant instead of magic number 0.85
- Use evidence_type.is_negative() method instead of hardcoded match
- Add bounds checking to trust score fixed-point conversion with clamp(0.0, 1000.0)
- Add clarifying comment about trust score precision range
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
* Fix trust score clamp and remove unnecessary allow(dead_code)
- Change trust score clamp upper bound from 1000.0 to 1.0 (trust scores are in range [0.0, 1.0])
- Remove #[allow(dead_code)] attribute from avg_trust_score field as it's now actively used
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>1 parent ecbb4bb commit 5eea4b9
3 files changed
Lines changed: 145 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
106 | 127 | | |
107 | 128 | | |
108 | 129 | | |
| |||
162 | 183 | | |
163 | 184 | | |
164 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
165 | 208 | | |
166 | 209 | | |
167 | 210 | | |
| |||
198 | 241 | | |
199 | 242 | | |
200 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
201 | 252 | | |
202 | 253 | | |
203 | 254 | | |
| |||
220 | 271 | | |
221 | 272 | | |
222 | 273 | | |
223 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
224 | 283 | | |
225 | 284 | | |
226 | 285 | | |
227 | 286 | | |
228 | 287 | | |
229 | 288 | | |
| 289 | + | |
| 290 | + | |
230 | 291 | | |
231 | 292 | | |
232 | 293 | | |
233 | 294 | | |
234 | 295 | | |
235 | 296 | | |
| 297 | + | |
| 298 | + | |
236 | 299 | | |
237 | 300 | | |
238 | 301 | | |
| |||
270 | 333 | | |
271 | 334 | | |
272 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
273 | 382 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
587 | 591 | | |
588 | 592 | | |
589 | 593 | | |
| |||
623 | 627 | | |
624 | 628 | | |
625 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
626 | 634 | | |
627 | 635 | | |
628 | 636 | | |
| |||
653 | 661 | | |
654 | 662 | | |
655 | 663 | | |
| 664 | + | |
656 | 665 | | |
657 | 666 | | |
658 | 667 | | |
| |||
670 | 679 | | |
671 | 680 | | |
672 | 681 | | |
| 682 | + | |
673 | 683 | | |
674 | 684 | | |
675 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
| |||
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
| 219 | + | |
| 220 | + | |
211 | 221 | | |
212 | 222 | | |
213 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
217 | | - | |
| 231 | + | |
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
224 | 247 | | |
225 | 248 | | |
226 | 249 | | |
| |||
0 commit comments