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

pi-telemetry-otel

v0.1.1

Published

OpenTelemetry (OTLP/HTTP) telemetry extension + helper APIs for pi

Readme

pi OTEL Telemetry Extension

Emits OpenTelemetry spans for pi agent lifecycle + tool usage to an OTLP/HTTP collector (Jaeger).

Install / enable

Install as a pi package (recommended):

# Global install (writes ~/.pi/agent/settings.json)
pi install npm:pi-telemetry-otel

# Project-local install (writes .pi/settings.json)
pi install -l npm:pi-telemetry-otel

Try without installing:

pi -e npm:pi-telemetry-otel "List files"

Pi loads the extension from the package’s pi.extensions manifest automatically once installed (unless disabled via pi config).

Configuration

All settings accept PI_ overrides (e.g. PI_OTEL_SERVICE_NAME) and fall back to standard OTEL env vars.

| Env var | Default | Purpose | | ----------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------- | | OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4318/v1/traces | OTLP/HTTP endpoint | | OTEL_EXPORTER_OTLP_HEADERS | (none) | Comma-separated k=v headers | | OTEL_SERVICE_NAME | pi-agent | Service name in Jaeger (defaults to agent name from PI_AGENT_CHAIN if present) | | OTEL_RESOURCE_ATTRIBUTES | (none) | Comma-separated k=v attributes | | PI_AGENT_TRACE_ID | (generated) | Parent trace ID to reuse; set once and kept for subprocess trace linking | | PI_AGENT_SPAN_ID | (generated) | Parent span ID for subprocess linking; updated to current active span (session/agent/turn/tool) |

Extension interoperability (child spans)

Other pi extensions can attach spans to the current pi trace.

Recommended: use the helper APIs

import { withPiSpan } from "pi-telemetry-otel/helpers";

pi.on("tool_call", async (_event, ctx) => {
  await withPiSpan(ctx, "myext.do_work", async (span) => {
    span?.setAttribute("myext.foo", "bar");
    // ... your work
  });
});

The helper functions:

  • reuse the tracer/export pipeline registered by this extension
  • parent spans under the active pi span (session/agent/turn/tool)
  • prefer a per-session context registry (avoids env-var races in concurrent in-process sub-sessions)

Advanced: global registries (no hard dependency)

If you don’t want to depend on the package, you can read the registries directly:

  • Runtime registry symbol: Symbol.for("pi.telemetry-otel.runtimeRegistry.v1")
  • Active span context registry symbol: Symbol.for("pi.telemetry-otel.activeSpanContextRegistry.v1")
  • Map key: ctx.sessionManager.getSessionId()

(See flow-machine for a reference integration that emits pi.flow.* spans.)

Open the current trace

Use /open-jaeger-trace to show the current trace URL and optionally open it in your browser. If Tailscale is available, the command also surfaces a Tailscale IP URL for remote access.

Jaeger smoke check

# Run pi (interactive preferred so spans flush)
PI_OTEL_SERVICE_NAME=pi-agent-dev pi

# Query traces
curl -sSf "http://localhost:16686/api/traces?service=pi-agent-dev&limit=5" | jq -r '.data[].traceID'
curl -sSf "http://localhost:16686/api/traces/<trace-id>" | jq -r '.data[0].spans[].operationName'

Expected operations: pi.session, pi.agent, pi.turn, pi.tool: <tool-name> (bash adds command preview).

Tests

cd telemetry-otel
bun install
bun test