feat(#131): add OpenTelemetry tracing infrastructure
Implement comprehensive distributed tracing for HTTP requests and LLM operations using OpenTelemetry with GenAI semantic conventions. Features: - TelemetryService: SDK initialization with OTLP HTTP exporter - TelemetryInterceptor: Automatic HTTP request spans - @TraceLlmCall decorator: LLM operation tracing - GenAI semantic conventions for model/token tracking - Graceful degradation when tracing disabled Instrumented: - All HTTP requests (automatic spans) - OllamaProvider chat/chatStream/embed operations - Token counts, model names, durations Environment: - OTEL_ENABLED (default: true) - OTEL_SERVICE_NAME (default: mosaic-api) - OTEL_EXPORTER_OTLP_ENDPOINT (default: localhost:4318) Tests: 23 passing with full coverage Fixes #131 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
23
apps/api/src/telemetry/telemetry.module.ts
Normal file
23
apps/api/src/telemetry/telemetry.module.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Module, Global } from "@nestjs/common";
|
||||
import { TelemetryService } from "./telemetry.service";
|
||||
import { TelemetryInterceptor } from "./telemetry.interceptor";
|
||||
import { SpanContextService } from "./span-context.service";
|
||||
|
||||
/**
|
||||
* Global module providing OpenTelemetry distributed tracing.
|
||||
* Automatically instruments HTTP requests and provides utilities for LLM tracing.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* @Module({
|
||||
* imports: [TelemetryModule],
|
||||
* })
|
||||
* export class AppModule {}
|
||||
* ```
|
||||
*/
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [TelemetryService, TelemetryInterceptor, SpanContextService],
|
||||
exports: [TelemetryService, TelemetryInterceptor, SpanContextService],
|
||||
})
|
||||
export class TelemetryModule {}
|
||||
Reference in New Issue
Block a user