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.
Recommended Setup
- Initialize SDK before app starts listening.
- Instrument request lifecycle (ingress -> handler -> response).
- Capture structured errors from global exception filters.
- Add spans around DB and external service calls.
Minimum Data Contract
- Stable service name per app/module domain.
- Environment and version tags in every event.
- Correlation ID propagation through async operations.
Validation Checklist
- 4xx/5xx errors include trace context.
- Slow endpoints produce spans with useful attributes.
- Startup/shutdown hooks flush telemetry correctly.
Production Hardening
- Bound queue and retry configuration.
- Add ingestion failure alerting.
- Validate after module refactors.
- Keep key rotation runbook documented.
Troubleshooting
- No events after deploy: verify bootstrap path still initializes SDK.
- Missing spans in async handlers: confirm context propagation.
- High noise: reduce low-value event emission.