NestJS Project Guide
Complete instrumentation approach for NestJS APIs and microservices
Use this guide for NestJS backends where request lifecycle, dependency injection, and module boundaries must remain observable.
Architecture Scope
- HTTP controllers and middleware chain.
- Service/provider calls.
- Outbound HTTP/DB/queue operations.
Setup
Initialize the Node SDK before the NestJS app starts listening:
The Node SDK auto-instruments all inbound HTTP requests, outbound fetch() calls, and console output. No NestJS-specific middleware or interceptor is needed for basic telemetry.
For business-specific telemetry, use the SDK instance:
Environment Variables
Validation Checklist
- 4xx/5xx errors include trace context
- All HTTP endpoints produce spans automatically
- Console output appears as structured logs
- Startup/shutdown hooks flush telemetry correctly
Production Hardening
- Call
ob.shutdown()in the NestJSonApplicationShutdownlifecycle hook. - Bound queue and retry configuration.
- Validate after module refactors.
Troubleshooting
- No events after deploy: verify
initNodeSDKruns beforeNestFactory.create. - Missing spans in async handlers: confirm context propagation.
- High noise: reduce low-value event emission.