Skip to content

Commit

Permalink
feat(config): Export OpenTelemetry SDK to allow access in server - Im…
Browse files Browse the repository at this point in the history
…prove modularity.
  • Loading branch information
lui7henrique committed Oct 14, 2024
1 parent 635eb3a commit 58e4a1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/config/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -14,5 +14,3 @@ const sdk = new opentelemetry.NodeSDK({
}),
],
})

sdk.start()
2 changes: 2 additions & 0 deletions src/http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -119,6 +120,7 @@ app.setErrorHandler((error, _, reply) => {
return reply.status(500).send({ message: 'Internal server error.' })
})

sdk.start()
app
.listen({
port: env.PORT,
Expand Down

0 comments on commit 58e4a1c

Please sign in to comment.