fix: address Code Reviewer findings for Datadog/Sentry integration FRE-4806

P1: Load dd-trace before other modules via datadog-init.ts entry point
P1: Batch all CloudWatch metrics into single PutMetricDataCommand per request
P2: Deduplicate warning logs with else-if for high latency vs error
P3: Add response.ok check to Datadog log forwarding fetch
P3: Update getSentryHub() to use getCurrentScope() for Sentry SDK 8.x

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-05-10 16:02:18 -04:00
parent a653c77959
commit 31e0b39794
9 changed files with 168 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ export function initDatadogLogs() {
service,
});
await fetch(`${logIntakeUrl}/api/v2/logs`, {
const response = await fetch(`${logIntakeUrl}/api/v2/logs`, {
method: 'POST',
headers: {
'DD-API-KEY': process.env.DD_API_KEY!,
@@ -32,6 +32,12 @@ export function initDatadogLogs() {
},
body: payload,
});
if (!response.ok) {
console.warn(
`[Datadog Logs] HTTP ${response.status} response from intake API`,
await response.text()
);
}
} catch (err) {
console.warn('[Datadog Logs] Forward failed:', (err as Error).message);
}