fix
Build and Publish / Metadata (push) Successful in 10s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 2m15s

This commit is contained in:
mats committed 2026-09-20 11:39:20 +02:00
1 parent 645f923175
commit 2cf2cebf5c
20 files changed
+481 -51

No files matched your search

+32
View File
@@ -75,3 +75,35 @@ func TestBuildLogicalRequestFeatures(t *testing.T) {
t.Fatalf("bot share wrong: %v", r.BotErrorShare)
}
}
func TestBuildLabelIgnoresBadActorNoise(t *testing.T) {
base := time.Date(2026, 9, 15, 12, 0, 0, 0, time.UTC)
var events []Event
mk := func(at time.Time, err bool, bad string) Event {
return Event{Timestamp: at, Service: "api", Kind: "span", IsError: err, BadActor: bad, PatternSignature: "p"}
}
// seven days of a quiet baseline, then a future window of pure bot errors
for d := 0; d <= 7; d++ {
day := base.AddDate(0, 0, d)
for i := 0; i < 50; i++ {
events = append(events, mk(day.Add(time.Duration(i)*time.Second), i == 0, ""))
}
}
target := base.AddDate(0, 0, 7)
for i := 0; i < 30; i++ {
events = append(events, mk(target.Add(6*time.Minute+time.Duration(i)*time.Second), true, BadActorBot))
}
rows := Build(events, Config{ObservedUntil: target.Add(time.Hour)})
var found bool
for _, r := range rows {
if r.WindowStart.Equal(target) && r.Service == "api" {
found = true
if !r.LabelKnown || !r.RawLabel || r.Label {
t.Fatalf("raw label should fire on bot errors and clean label must not: %+v", r)
}
}
}
if !found {
t.Fatal("target row missing")
}
}