File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040 "@nestjs/config" : " ^4.0.2" ,
4141 "@nestjs/core" : " ^11.0.1" ,
4242 "@nestjs/platform-express" : " ^11.0.1" ,
43+ "@nestjs/schedule" : " ^5.0.1" ,
44+ "@opentelemetry/auto-instrumentations-node" : " ^0.70.1" ,
45+ "@opentelemetry/instrumentation-nestjs-core" : " ^0.58.0" ,
46+ "@opentelemetry/sdk-metrics" : " ^2.5.1" ,
47+ "@opentelemetry/sdk-node" : " ^0.212.0" ,
48+ "@opentelemetry/sdk-trace-node" : " ^2.5.1" ,
4349 "@prisma/client" : " ^6.0.1" ,
4450 "@ts-rest/core" : " ^3.52.1" ,
4551 "@ts-rest/fastify" : " ^3.52.1" ,
Original file line number Diff line number Diff line change 1+ import { NodeSDK } from '@opentelemetry/sdk-node'
2+ import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node'
3+ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
4+ import {
5+ PeriodicExportingMetricReader ,
6+ ConsoleMetricExporter ,
7+ } from '@opentelemetry/sdk-metrics'
8+ import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core'
9+
10+ function createSdk ( ) {
11+ return new NodeSDK ( {
12+ traceExporter : new ConsoleSpanExporter ( ) ,
13+ metricReader : new PeriodicExportingMetricReader ( {
14+ exporter : new ConsoleMetricExporter ( ) ,
15+ } ) ,
16+ instrumentations : [ getNodeAutoInstrumentations ( ) , new NestInstrumentation ( ) ] ,
17+ } )
18+ }
19+
20+ export function instrument ( ) {
21+ const sdk = createSdk ( )
22+ sdk . start ( )
23+ process . on ( 'SIGTERM' , ( ) => {
24+ sdk . shutdown ( )
25+ } )
26+ }
Original file line number Diff line number Diff line change 11import { NestFactory } from '@nestjs/core'
22import { Logger } from 'nestjs-pino'
3-
3+ import { instrument } from './instrumentation'
44import { MainModule } from './main.module'
55
66async function bootstrap ( ) {
@@ -9,4 +9,6 @@ async function bootstrap() {
99 app . flushLogs ( )
1010 await app . listen ( process . env . PORT ?? 0 )
1111}
12+
13+ instrument ( )
1214bootstrap ( )
You can’t perform that action at this time.
0 commit comments