-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathappInsightsClient.js
More file actions
31 lines (27 loc) · 945 Bytes
/
appInsightsClient.js
File metadata and controls
31 lines (27 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// appInsightsClient.js
const appInsights = require("applicationinsights");
let insightsClient = null;
if (
process.env.NODE_ENV === "production" &&
process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
) {
appInsights
.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING)
.setDistributedTracingMode(appInsights.DistributedTracingModes.AI_AND_W3C)
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true, true)
.setUseDiskRetryCaching(true)
.setSendLiveMetrics(false)
.start();
insightsClient = appInsights.defaultClient;
console.log("✅ Application Insights initialized in production mode");
} else {
console.log(
"⚠️ Application Insights disabled (not in production or missing connection string)"
);
}
module.exports = insightsClient;