From a4f164e5c60f83fba5da491ec21463ad913ba3ee Mon Sep 17 00:00:00 2001 From: Qing Tomlinson Date: Tue, 24 Mar 2026 21:41:58 -0600 Subject: [PATCH] fix(logging): prevent duplicate Application Insights traces Problem: Duplicate trace rows were appearing in Application Insights for the same log event, often with different customProperties payloads. Root cause: Two telemetry paths were active at the same time: - Explicit trace emission through the custom Winston to Application Insights transport. - SDK auto-collection of logger/console output. This caused the same logical log to be ingested twice with different property envelopes. Fix: Disable SDK console/logger auto-collection explicitly with setAutoCollectConsole(false, false), keeping a single, intentional telemetry path through the custom transport. --- providers/logging/insights.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/providers/logging/insights.js b/providers/logging/insights.js index 68e4f9f0..cbf4728b 100644 --- a/providers/logging/insights.js +++ b/providers/logging/insights.js @@ -48,7 +48,14 @@ class Insights { if (!connectionString || connectionString === 'mock') { _client = new Insights(tattoos, null, echo) } else { - appInsights.setup(connectionString).setAutoCollectPerformance(false).setAutoCollectDependencies(false).start() + appInsights + .setup(connectionString) + .setAutoCollectPerformance(false) + .setAutoCollectDependencies(false) + // We emit telemetry via our custom Winston transport; disable console auto-collection + // to avoid duplicate traces with a reduced customProperties envelope. + .setAutoCollectConsole(false, false) + .start() _client = new Insights(tattoos, appInsights.defaultClient, echo) } }