-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
37 lines (32 loc) · 1.35 KB
/
main.ts
File metadata and controls
37 lines (32 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* The require imports are needed because open telemetry needs to be loaded before the application gets bootstrapped.
*/
import otel = require('@zonneplan/open-telemetry-node');
import nest = require('@zonneplan/open-telemetry-nest');
import zonneplan = require('@zonneplan/open-telemetry-zonneplan');
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
import * as process from 'node:process';
import { LoggerFactory } from '@zonneplan/open-telemetry-zonneplan';
import { DiagLogLevel } from '@zonneplan/open-telemetry-node';
new otel.OpenTelemetryBuilder('nest-example')
.withTracing(zonneplan.DefaultTracingOptions)
.withLogging(zonneplan.DefaultLoggingOptions)
.withMetrics(zonneplan.DefaultMetricsOptions)
.withMetrics((options) =>
options.$if(process.env['NODE_ENV'] === 'development', (metricsOptions) =>
metricsOptions.withMetricReader(new nest.PrometheusNestExporter())
)
)
.withDiagLogging(DiagLogLevel.WARN)
.start();
async function bootstrap() {
const logger = new LoggerFactory().create('nest-app');
const app = await NestFactory.create(AppModule, { logger });
app.enableShutdownHooks();
const port = process.env['PORT'] || 4200;
await app.listen(port);
Logger.log(`🚀 Application is running on: http://localhost:${port}`);
}
bootstrap();