Move app insights initialization earlier

This commit is contained in:
Andrew Branch
2021-06-21 09:21:30 -05:00
parent c8246edf65
commit d8123f9b3e

View File

@@ -8,6 +8,11 @@ import full from "./full";
import { getFunctionTimeoutSeconds, lockFilePath } from "./lib/settings";
export default function main() {
if (process.env.APPINSIGHTS_INSTRUMENTATIONKEY) {
applicationinsights.setup().start();
console.log("Done initialising App Insights");
}
return withFileLock(lockFilePath, async () => {
const githubAccessToken = await getSecret(Secret.GITHUB_ACCESS_TOKEN);
const dry = !!(yargs.argv.dry || process.env.WEBHOOK_FORCE_DRY);
@@ -16,10 +21,6 @@ export default function main() {
console.log("The environment variable GITHUB_ACCESS_TOKEN must be set.");
} else {
console.log(`=== ${dry ? "DRY" : "PRODUCTION"} RUN ===`);
if (process.env.APPINSIGHTS_INSTRUMENTATIONKEY) {
applicationinsights.setup().start();
console.log("Done initialising App Insights");
}
const fetcher = new Fetcher();
const log = loggerWithErrors()[0];
log.info("");