Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as DiagChannelPublishers from "diagnostic-channel-publishers";
import * as DiagChannel from "diagnostic-channel";
export const IsInitialized = !process.env["APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL"];
if (IsInitialized) {
const publishers: typeof DiagChannelPublishers = require("diagnostic-channel-publishers");
const individualOptOuts = process.env["APPLICATION_INSIGHTS_NO_PATCH_MODULES"] || "";
const unpatchedModules = individualOptOuts.split(",");
const modules: {[key: string] : any} = {
bunyan: publishers.bunyan,
console: publishers.console,
mongodb: publishers.mongodb,
mongodbCore: publishers.mongodbCore,
mysql: publishers.mysql,
redis: publishers.redis,
pg: publishers.pg,
pgPool: publishers.pgPool,
winston: publishers.winston
};
for (const mod in modules) {
if (unpatchedModules.indexOf(mod) === -1) {
modules[mod].enable();
}
}
}
export function registerContextPreservation(cb: (cb: Function) => Function) {
if (!IsInitialized) {
return;
}