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.2.0

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.

Prerequisites

Your application must be started with the --import=@opentelemetry/instrumentation/hook.mjs Node.js flag. This flag registers the OpenTelemetry instrumentation hook before any application code runs, enabling automatic patching of all imported modules.

In your Dockerfile:

CMD ["dumb-init", "node", "--import=@opentelemetry/instrumentation/hook.mjs", "/home/node/app/server.js"]

When the --import hook is used, strict import sequencing is not required — you can use regular static imports in your application code. This is the recommended approach for performance reasons, as dynamic imports can cause significantly slower module loading (synchronous module resolution can add 20+ seconds to startup in large applications).

Installation

npm install @lokalise/opentelemetry-fastify-bootstrap

Usage

With the --import hook in place, use regular static imports and call initOpenTelemetry before starting your server:

// server.ts (entry point)
import { initOpenTelemetry } from '@lokalise/opentelemetry-fastify-bootstrap'
import { startServer } from './serverInternal.ts'

// Call this before starting the server
if (process.env.OTEL_ENABLED !== 'false') {
  initOpenTelemetry({
    skippedPaths: ['/health', '/ready', '/live', '/metrics', '/'],
  })
}

await startServer()

Using defaults

If you don't need custom skipped paths:

import { initOpenTelemetry } from '@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 | | spanProcessors | SpanProcessor[] | [] | Additional span processors to register |

Debugging with Console Spans

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

import { initOpenTelemetry } from '@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.

Adding Custom Span Processors

You can integrate additional span processors to send telemetry data to multiple destinations or add custom processing logic.

Multiple span processors work alongside the OTLP exporter and optional console span exporter:

import { MyCustomSpanProcessor } from './custom-processor'
import { initOpenTelemetry } from '@lokalise/opentelemetry-fastify-bootstrap'

initOpenTelemetry({
  consoleSpans: true, // Enable console debugging
  spanProcessors: [
    new MyCustomSpanProcessor({ /* config */ }),
  ],
})

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
  • Support for custom span processors
  • 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)
})