diff --git a/src/config/instrumentation.ts b/src/config/instrumentation.ts index 2813c28..da47a4b 100644 --- a/src/config/instrumentation.ts +++ b/src/config/instrumentation.ts @@ -2,7 +2,7 @@ import opentelemetry from '@opentelemetry/sdk-node' import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http' import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node' -const sdk = new opentelemetry.NodeSDK({ +export const sdk = new opentelemetry.NodeSDK({ traceExporter: new OTLPTraceExporter(), instrumentations: [ getNodeAutoInstrumentations({ @@ -14,5 +14,3 @@ const sdk = new opentelemetry.NodeSDK({ }), ], }) - -sdk.start() diff --git a/src/http/server.ts b/src/http/server.ts index 1b46262..07345bc 100644 --- a/src/http/server.ts +++ b/src/http/server.ts @@ -26,6 +26,7 @@ import { loginRoute } from './routes/login' import { registerEventRoute } from './routes/register-event' import { registerHostRoute } from './routes/register-host' import { registerSubscriptionRoute } from './routes/register-subscription' +import { sdk } from '@/config/instrumentation' const app = fastify() @@ -119,6 +120,7 @@ app.setErrorHandler((error, _, reply) => { return reply.status(500).send({ message: 'Internal server error.' }) }) +sdk.start() app .listen({ port: env.PORT,