mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(observability): Replace Prometheus package with OpenTelemetry
This commit is contained in:
parent
f67383b761
commit
6b1640b753
22 changed files with 2391 additions and 568 deletions
27
src/main.ts
27
src/main.ts
|
|
@ -1,11 +1,31 @@
|
|||
import { otelSDK } from "./open-telemetry/sdk"; // needs to be loaded first - always -
|
||||
import { ValidationPipe } from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { NestFactory } from "@nestjs/core";
|
||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||
import { context, trace } from "@opentelemetry/api";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import { RavenInterceptor } from "nest-raven";
|
||||
import Pino from "pino";
|
||||
import { AppModule } from "./app.module";
|
||||
import { Logger } from "nestjs-pino";
|
||||
|
||||
const logger = Pino({
|
||||
formatters: {
|
||||
log(object) {
|
||||
const span = trace.getSpan(context.active());
|
||||
if (!span) return { ...object };
|
||||
const { spanId, traceId } = trace
|
||||
.getSpan(context.active())
|
||||
?.spanContext();
|
||||
return { ...object, spanId, traceId };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
logger.log = logger.info;
|
||||
|
||||
function setupSentry(
|
||||
app: NestExpressApplication,
|
||||
|
|
@ -23,7 +43,12 @@ function setupSentry(
|
|||
}
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||
await otelSDK.start();
|
||||
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||
bufferLogs: true,
|
||||
});
|
||||
app.useLogger(app.get(Logger));
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
transform: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue