Skip to content

The only tool you need to know what is happening and how to fix it.

fix: stop reporting an AI-trace stats failure as 0ms latency (#320)

FrameAutomata16b796f3b4f5
diff --git a/backend/app/controllers/ai_trace.controller.go b/backend/app/controllers/ai_trace.controller.go
index e6ec8e40..f583fae2 100644
--- a/backend/app/controllers/ai_trace.controller.go
+++ b/backend/app/controllers/ai_trace.controller.go
@@ -2,6 +2,7 @@ package controllers
import (
"encoding/json"
+ "fmt"
"net/http"
"net/url"
"sync"
@@ -162,8 +163,11 @@ func (a aiTraceController) FindByTraceName(c *gin.Context) {
return
}
+ // Stats are best-effort: the trace list still renders without them, so a
+ // failure here is reported rather than aborting the request.
stats, err := telemetry.AiTraceRepository.GetTraceNameStats(c, projectId, traceName, request.FromDate, request.ToDate)
if err != nil {
+ traceway.CaptureException(fmt.Errorf("failed to load ai trace stats (traceName=%s): %w", traceName, err))
stats = nil
}
diff --git a/backend/app/repositories/telemetry/sqlite/ai_trace.repository.go b/backend/app/repositories/telemetry/sqlite/ai_trace.repository.go
index b03d5277..a03f7f88 100644
--- a/backend/app/repositories/telemetry/sqlite/ai_trace.repository.go
+++ b/backend/app/repositories/telemetry/sqlite/ai_trace.repository.go
@@ -429,7 +429,7 @@ func (r *aiTraceRepository) GetTraceNameStats(ctx context.Context, projectId uui
WHERE project_id = :project_id AND trace_name = :trace_name AND recorded_at >= :from AND recorded_at <= :to
ORDER BY duration ASC`, params)
if err != nil {
- return stats, nil
+ return nil, err
}
sortedDurations := make([]float64, len(durationRows))