dependencies Legend  Declarations  Module  Bootstrap  Providers  Exports cluster_CoreModule cluster_CoreModule_imports cluster_CoreModule_exports cluster_CoreModule_providers HealthModule HealthModule CoreModule CoreModule HealthModule->CoreModule HealthModule HealthModule CoreModule->HealthModule TraceIdInterceptor TraceIdInterceptor TraceIdInterceptor->CoreModule

File

src/core/core.module.ts

Description

Core Module - Platform infrastructure and observability

Responsibilities:

  • Service information endpoint
  • Health checks
  • OpenTelemetry metrics and tracing (via nestjs-otel)
  • Trace ID propagation to HTTP response headers (X-Trace-Id)

Tracing:

  • HTTP spans are automatically created by @opentelemetry/instrumentation-http
  • Use @Span() decorator from nestjs-otel for business logic spans
  • Use @Traceable() class decorator to trace all methods of a service
  • X-Trace-Id header is added to all responses for client-side debugging

Providers

Controllers

Imports

Exports

import { Module } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { OpenTelemetryModule } from "nestjs-otel";
import { AppController } from "./app/app.controller";
import { HealthModule } from "./health/health.module";
import { TraceIdInterceptor } from "./interceptors/trace-id.interceptor";

/**
 * Core Module - Platform infrastructure and observability
 *
 * Responsibilities:
 * - Service information endpoint
 * - Health checks
 * - OpenTelemetry metrics and tracing (via nestjs-otel)
 * - Trace ID propagation to HTTP response headers (X-Trace-Id)
 *
 * Tracing:
 * - HTTP spans are automatically created by @opentelemetry/instrumentation-http
 * - Use @Span() decorator from nestjs-otel for business logic spans
 * - Use @Traceable() class decorator to trace all methods of a service
 * - X-Trace-Id header is added to all responses for client-side debugging
 */
@Module({
    imports: [
        HealthModule,
        OpenTelemetryModule.forRoot({
            metrics: {
                hostMetrics: true,
            },
        }),
    ],
    controllers: [AppController],
    providers: [
        {
            provide: APP_INTERCEPTOR,
            useClass: TraceIdInterceptor,
        },
    ],
    exports: [HealthModule],
})
export class CoreModule {}

results matching ""

    No results matching ""