Commit 34651ad
authored
feat(adapter): expose keyviz heatmap via AdminServer.GetKeyVizMatrix (#646)
## Summary
- Implements `AdminServer.GetKeyVizMatrix` against the proto declared in
`proto/admin.proto` (already generated; no proto edits).
- New narrow `KeyVizSampler` interface in the adapter package (just
`Snapshot(from, to time.Time) []keyviz.MatrixColumn`), so production
wires `*keyviz.MemSampler` while tests pass an in-memory fake.
- `AdminServer.RegisterSampler` mirrors `RegisterGroup`. Without it,
`GetKeyVizMatrix` returns `codes.Unavailable` so callers can distinguish
"keyviz disabled on this node" from "no data yet" (which is a successful
empty response).
- Pivots the column-major `MatrixColumn` slice into the row-major proto
layout: one `KeyVizRow` per `RouteID` with values aligned to a parallel
`column_unix_ms` slice. `KeyVizSeries` selection picks the matching
per-row counter; `UNSPECIFIED` defaults to `Reads`.
- `bucket_id` encodes `route:<id>` for individual slots and
`virtual:<syntheticID>` for aggregate buckets. Aggregate rows carry
`MemberRoutes` verbatim through `route_ids` and `route_count`.
Implements the read-side half of
`docs/admin_ui_key_visualizer_design.md` §5.2 / §6. The dispatch-side
`Observe` wiring is in #645.
## Test plan
- [x] `TestGetKeyVizMatrixReturnsUnavailableWhenSamplerNotRegistered` —
verifies `codes.Unavailable` when no sampler registered.
- [x] `TestGetKeyVizMatrixPivotsColumnsToRows` — two-column / two-route
fixture, verifies the missing-row-becomes-zero contract.
- [x] `TestGetKeyVizMatrixSeriesSelection` — table-driven across all
five enum values including `UNSPECIFIED` defaulting to `Reads`.
- [x] `TestGetKeyVizMatrixEncodesAggregateBucket` — virtual bucket
layout (`bucket_id` prefix, `aggregate=true`, `route_ids`,
`route_count`).
- [x] `go test -race -count=1 -run TestGetKeyVizMatrix ./adapter/...`
clean.
- [x] `golangci-lint run ./adapter/...` clean.4 files changed
Lines changed: 208 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
539 | 556 | | |
540 | 557 | | |
541 | 558 | | |
| |||
549 | 566 | | |
550 | 567 | | |
551 | 568 | | |
552 | | - | |
553 | | - | |
554 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
555 | 573 | | |
556 | 574 | | |
557 | | - | |
558 | | - | |
| 575 | + | |
| 576 | + | |
559 | 577 | | |
560 | 578 | | |
561 | 579 | | |
562 | 580 | | |
563 | | - | |
564 | | - | |
| 581 | + | |
| 582 | + | |
565 | 583 | | |
566 | | - | |
| 584 | + | |
567 | 585 | | |
568 | 586 | | |
569 | 587 | | |
| |||
608 | 626 | | |
609 | 627 | | |
610 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
611 | 637 | | |
612 | 638 | | |
613 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
217 | 246 | | |
218 | 247 | | |
219 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
242 | 247 | | |
243 | 248 | | |
244 | 249 | | |
| |||
463 | 468 | | |
464 | 469 | | |
465 | 470 | | |
466 | | - | |
467 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
468 | 474 | | |
469 | 475 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 476 | + | |
476 | 477 | | |
477 | 478 | | |
478 | 479 | | |
| |||
486 | 487 | | |
487 | 488 | | |
488 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
489 | 515 | | |
490 | 516 | | |
491 | 517 | | |
| |||
727 | 753 | | |
728 | 754 | | |
729 | 755 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
736 | 763 | | |
737 | 764 | | |
738 | 765 | | |
| |||
746 | 773 | | |
747 | 774 | | |
748 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
749 | 785 | | |
750 | 786 | | |
751 | 787 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
919 | 1007 | | |
920 | 1008 | | |
921 | 1009 | | |
| |||
0 commit comments