ApplicationInsights-node.js: [BUG] Correlation context missing from trackTrace
Description/Screenshot
When running Application Insights locally trackTrace
works fine and appInsights.getCorrelationContext()
returns a context. However once the app is deployed on Azure the trackTrace
will store TRACEs without operationId and appInsights.getCorrelationContext()
returns null. This makes it difficult/impossible to correlate the traces with the operations in the performance view on Azure dashboard.
Running node locally on Windows:
Running node on Azure in Linux:
Note the “0 Traces” because they are not associated with the operation, because the operationId is missing
The trace is actually stored (without operationId):
Steps to Reproduce
- OS/Browser: Azure App Service running on Linux (Node - 16-lts)
- SDK Version [e.g. 22]: 2.4.0
- How you initialized the SDK:
const appInsights = require('applicationinsights');
appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING).start();
const appInsightsClient = appInsights.defaultClient;
Expected behavior
The behavior locally should match the behavior on Azure.
Additional context
Is the initialization different because the architecture is different? Have tried setting different configurations, but can’t seem to find the root cause of this.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (2 by maintainers)
I found a workaround: if you don’t enable AI in the Azure App Service and only initialize it from code (with the AI connection string) then everything is logged and correlated correctly.
I tried the other way too: enable AI in App Service but don’t call start() in the code. It works correctly.
appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING);
So the issue is connected to the double initialization somehow. (once enabled/started on App Service and once from code).