npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@crossdelta/telemetry

v0.5.2

Published

OpenTelemetry instrumentation for CrossDelta services

Readme

@crossdelta/telemetry

npm version License: MIT TypeScript OpenTelemetry

Zero-config OpenTelemetry instrumentation for TypeScript services.

Import once, get automatic tracing, metrics, and logs — configured entirely via environment variables.

┌─────────────────┐     OTLP/HTTP     ┌──────────────────┐
│  Your Service   │ ───── traces ───► │  Grafana Cloud   │
│                 │ ───── metrics ──► │  Better Stack    │
│                 │ ───── logs ─────► │  Jaeger, etc.    │
└─────────────────┘                   └──────────────────┘

Why this library?

Setting up OpenTelemetry is tedious: SDK initialization, exporter configuration, instrumentation setup, graceful shutdown handling...

| Feature | Benefit | |---------|---------| | 🚀 Zero config | Just import — reads OTEL_* env vars automatically | | 🔌 Selective instrumentation | HTTP, Express, and Pino instrumented under Node.js | | 📊 Traces + Metrics + Logs | All three signals configured in one import | | 📝 Pino log forwarding | Pino logs automatically sent to OTLP via PinoInstrumentation (Node.js) | | 💬 Console capture | console.log/warn/error forwarded as OTEL LogRecords (all runtimes) | | 🛑 Graceful shutdown | Flushes telemetry on SIGTERM/SIGINT | | 🏃 Multi-runtime | Node.js (full instrumentation) and Bun (console log forwarding) |

Installation

bun add @crossdelta/telemetry
# or
npm install @crossdelta/telemetry

Getting Started

1. Add the import (first line!)

// src/index.ts
import '@crossdelta/telemetry'  // ← MUST be first!

import { Hono } from 'hono'
// ... rest of your code

⚠️ Important: The import must come before any other imports to properly patch modules (especially Pino).

2. Set environment variables

# Service identification
OTEL_SERVICE_NAME=my-service
OTEL_RESOURCE_ATTRIBUTES=service.name=my-service,deployment.environment=production

# Traces endpoint
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://otlp-gateway.grafana.net/otlp/v1/traces

# Metrics endpoint (optional)
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://otlp-gateway.grafana.net/otlp/v1/metrics

# Logs endpoint (optional — enables pino + console forwarding)
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://otlp-gateway.grafana.net/otlp/v1/logs

# Shared auth header for all signals
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic base64(instanceId:apiKey)

3. That's it!

Your service now exports traces, metrics, and logs. You'll see:

✅ OpenTelemetry initialized for my-service

If no OTEL_EXPORTER_OTLP_TRACES_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT is set, telemetry is disabled:

ℹ️  OpenTelemetry not configured (no OTEL_EXPORTER_OTLP_TRACES_ENDPOINT)

How Logs Work

Logs are captured through two mechanisms:

  1. Pino (Node.js services via nestjs-pino): @opentelemetry/instrumentation-pino intercepts pino's output via pino.multistream and sends log records to the OTEL Logs API. Logs still appear on stdout as usual.

  2. Console (all runtimes): console.log/info/warn/error/debug are patched to emit OTEL LogRecords alongside their normal stdout output.

Both paths use BatchLogRecordProcessorOTLPLogExporter → your configured logs endpoint.

Runtime Support

| Feature | Node.js | Bun | |---------|---------|-----| | Console log forwarding | ✅ | ✅ | | Pino log forwarding | ✅ | ❌ (no require hooks) | | HTTP tracing | ✅ | ❌ (no require hooks) | | Express/NestJS tracing | ✅ | ❌ (no require hooks) | | Metrics export | ✅ | ✅ | | Graceful shutdown | ✅ | ✅ |

Bun services (Hono) get log forwarding and metrics. Full instrumentation (traces, pino) requires Node.js.

Instrumentations (Node.js only)

| Package | What it captures | |---------|-----------------| | @opentelemetry/instrumentation-http | Incoming/outgoing HTTP requests | | @opentelemetry/instrumentation-express | Express/NestJS route spans | | @opentelemetry/instrumentation-pino | Pino log records → OTEL Logs API |

Advanced Usage

For custom configuration, use initTelemetry() instead of the side-effect import:

import { initTelemetry } from '@crossdelta/telemetry'

initTelemetry({
  // Custom metrics export interval (default: 60s)
  metricsIntervalMs: 30_000,

  // Custom shutdown handler
  onShutdown: async () => {
    await myDatabase.close()
  },
})

Supported Backends

Any OTLP-compatible backend works:

API Reference

initTelemetry(config?)

Initialize the OpenTelemetry SDK manually.

| Option | Type | Default | Description | |--------|------|---------|-------------| | metricsIntervalMs | number | 60000 | Metrics export interval | | onShutdown | () => Promise<void> | - | Custom shutdown handler |

Returns true if initialized, false if already initialized or not configured.

getSDK()

Returns the current NodeSDK instance (or null if not initialized).

shutdownTelemetry()

Flush all pending telemetry data and shut down the SDK.

Infrastructure

OTEL environment variables are automatically injected by @crossdelta/infrastructure via buildOtelEnv(). See the infra config for endpoint configuration (Pulumi secrets).

License

MIT © crossdelta