Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private static startup(): void {
if (!this._hasStarted) {
AppInsights.setup(INSTRUMENTATION_KEY)
// turn off extra instrumentation
.setAutoCollectConsole(false)
.setAutoCollectDependencies(false)
.setAutoCollectExceptions(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
// Fix for zonejs / restify conflict (https://github.com/Microsoft/ApplicationInsights-node.js/issues/460)
.setAutoDependencyCorrelation(false);
// do not collect the user's machine name
AppInsights.defaultClient.context.tags[AppInsights.defaultClient.context.keys.cloudRoleInstance] = '';
AppInsights.start();
this._client = AppInsights.defaultClient;
this._hasStarted = true;
}
}
}
function setup() {
if (appinsightsInstrumentationkey) {
const appInsights = require('applicationinsights');
appInsights.setup(appinsightsInstrumentationkey);
appInsights.start();
client = appInsights.getClient(appinsightsInstrumentationkey);
console.log = trackTrace(TRACE_LEVEL_INFO, consoleLog);
console.warn = trackTrace(TRACE_LEVEL_WARNING, consoleWarn);
console.error = trackTrace(TRACE_LEVEL_ERROR, consoleError);
}
}