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

@lokalise/opentelemetry-fastify-bootstrap

v2.0.1

Published

This package provides a pre-configured OpenTelemetry setup for Fastify applications with automatic instrumentation.

Readme

OpenTelemetry Fastify Bootstrap

This package provides a pre-configured OpenTelemetry setup for Fastify applications with automatic instrumentation.

Important: OpenTelemetry must be initialized before importing any modules you want to instrument (fastify, http, etc.), because it works by patching module exports at import time. This requires using dynamic imports to control the loading order.

Installation

npm install @lokalise/opentelemetry-fastify-bootstrap

Usage

Your application entry point must use dynamic await import() to ensure OpenTelemetry initializes before other modules are loaded:

// index.ts (entry point)

// This MUST be first - initializes OpenTelemetry before anything else
const { initOpenTelemetry } = await import('@lokalise/opentelemetry-fastify-bootstrap')
initOpenTelemetry({
  skippedPaths: ['/health', '/ready', '/live', '/metrics', '/'],
})

// Now dynamically import your actual server code
const server = await import('./server.ts')
await server.start()

Why dynamic imports? Static imports in ESM are hoisted and resolved together before any code executes. Dynamic await import() ensures sequential loading - the package fully initializes before server.ts is even parsed.

Using defaults

If you don't need custom skipped paths:

const { initOpenTelemetry } = await import('@lokalise/opentelemetry-fastify-bootstrap')
initOpenTelemetry()

Configuration

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | NODE_ENV | When set to test, OpenTelemetry is disabled | - | | OTEL_ENABLED | Set to true to enable OpenTelemetry | false | | OTEL_EXPORTER_URL | OTLP gRPC exporter URL | grpc://localhost:4317 |

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | skippedPaths | string[] | ['/health', '/metrics', '/'] | Paths to exclude from tracing | | consoleSpans | boolean | false | Enable console span exporter for debugging |

Debugging with Console Spans

For local development and debugging, you can enable console span output to see traces printed directly to the console:

const { initOpenTelemetry } = await import('@lokalise/opentelemetry-fastify-bootstrap')
initOpenTelemetry({
  consoleSpans: true, // Prints spans to console for debugging
})

When enabled, spans are printed to the console in addition to being sent to the OTLP exporter. This is useful for verifying that instrumentation is working correctly without needing to run a full observability stack.

Features

  • Automatic instrumentation for Node.js applications via @opentelemetry/auto-instrumentations-node
  • Fastify-specific instrumentation via @fastify/otel
  • OTLP gRPC trace exporter
  • Configurable path filtering
  • Optional console span exporter for debugging
  • Graceful shutdown support

Graceful Shutdown

To properly shutdown the OpenTelemetry SDK when your application exits:

import { gracefulOtelShutdown } from '@lokalise/opentelemetry-fastify-bootstrap'

process.on('SIGTERM', async () => {
  await gracefulOtelShutdown()
  process.exit(0)
})