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

magic-otel

v0.0.7

Published

A lightweight TypeScript library that simplifies OpenTelemetry integration for Node.js applications. Magic-OTEL provides easy-to-use decorators for method tracing and a custom Zipkin file exporter for local development and debugging.

Readme

Magic OpenTelemetry

A lightweight TypeScript library that simplifies OpenTelemetry integration for Node.js applications. Magic-OTEL provides easy-to-use decorators for method tracing and a custom Zipkin file exporter for local development and debugging.

Features

  • 🚀 Simple setup with minimal configuration
  • 🔍 Method-level tracing with TypeScript decorators
  • 📁 Custom Zipkin file exporter for local development
  • 🔌 Auto-instrumentation for popular Node.js libraries
  • 🛠️ Flexible configuration options

Installation

npm install magic-otel
# or
yarn add magic-otel

Make sure to also install the required peer dependencies:

npm install @opentelemetry/api @opentelemetry/sdk-node
# or
yarn add @opentelemetry/api @opentelemetry/sdk-node

Quick Start

Basic Setup

import { registerOpenTelemetry } from 'magic-otel';

// Initialize OpenTelemetry with default settings
registerOpenTelemetry({
  serviceName: 'my-service'
});

// Your application code here

Method Tracing with Decorators

import { Tracing } from 'magic-otel';

class UserService {
  @Tracing()
  async getUserById(id: string) {
    // This method will be automatically traced
    return { id, name: 'John Doe' };
  }
}

Class-level Tracing

import { ClassTracing } from 'magic-otel';

@ClassTracing()
class OrderService {
  // All methods in this class will be automatically traced
  async createOrder(data: any) {
    return { orderId: '123', status: 'created' };
  }
  
  async getOrderById(id: string) {
    return { id, items: [] };
  }
}

Using the Zipkin File Exporter

import { registerOpenTelemetry, ZipkinFileSpanExporter } from 'magic-otel';
import * as path from 'path';

// Create a Zipkin file exporter
const exporter = new ZipkinFileSpanExporter({
  exportDir: path.join(__dirname, 'traces'),
  serviceName: 'my-service',
  maxWrittenCount: 100 // Clean up after 100 exports
});

// Register OpenTelemetry with the exporter
registerOpenTelemetry({
  serviceName: 'my-service',
  traceExporter: exporter
});

API Reference

registerOpenTelemetry(params?: RegisterOpenTelemetryParams)

Initializes and starts the OpenTelemetry SDK with the provided configuration.

Parameters:

  • params.serviceName: Name of your service
  • params.metricReader: Custom metric reader
  • params.traceExporter: Custom span exporter
  • params.instrumentations: Additional instrumentations
  • params.autoInstrumentations: Configuration for auto-instrumentations

ZipkinFileSpanExporter

A custom span exporter that writes spans to JSON files in Zipkin format.

Constructor options:

  • exportDir: Directory where span files will be saved
  • serviceName: Name of your service (optional)
  • maxWrittenCount: Maximum number of files before cleanup (optional, default: 100)

Decorators

@Tracing()

A method decorator that automatically creates and manages spans for the decorated method.

@ClassTracing()

A class decorator that automatically applies tracing to all methods in the class.

Examples

Express Application with Tracing

import express from 'express';
import { registerOpenTelemetry, Tracing } from 'magic-otel';

// Initialize OpenTelemetry
registerOpenTelemetry({
  serviceName: 'express-app'
});

class UserController {
  @Tracing()
  async getUsers(req: express.Request, res: express.Response) {
    // This method is traced
    const users = await fetchUsers();
    res.json(users);
  }
}

const userController = new UserController();
const app = express();

app.get('/users', (req, res) => userController.getUsers(req, res));

app.listen(3000, () => {
  console.log('Server running on port 3000');
});