metrics: extract boolGauge to simplify RecordInventory (issue #9) #11
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "wt/t_f1593f8c"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #9 ([hermes] soteria: go:S3776).
RecordInventory in
internal/server/metrics.goexceeded the SonarQube cognitive-complexity threshold (16 > 15) because of thepvc.Healthyif/else that only chooses between gauge values 1 and 0. This PR replaces that branch with a small documentedboolGaugehelper, removing one decision point without changing any emitted metric.Behavior lock (RED → GREEN):
TestBoolGaugeMapsHealthToPrometheusValuesandTestTelemetryRecordInventoryHealthGaugeIdentityassert the renderedpvc_backup_healthgauge stays exactly1for healthy and0for unhealthy PVCs with unchanged metric name and labels. The tests failed to build before the refactor (undefinedboolGauge) and pass after.Validation:
go test -race ./...— all packages passbash scripts/check.sh— gofmt, doc/structure/LOC/code-smell/UI hygiene,go vet, unit tests + coverage hygiene all pass (total coverage 96.20%)Started from exact main head 47205db5b2e8041bac6a06a78f94fd3662134fc8; only
internal/server/metrics.goandinternal/server/metrics_test.gochanged.🤖 Generated with Claude Code
Checkout
From your project repository, check out a new branch and test the changes.