all the changes
Build and Publish / Metadata (push) Successful in 2s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m23s

This commit is contained in:
mats committed 2026-09-19 23:25:59 +02:00
1 parent 94f30165f9
commit f30adf05af
35 files changed
+2979 -1607

No files matched your search

+41
View File
@@ -392,6 +392,47 @@ func TestHandleIssuesAndByID(t *testing.T) {
}
}
func TestIssueTrendsUseTelemetryTimestamps(t *testing.T) {
coll := New(noopBroadcaster{}, 10, nil)
base := time.Date(2026, 9, 19, 10, 0, 0, 0, time.UTC)
ld := plog.NewLogs()
rl := ld.ResourceLogs().AppendEmpty()
rl.Resource().Attributes().PutStr("service.name", "api")
records := rl.ScopeLogs().AppendEmpty().LogRecords()
first := records.AppendEmpty()
first.SetTimestamp(pcommon.NewTimestampFromTime(base))
first.SetSeverityNumber(plog.SeverityNumberError)
first.Body().SetStr("first failure")
second := records.AppendEmpty()
second.SetTimestamp(pcommon.NewTimestampFromTime(base.Add(time.Hour)))
second.SetSeverityNumber(plog.SeverityNumberError)
second.Body().SetStr("second failure")
if err := coll.ConsumeLogs(context.Background(), ld); err != nil {
t.Fatalf("ConsumeLogs failed: %v", err)
}
list := coll.ListIssues(0)
if len(list) != 2 {
t.Fatalf("expected two issues, got %d", len(list))
}
for _, issue := range list {
if len(issue.Trend) != 1 {
t.Fatalf("expected one trend bucket for %q, got %+v", issue.Title, issue.Trend)
}
}
expected := map[string]string{
"first failure": issues.HourBucket(base.UnixNano()),
"second failure": issues.HourBucket(base.Add(time.Hour).UnixNano()),
}
for _, issue := range list {
if _, ok := issue.Trend[expected[issue.Title]]; !ok {
t.Fatalf("telemetry timestamp was not used for %q: %+v", issue.Title, issue.Trend)
}
}
}
func TestHandleMLDetectorTest(t *testing.T) {
coll := New(nil, 10, nil)
req := httptest.NewRequest(http.MethodPost, "/api/ml/test-spike", nil)