diff --git a/lib/renovate.ts b/lib/renovate.ts index f7bed3cf460..6571e5079ec 100644 --- a/lib/renovate.ts +++ b/lib/renovate.ts @@ -4,18 +4,19 @@ import 'source-map-support/register.js'; import './punycode.cjs'; void (async (): Promise => { + // ⚠️ Don't add code before this! + // This has to be imported before logger and other libraries which are instrumented. + const otel = await import('./instrumentation/index.ts'); + otel.init(); + (await import('./proxy.ts')).bootstrap(); + // prints and exits the process if --version or --help is passed const { parseEarlyFlags } = await import('./workers/global/config/parse/cli.ts'); parseEarlyFlags(); - // has to be imported before logger and other libraries which are instrumentalised - const otel = await import('./instrumentation/index.ts'); - otel.init(); - (await import('./proxy.ts')).bootstrap(); - const logger = await import('./logger/index.ts'); - /* v8 ignore next 3 -- not easily testable */ + /* v8 ignore next -- not easily testable */ process.on('unhandledRejection', (err) => { logger.logger.error({ err }, 'unhandledRejection'); }); @@ -25,7 +26,7 @@ void (async (): Promise => { process.exitCode = await otel.instrument('run', start); await otel.shutdown(); //gracefully shutdown OpenTelemetry - /* v8 ignore next 3 -- no test required */ + /* v8 ignore if -- no test required */ if (process.env.RENOVATE_X_HARD_EXIT) { process.exit(process.exitCode); }