Skip to content

feat: complete OpenTelemetry distributed tracing integration#84

Merged
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
prismn:feat/issue-75-opentelemetry-distributed-tracing
Jun 24, 2026
Merged

feat: complete OpenTelemetry distributed tracing integration#84
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
prismn:feat/issue-75-opentelemetry-distributed-tracing

Conversation

@prismn

@prismn prismn commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the OpenTelemetry distributed tracing implementation across all services as specified in issue #75.

Implementation Details

src/config/tracing.ts

  • Added Jaeger exporter alongside the existing OTLP exporter (activated via JAEGER_AGENT_HOST or JAEGER_ENDPOINT env vars — falls back to OTLP-native Jaeger 1.41+)
  • Added W3CTraceContextPropagator so trace context propagates correctly across service boundaries via traceparent/tracestate HTTP headers
  • Added extractContext and injectContext helpers for explicit context propagation at service boundaries
  • Replaced deprecated spanProcessor with spanProcessors array to support multiple exporters
  • Guarded shutdownTracing against being called before SDK is started

src/observability/tracing.interceptor.ts (new)

  • TracingInterceptor — NestJS interceptor that wraps every HTTP handler in a named OTel span
  • Extracts upstream trace context from incoming headers (distributed tracing across microservices)
  • Records http.method, http.url, http.route, handler.class, handler.method, and http.status_code
  • Records exceptions and sets ERROR span status on failures

src/observability/observability.module.ts

  • Registers TracingInterceptor globally via APP_INTERCEPTOR so 100% of HTTP endpoints are traced

src/dashboard/websocket/dashboard.gateway.ts

  • Adds OTel spans for WebSocket connect and disconnect events with client ID, namespace, and trace context attributes

Auto-instrumentation coverage (via @opentelemetry/auto-instrumentations-node)

  • Database queries — TypeORM/pg instrumented with timing metrics by the HTTP auto-instrumentation
  • External AI provider / HTTP calls — all outgoing HTTP requests instrumented automatically
  • HTTP servers — incoming request headers (x-request-id, x-correlation-id) captured in span attributes

Validation Results

  • npm run build — compiled successfully (webpack)
  • ⚠️ npm test — pre-existing RangeError: Maximum call stack size exceeded in @nestjs/core injector; not introduced by this change (confirmed identical failure on upstream main before changes)

Closes #75

…XL#75)

- Add Jaeger exporter alongside OTLP with env-based configuration
- Add W3CTraceContextPropagator for trace context propagation across services
- Add TracingInterceptor that wraps every HTTP handler in a named span
  with request metadata, handler class/method, upstream context extraction
- Instrument WebSocket gateway (connect/disconnect) with tracing spans
- Register TracingInterceptor globally via APP_INTERCEPTOR in ObservabilityModule
- Export extractContext/injectContext helpers for service-boundary propagation
- Auto-instrumentations cover DB queries and external HTTP/AI provider calls

Closes SourceXXL#75
@memplethee-lab memplethee-lab merged commit c8ae13d into SourceXXL:main Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenTelemetry Distributed Tracing Complete Implementation

2 participants