Fix span duplicates and metrics

Implements complete plan to resolve duplicate span_id issues and metric collection errors:
- Ensure edge handlers return proper Response objects to prevent double logging
- Update collect-metrics to use valid metric categories, fix system_alerts query, and adjust returns
- Apply detect-anomalies adjustments if needed and add defensive handling in wrapper
- Prepare ground for end-to-end verification of location-related fixes
This commit is contained in:
gpt-engineer-app[bot]
2025-11-12 04:57:54 +00:00
parent b6d1b99f2b
commit 5531376edf
3 changed files with 39 additions and 19 deletions

View File

@@ -474,11 +474,17 @@ const handler = async (req: Request, { supabase, span, requestId }: EdgeFunction
addSpanEvent(span, 'anomaly_detection_complete', { detected: anomaliesDetected.length });
return {
success: true,
anomalies_detected: anomaliesDetected.length,
anomalies: anomaliesDetected,
};
return new Response(
JSON.stringify({
success: true,
anomalies_detected: anomaliesDetected.length,
anomalies: anomaliesDetected,
}),
{
status: 200,
headers: { 'Content-Type': 'application/json' },
}
);
};
serve(createEdgeFunction({