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)
+16 -2
View File
@@ -37,7 +37,14 @@ func extractSpanErrors(tracker *issues.Tracker, td ptrace.Traces, timestamp int6
service := spanServiceName(rs.Resource(), span)
title := spanErrorTitle(span)
found = true
tracker.Record("span_error", service, title, spanSample(span, rs.Resource(), timestamp, title))
occurrenceTimestamp := span.StartTimestamp()
if occurrenceTimestamp == 0 {
occurrenceTimestamp = span.EndTimestamp()
}
if occurrenceTimestamp == 0 {
occurrenceTimestamp = pcommon.Timestamp(timestamp)
}
tracker.Record("span_error", service, title, spanSample(span, rs.Resource(), int64(occurrenceTimestamp), title))
}
}
}
@@ -102,7 +109,14 @@ func extractLogErrors(tracker *issues.Tracker, ld plog.Logs, timestamp int64) bo
title := logErrorTitle(record)
found = true
kind := "log_error"
sample := logSample(record, rl.Resource(), timestamp, title)
occurrenceTimestamp := record.Timestamp()
if occurrenceTimestamp == 0 {
occurrenceTimestamp = record.ObservedTimestamp()
}
if occurrenceTimestamp == 0 {
occurrenceTimestamp = pcommon.Timestamp(timestamp)
}
sample := logSample(record, rl.Resource(), int64(occurrenceTimestamp), title)
if attrString(record.Attributes(), "source") == "frontend" {
kind = "frontend_error"
sample.URL = attrString(record.Attributes(), "browser.url")