From d288a4f357bebfa49b0a1dc430f0cacb781ebbc2 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Thu, 7 Jul 2022 18:18:53 -0300 Subject: [PATCH] FIX: conditionally importing apm --- src/apm.ts | 5 +++++ src/main.ts | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/apm.ts diff --git a/src/apm.ts b/src/apm.ts new file mode 100644 index 0000000..8c20720 --- /dev/null +++ b/src/apm.ts @@ -0,0 +1,5 @@ +export const startAPm = async () => { + if (process.env.ENV !== 'local') + return await import('elastic-apm-node/start'); +}; +startAPm(); diff --git a/src/main.ts b/src/main.ts index c0505ac..33c5e54 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ +import './apm'; import { NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { writeFileSync } from 'fs'; import helmet from 'helmet'; import { DadosferaLogger } from 'dadosfera-logs'; @@ -9,8 +9,6 @@ import documentEmpty from '../swagger_empty.json'; import { AppModule } from './app.module'; async function bootstrap() { - if (process.env.ENV !== 'local') await import('elastic-apm-node/start'); - DadosferaLogger.setupLogger({ serviceName: 'maestro', serviceEnvironment: process.env.ENV,