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

@llm-ports/telemetry-otel

v0.1.0-alpha.35

Published

OpenTelemetry semantic-conventions bridge for @llm-ports/observability-contract. `createOtelSink({ tracer, meter? })` maps every lifecycle event into gen_ai.* spans + metrics per the OTel gen_ai semconv. Zero runtime dependencies; consumers pass their own

Readme

@llm-ports/telemetry-otel

OpenTelemetry semantic-conventions bridge for @llm-ports/observability-contract. Wraps any ObservabilitySink slot to turn every contract lifecycle event into OTel spans + metrics per the OTel gen_ai semantic conventions.

Install

pnpm add @llm-ports/telemetry-otel @llm-ports/observability-contract

Zero runtime dependencies. The package type-checks against a minimal Tracer / Meter interface (subset of @opentelemetry/api v1). Any object satisfying that shape works — your real @opentelemetry/api tracer, an SDK-specific tracer, or a test double.

Use

import { trace, metrics } from "@opentelemetry/api";
import { createOtelSink } from "@llm-ports/telemetry-otel";
import { createRegistryFromEnv } from "@llm-ports/core";

const otelSink = createOtelSink({
  tracer: trace.getTracer("my-app"),
  meter: metrics.getMeter("my-app"),
});

const registry = createRegistryFromEnv({
  env: process.env,
  adapters: { /* your adapters */ },
  instrumentation: {
    config: {
      sink: otelSink,
      source: { library: "my-app", library_version: "1.0.0" },
    },
  },
});

Every generateText / generateStructured / streamText / streamStructured / runAgent call now produces:

  • A span per operation (gen_ai.<method>, e.g. gen_ai.generateText), open for the duration of the operation.
  • Span attributes gen_ai.operation.name, gen_ai.task_type, gen_ai.provider_chain, gen_ai.request.model, gen_ai.response.model, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.usage.total_tokens, gen_ai.response.id.
  • Histogram samples on gen_ai.client.token.usage (dimensioned by input / output token type), gen_ai.client.operation.duration (seconds), gen_ai.client.cache.read_tokens (when provider cache read > 0). Only recorded when a meter is passed.
  • Span events for agent.step.* (LLM turns), agent.tool.* (tool calls with sha256 digests of arguments + results), and llm.stream.chunk (per-chunk streaming events when the capture policy enables per-chunk emission).
  • Span status: OK on llm.operation.completed, ERROR + recordException on .failed, ERROR + "cancelled" message on .cancelled.

Options

createOtelSink({
  tracer,              // required — any Tracer-shaped object
  meter,               // optional — omit for tracing-only mode
  emitStreamChunkEvents: true,  // default — set false for high-chunk-count streams
  emitAgentEvents: true,        // default — set false to skip agent span events
});

Semantic-conventions mapping

| Contract event | OTel treatment | | --------------------------------------- | ------------------------------------------------------------ | | llm.operation.started | startSpan("gen_ai.<method>") + attributes | | llm.attempt.completed | setAttributes on the open span + histogram samples | | llm.attempt.failed | recordException on the open span | | llm.operation.completed | setStatus(OK) + end() | | llm.operation.failed | recordException + setStatus(ERROR) + end() | | llm.operation.cancelled | setStatus(ERROR, "cancelled") + end() | | llm.stream.chunk | addEvent("gen_ai.stream.chunk", chunkData) | | agent.step.started / .completed | addEvent("gen_ai.agent.step.started" / ".completed", ...) | | agent.tool.called / .returned | addEvent("gen_ai.agent.tool.called" / ".returned", ...) |

Unknown event types (llm.attempt.retry_scheduled, llm.fallback.selected, and future additions) are silently dropped by this sink — layer your own custom sink on top if you want to trace them too.

Versioning

Alpha until the observability contract and gen_ai semconv both stabilize. Contract changes shipped in later alphas may prompt corresponding sink updates.