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

@usagetap/otel-exporter

v0.1.1

Published

OpenTelemetry metrics exporter for UsageTap SDK

Readme

@usagetap/otel-exporter

Export UsageTap usage metrics to any OpenTelemetry-compatible observability platform.

Installation

npm install @usagetap/otel-exporter @usagetap/sdk

Quick Start

import { UsageTapClient } from "@usagetap/sdk";
import { createOtelExporter } from "@usagetap/otel-exporter";

// Create the OTEL exporter
const otel = createOtelExporter({
  endpoint: "https://otel-collector.example.com:4318/v1/metrics",
  headers: {
    Authorization: "Bearer your-api-key",
  },
  serviceName: "my-llm-service",
});

// Wire it to the UsageTap client
const usageTap = new UsageTapClient({
  apiKey: process.env.USAGETAP_API_KEY!,
  baseUrl: process.env.USAGETAP_BASE_URL!,
  onUsageMetric: otel.send,
});

// Use UsageTap as normal - metrics are automatically exported
const result = await usageTap.withUsage(
  { customerId: "user-123" },
  async (ctx) => {
    // Your LLM call here
    ctx.setUsage({ inputTokens: 100, responseTokens: 50 });
    return "response";
  }
);

// On application shutdown
await otel.shutdown();

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | endpoint | string | Required | OTLP HTTP endpoint URL | | headers | Record<string, string> | {} | Auth headers (API keys, tokens) | | serviceName | string | "usagetap" | Service name in metrics | | serviceVersion | string | "1.0.0" | Service version | | resourceAttributes | Record<string, string> | {} | Additional resource attributes | | exportIntervalMs | number | 60000 | Export batch interval (ms) |

Exported Metrics

| Metric | Type | Description | |--------|------|-------------| | usagetap.calls | Counter | Number of LLM API calls | | usagetap.tokens.input | Counter | Input/prompt tokens | | usagetap.tokens.output | Counter | Output/response tokens | | usagetap.tokens.cached | Counter | Cached tokens | | usagetap.tokens.reasoning | Counter | Reasoning tokens | | usagetap.cost.usd | Counter | Cost in USD | | usagetap.searches | Counter | Web search calls | | usagetap.audio.seconds | Counter | Audio duration | | usagetap.custom_meter | Counter | Custom meter increments |

Metric Attributes

All metrics include these attributes:

  • usagetap.customer_id - Customer identifier
  • usagetap.call_id - Unique call ID
  • usagetap.feature - Feature tag
  • usagetap.model - Model used
  • usagetap.tags - Comma-separated tags
  • usagetap.correlation_id - Trace correlation ID

Platform Examples

Datadog

const otel = createOtelExporter({
  endpoint: "https://http-intake.logs.datadoghq.com/api/v2/otlp/v1/metrics",
  headers: {
    "DD-API-KEY": process.env.DD_API_KEY!,
  },
});

Grafana Cloud

const otel = createOtelExporter({
  endpoint: "https://otlp-gateway-prod-us-central-0.grafana.net/otlp/v1/metrics",
  headers: {
    Authorization: `Basic ${Buffer.from(`${instanceId}:${apiKey}`).toString("base64")}`,
  },
});

New Relic

const otel = createOtelExporter({
  endpoint: "https://otlp.nr-data.net:4318/v1/metrics",
  headers: {
    "api-key": process.env.NEW_RELIC_LICENSE_KEY!,
  },
});

Self-hosted Collector

const otel = createOtelExporter({
  endpoint: "http://localhost:4318/v1/metrics",
});

License

MIT