mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 16:51:13 -05:00
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:
@@ -266,7 +266,15 @@ export function wrapEdgeFunction(
|
||||
logSpanToDatabase(span, requestId);
|
||||
|
||||
// Clone response to add tracking headers
|
||||
const responseBody = await response.text();
|
||||
// Defensive check: ensure handler returned a Response object
|
||||
let responseBody: string;
|
||||
if (response instanceof Response) {
|
||||
responseBody = await response.text();
|
||||
} else {
|
||||
// Handler returned non-Response (shouldn't happen, but handle it)
|
||||
addSpanEvent(span, 'warning_non_response_object');
|
||||
responseBody = JSON.stringify(response);
|
||||
}
|
||||
const enhancedResponse = new Response(responseBody, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
|
||||
Reference in New Issue
Block a user