homelab: v0.6.0 — usage telemetry (usage top), evidence-driven verb prioritization
Answers the question that drove the whole CLI — which verbs to add next — with
data instead of one maintainer's habits, and resolves the cross-user-usage ask
in-bounds (no reading anyone's home).
- emit on dispatch: every verb fire-and-forgets one Loki line {job,user,verb} +
"exit=N ver=X". ONLY the verb path + exit code — never args, paths, flags, or
secrets (the emit never sees arguments). Best-effort: 800ms timeout, errors
swallowed, never affects the command; opt-out HOMELAB_TELEMETRY=0. Discovery
verbs (manifest/version/help) and usage itself don't self-record.
- usage top [--since 30d] [--user U] [--json]: ranks verbs via
sum by (verb)(count_over_time({job="homelab-usage"}[…])) against the shared
Loki. Cross-user analytics WITHOUT touching ~/.claude — the privacy-preserving
answer to "what does the team use".
- Loki sink (zero new infra, dogfoods v0.5 logs path); push verified HTTP 204 no
auth. ADR docs/adr/0011.
Live-verified: ran 4 verbs, usage top ranked them correctly (metrics query=2).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
666fefd22b
commit
3e3fdb34f0
9 changed files with 215 additions and 4 deletions
18
cli/usage_test.go
Normal file
18
cli/usage_test.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUsageQuery(t *testing.T) {
|
||||
got := usageQuery("30d", "")
|
||||
want := `sum by (verb) (count_over_time({job="homelab-usage"}[30d]))`
|
||||
if got != want {
|
||||
t.Errorf("usageQuery(30d,\"\") = %q, want %q", got, want)
|
||||
}
|
||||
withUser := usageQuery("7d", "emo")
|
||||
if !strings.Contains(withUser, `user="emo"`) || !strings.Contains(withUser, "[7d]") {
|
||||
t.Errorf("usageQuery with user missing filter/range: %q", withUser)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue