feat(logging): add trace ID propagation via AsyncLocalStorage

- add TraceInterceptor that reads x-trace-id header or generates a UUID
- add AsyncLocalStorage store in common/trace-context for request-scoped trace ID
- replace NestJS Logger with TraceLogger (extends ConsoleLogger) that injects trace ID into log context
- register TraceInterceptor globally before LoggingInterceptor
- move HealthController into HealthModule so global interceptors apply to /healthz
- omit body/response from log lines when empty or null
This commit is contained in:
2026-04-08 12:20:06 +03:00
parent 7f5a2bfe18
commit 6fd991811f
12 changed files with 72 additions and 19 deletions
+2 -2
View File
@@ -2,9 +2,9 @@ import {
Injectable,
BadRequestException,
InternalServerErrorException,
Logger,
NotFoundException,
} from '@nestjs/common';
import { TraceLogger } from '../common/trace-logger';
import { ConfigService } from '@nestjs/config';
import { chromium } from 'playwright';
import * as fs from 'fs';
@@ -21,7 +21,7 @@ interface KeyDescriptor {
@Injectable()
export class AuthService {
private readonly logger = new Logger(AuthService.name);
private readonly logger = new TraceLogger(AuthService.name);
private readonly keysDir: string;
constructor(