hanahmily opened a new pull request, #1172:
URL: https://github.com/apache/skywalking-banyandb/pull/1172

   ## Summary
   
   Refactor the lifecycle cycle-level metrics 
(`banyandb_lifecycle_cycles_total`, 
`banyandb_lifecycle_last_run_timestamp_seconds`, 
`banyandb_lifecycle_last_run_success`) to carry labels `(remote_node, 
remote_role, remote_tier, group)`, matching the form of the parallel 
`banyandb_lifecycle_migration_*` family emitted by the queue/pub lifecycle 
publisher. Drop `banyandb_lifecycle_self_identity_resolution_total`; its 
regression-detection role moves to the new labeled 
`cycles_total{remote_node!=""}` plus the existing receiver-side count of empty 
`remote_node` on lifecycle `banyandb_queue_sub_total_finished` series.
   
   ## Why
   
   The cycle-level metrics were pod-aggregates with no labels, so dashboards 
couldn't filter by group or by the (sender_node, sender_role, sender_tier) 
tuple. The new labels cross-reference the same tuple computed by `parseGroup` 
via `resolveSelfIdentity` and stamped onto the wire via `SetSelfNode`, so the 
cycle-level series and the wire-level stamps share the same source. The label 
form mirrors the per-message `banyandb_lifecycle_migration_*` family 
(file-sync: `banyand/queue/pub/chunked_sync.go:67-82`; batch-write: 
`banyand/queue/pub/batch.go:215, 271, 291-292, 421, 471-472, 488, 511, 520, 
532`); the two families describe different sides (sender vs destination) and 
share the same label form so dashboard matchers and regexes apply to both.
   
   ## Changes
   
   - **banyand/backup/lifecycle/service.go**: drop `selfIdentityResolution` 
field and `banyandb_lifecycle_self_identity_resolution_total` counter. Register 
`cyclesTotal` / `lastRunTimestamp` / `lastRunSuccess` with `cycleLabels := 
[]string{remote_node, remote_role, remote_tier, group}`. Add 
`recordCycleGroup(group, senderNode, senderRole, senderTier)` — Inc 
`cyclesTotal` per group with the (group, remote_*) tuple, capture the cycle's 
last-seen tuple. Add `recordLastRun` — Set both `lastRunTimestamp` and 
`lastRunSuccess` with the cycle's last-seen tuple (or empty labels on the 
empty-cycle path), first calling `Delete` on the previously-emitted tuple 
(`emittedLastRun{Group,Node,Role,Tier}` tracking + `emittedLastRunSet` bool for 
the empty-tuple predecessor edge case) so each cycle fully replaces the 
previous cycle's series. `action()` resets the captured tuple to empty strings 
at the start so scheduler-driven consecutive cycles don't see stale labels.
   
   - **banyand/backup/lifecycle/steps.go**: `parseGroup` now returns the 
`(senderNode, senderRole, senderTier)` tuple alongside `*GroupConfig`; the 
`resolutionCounter` parameter is dropped. The tuple is the same one 
`parseGroup` feeds to `client.SetSelfNode` to populate the wire-level 
`SenderNode/Role/Tier`, so the cycle-level stamps and the wire-level stamps 
share the same source.
   
   - **banyand/backup/lifecycle/{steps,metrics}_test.go**: adjust to the new 
label set. New tests cover: `TestRecordCycleGroupStampsLabeledMetrics` (asserts 
`cyclesTotal` Inc'd, gauges NOT touched by `recordCycleGroup`), 
`TestRecordLastRunResetsTupleAtActionStart` (empty-cycle path), 
`TestRecordLastRunTwoCycleReplaceStaleSeries` (regression: cycle B must Delete 
cycle A's tuple), `TestRecordLastRunEmptyThenNonEmptyCycle` (regression: cycle 
B must Delete the all-empty tuple from a preceding empty cycle A).
   
   - **test/cases/lifecycle/lifecycle.go**: regexes at lines 261-268 require 
all four labels in the alphabetical order Prometheus emits them (`group`, 
`remote_node`, `remote_role`, `remote_tier`).
   
   - **docs/operation/grafana-fodc-workload.json**: add `group=~\"$group\"` 
matcher to the two lifecycle panel queries (lines 3494, 3558).
   
   - **CHANGES.md**: 0.11.0 entry describing the relabel and the removal of 
`banyandb_lifecycle_self_identity_resolution_total`.
   
   ## Breaking change
   
   Any alert/panel that pinned the unlabeld form (e.g. 
`banyandb_lifecycle_last_run_success == 1`) must update to the labeled form 
(`banyandb_lifecycle_last_run_success{group!=""}`).
   
   ## Test plan
   
   - [x] `make license-check`
   - [x] `make check-req`
   - [x] `make build`
   - [x] `make lint`
   - [x] `make check`
   - [x] `go test ./banyand/backup/lifecycle/... -count=1` (PASS, ~12s, 
includes 5 new tests)
   - [x] Codex critic round 5: APPROVED


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to