Shaaban Registry

OpenTelemetry Bootstrap

Instrument Node.js services with opinionated sampling, pretty console traces, and optional OTLP exporting.

Why ship tracing defaults?

Observability often lands at the end of the sprint. We provide an otel.bootstrap.ts file that mirrors how we configure OpenTelemetry in production NestJS and Express services. Drop the file into your project and import it before your HTTP server starts to get consistent tracing metadata.

Installation

Observability often lands at the end of the sprint. We provide an otel.bootstrap.ts file that mirrors how we configure OpenTelemetry in production NestJS and Express services. Drop the file into your project and import it before your HTTP server starts to get consistent tracing metadata.

npx shadcn@latest add https://registry.shaaban.com/r/open-telemetry.json

Features

  • Parent based sampling driven by OTEL_SAMPLER_RATIO, matching upstream best practices.

  • Pretty console exporter that mirrors the dashboards we use during development while keeping production clean.

  • Optional OTLP exporter activated with OTEL_EXPORTER_ENABLED=true .

  • Express + Nest instrumentation with custom attributes for authenticated users and request bodies.

Installation

  1. Generate the bootstrap file with the Shadcn CLI, pointed at the Shaaban registry:

    pnpm dlx shadcn@latest add https://registry.shaaban.com/r/open-telemetry.json
  2. Add the recommended defaults to your .env file:

    # OTEL_LOG_FORMAT="simple" OTEL_LOG_FORMAT="advanced" APP_NAME="Nest" OTEL_EXPORTER_ENABLED="false"
    OTEL_SAMPLER_RATIO=1.0
    
    # OTEL_EXPORTER_URL="http://localhost:4318/v1/traces"
  3. Ensure the bootstrap runs before your server starts by configuring NODE_OPTIONS:

    NODE_OPTIONS="--require ./otel.bootstrap.ts"

If you prefer to keep the bootstrap file inside the repository, move it after generation and adjust the import path.

Environment variables

  • APP_NAME — displayed in logs to differentiate between services.

  • OTEL_SAMPLER_RATIO — decimal between 0 and 1 controlling trace sampling (for example 0.25).

  • OTEL_EXPORTER_ENABLED — set to true to enable OTLP exporting.

  • OTEL_EXPORTER_URL — OTLP endpoint (e.g. https://api.honeycomb.io/v1/traces).

  • OTEL_LOG_FORMATsimple (single line) or advanced (grouped console output).

The bootstrap relies on dotenv to load environment variables, mirroring the setup in our NestJS starters.

Further reading

The implementation follows the patterns documented in

open-telemetry/opentelemetry-js

and we periodically sync improvements from the upstream shadcn docs. For production deployments, pair these defaults with centralized log ingestion and metrics from your infrastructure provider.