DEV.co
Open-Source Observability · pragmaticivan

nestjs-otel

nestjs-otel is an OpenTelemetry integration module for NestJS applications that streamlines observability setup by providing decorators and services for distributed tracing and metrics collection. It reduces boilerplate required to emit spans and metrics to backends like Jaeger, Prometheus, and Grafana.

Source: GitHub — github.com/pragmaticivan/nestjs-otel
789
GitHub stars
65
Forks
TypeScript
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorypragmaticivan/nestjs-otel
Ownerpragmaticivan
Primary languageTypeScript
LicenseApache-2.0 — OSI-approved
Stars789
Forks65
Open issues8
Latest releasev8.1.0 (2026-06-18)
Last updated2026-07-01
Sourcehttps://github.com/pragmaticivan/nestjs-otel

What nestjs-otel is

A TypeScript module that wraps OpenTelemetry SDK for Node.js, offering NestJS-idiomatic decorators (@Span, @Traceable, @CurrentSpan, @Baggage), interceptors (WideEventInterceptor for canonical log lines), and a TraceService for programmatic span management. Supports composite propagators and multiple exporter backends.

Quickstart

Get the nestjs-otel source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/pragmaticivan/nestjs-otel.gitcd nestjs-otel# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Distributed Tracing in Microservices

Track request flow across multiple NestJS services with automatic span propagation and context correlation using W3C Trace Context or Jaeger propagators.

Observability-First API Development

Instrument REST/GraphQL APIs with minimal code using @Span and @Traceable decorators to capture business logic execution and surface latency/errors to ops teams.

Prometheus Metrics + Grafana Dashboards

Emit host metrics and custom metrics to Prometheus exporter, then visualize via Grafana dashboards without manual instrumentation across handlers/services.

Implementation considerations

  • NodeSDK must be initialized before NestFactory.create() to capture early application startup traces; async startup adds complexity to bootstrap flow.
  • Peer dependencies (e.g., @opentelemetry/exporter-prometheus, @opentelemetry/exporter-jaeger) must be installed separately; unclear from data which versions are tested.
  • @Span and @Traceable decorators work well for service methods; @CurrentSpan only works in Controllers/Resolvers, not service-to-service calls—requires architectural awareness.
  • WideEventInterceptor pattern for canonical log lines requires filtering and aggregation logic downstream; ensures all request attributes are captured for debugging.
  • Propagator configuration (Jaeger, B3, W3C) must match downstream service expectations; misconfiguration breaks trace correlation across services.

When to avoid it — and what to weigh

  • Simple, Single-Service Applications — If running one monolithic NestJS app with no external service calls, the overhead of OTEL setup and span emission may not justify the observability gains.
  • Minimal Observability Requirements — Projects needing only basic logging (no distributed tracing or metrics) should use simpler logging libraries; OTEL adds complexity without return on investment.
  • No Backend Infrastructure for Exporters — If Jaeger, Prometheus, Loki, or Tempo instances are unavailable or unaffordable, spans and metrics will be dropped or buffered in-memory, creating overhead without utility.
  • Strict Latency Budgets — Span processing and batch export can introduce measurable latency in high-frequency operations; profiles should validate impact before production rollout.

License & commercial use

Licensed under Apache License 2.0 (Apache-2.0), a permissive OSI-approved license.

Apache-2.0 permits commercial use, modification, and distribution with proper attribution and disclaimer of warranty. No royalties required. Verify compliance with your organization's IP policy; if bundling into proprietary products, include license notice. No commercial support details provided in repository.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

Module itself does not handle authentication or encryption. Spans may contain sensitive data (user IDs, request payloads); downstream exporters must enforce network security and access controls. Jaeger and Prometheus exporters should be exposed only on internal networks, not public internet. Baggage decorator carries user/tenant context; validate propagator chain to prevent context leakage across trust boundaries.

Alternatives to consider

elastic-apm-node (Elastic APM)

Provides integrated APM backend with NestJS plugins; simpler all-in-one setup but vendor-locked to Elastic. Fewer customization hooks than OTEL.

winston + pinojs (logging only)

Simpler than full OTEL for applications needing only structured logs. Does not provide distributed tracing or metrics; insufficient for microservices observability.

DD APM (Datadog)

Proprietary SaaS APM with NestJS support. Higher cost but includes integrations, sampling rules, and ML-based alerting. Requires vendor lock-in.

Software development agency

Build on nestjs-otel with DEV.co software developers

nestjs-otel reduces observability boilerplate and integrates seamlessly with NestJS. Consult with our engineers to design your tracing and metrics strategy for microservices.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

nestjs-otel FAQ

Does nestjs-otel emit metrics or only traces?
Both. It supports tracing (spans) via Jaeger/OTLP and metrics (counters, histograms) via Prometheus exporter. Host metrics can be enabled in configuration.
Can I use this without a separate OTEL backend?
No. The module exports telemetry; you must configure and operate a backend (Jaeger, Prometheus, Loki, Tempo). In-memory buffering is possible but not recommended for production.
Does @Span work on async methods?
Yes. The decorator works with both sync and async methods; spans are automatically closed when the method completes or rejects.
How much latency does span emission add?
Unknown from provided data. BatchSpanProcessor reduces overhead by batching; measure impact in your environment. WideEventInterceptor adds per-request overhead; profile before production.

Software development & web development with DEV.co

DEV.co helps companies turn open-source tools like nestjs-otel into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source observability stack.

Ready to Add Observability to Your NestJS Application?

nestjs-otel reduces observability boilerplate and integrates seamlessly with NestJS. Consult with our engineers to design your tracing and metrics strategy for microservices.