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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hannoeru/nuxt-otel

v0.0.8

Published

OpenTelemetry module for Nuxt 3

Readme

Nuxt OpenTelemetry

OpenTelemetry integration for Nuxt 3 applications with automatic instrumentation and telemetry collection.

Features

  • 🔍  Automatic instrumentation - HTTP requests, API routes, and server-side operations
  • 📊  Multiple presets - Support for Node.js and Vercel deployments
  • ⚙️  Flexible configuration - Customize telemetry collection and filtering
  • 🎯  Zero-config setup - Works out of the box with sensible defaults
  • 🔧  TypeScript support - Full type safety for configuration options
  • 🌐  OpenTelemetry standards - Compatible with all OpenTelemetry collectors
  • 🎭  Function tracing - Automatic tracing of built-in functions

Quick Setup

Install the module to your Nuxt application:

npx nuxi module add @hannoeru/nuxt-otel

For Vercel deployments, also install the optional peer dependency:

npm install @vercel/otel
# or
yarn add @vercel/otel
# or
pnpm add @vercel/otel

That's it! OpenTelemetry instrumentation is now enabled in your Nuxt app ✨

Configuration

Add the module to your nuxt.config.ts:

export default defineNuxtConfig({
  modules: [
    '@hannoeru/nuxt-otel'
  ],
  otel: {
    // Configuration options
  }
})

Options

See the full type definitions in src/types.ts.

Basic Configuration

export default defineNuxtConfig({
  modules: ['@hannoeru/nuxt-otel'],
})

Advanced Configuration

export default defineNuxtConfig({
  modules: ['@hannoeru/nuxt-otel'],
  otel: {
    ignorePath: '^/api/health',
    requestHeaders: ['x-custom-header', 'content'],
    responseHeaders: ['x-custom-header', 'content'],
    trace: {
      functions: {
        enabled: true,
        includeFrom: ['package'],
        include: [/useCustomTracing/],
        exclude: [/internal/]
      }
    }
  }
})

Environment Setup

Environment Variables

Configure OpenTelemetry using standard environment variables:

# Service identification
OTEL_SERVICE_NAME=my-nuxt-app

# Trace configuration
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

# Metrics configuration
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://localhost:4318/v1/metrics

# Logs configuration
OTEL_LOGS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318/v1/logs

# Headers (if authentication is required)
OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer token123

# Resource attributes
OTEL_RESOURCE_ATTRIBUTES=service.name=my-nuxt-app,service.version=1.0.0,deployment.environment=production

Local Development with Docker

See the example Docker Compose setup in playground/compose.yml.

Start the services:

docker-compose -f playground/compose.yml up -d

Production Deployment

Supported platforms

  • Node.js: Use the default configuration for Node.js applications.
  • Vercel: Use the Vercel preset for automatic instrumentation. Requires installing the optional @vercel/otel peer dependency.

API Routes Instrumentation

The module automatically instruments your API routes:

// server/api/users.get.ts
export default defineEventHandler(async (event) => {
  // This request will be automatically traced
  const users = await $fetch('/api/external-service')
  return users
})

Custom Instrumentation

Add custom spans to your application:

// server/utils/trace.ts
import { trace } from '@opentelemetry/api'

export function useTracing() {
  const tracer = trace.getTracer('my-app')
  
  return {
    async withSpan<T>(name: string, fn: () => Promise<T>): Promise<T> {
      const span = tracer.startSpan(name)
      try {
        const result = await fn()
        span.setStatus({ code: 1 }) // OK
        return result
      } catch (error) {
        span.recordException(error)
        span.setStatus({ code: 2 }) // ERROR
        throw error
      } finally {
        span.end()
      }
    }
  }
}

Debug Mode

Enable debug logging for OpenTelemetry:

OTEL_LOG_LEVEL=debug

Resources

Credits

License

MIT