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-otel-telemetry

v1.0.0

Published

OpenTelemetry traces & metrics extension for pi coding agent

Readme

Pi OTEL Telemetry Extension

OpenTelemetry tracing and metrics for pi coding agent. Exports spans and counters for sessions, agent prompts, LLM turns, and tool executions.

Trace Structure

session                          (root span, entire session lifecycle)
├── agent.prompt                 (one per user message)
│   └── agent.turn               (one per LLM call + tool execution cycle)
│       ├── llm.request          (span event: before provider API call)
│       ├── tool.bash            (tool execution span)
│       ├── tool.read            (tool execution span)
│       └── tool.edit            (tool execution span)
├── model.changed                (span event on model switch)
└── session.compacted            (span event on compaction)

Metrics

| Metric | Type | Labels | Description | |--------|------|--------|-------------| | pi.tokens.input | Counter | llm.model | Total input tokens consumed | | pi.tokens.output | Counter | llm.model | Total output tokens produced | | pi.tool.calls | Counter | tool.name | Total tool invocations | | pi.tool.errors | Counter | tool.name | Total failed tool invocations | | pi.tool.duration | Histogram (ms) | tool.name | Tool execution time | | pi.turns | Counter | llm.model | Total LLM turns | | pi.prompts | Counter | llm.model | Total user prompts | | pi.session.duration | Histogram (s) | llm.model | Session duration |

Trace Attributes

Session span

| Attribute | Description | |-----------|-------------| | session.id | Session file path or "ephemeral" | | session.cwd | Working directory | | session.turns | Total turn count | | session.tool_calls | Total tool calls | | session.tokens.input | Total input tokens | | session.tokens.output | Total output tokens | | llm.model | Current model (provider/id) |

Turn span

| Attribute | Description | |-----------|-------------| | turn.index | Turn index within agent prompt | | turn.number | Global turn number in session | | turn.tool_results | Number of tool results | | llm.usage.input_tokens | Tokens consumed (input) | | llm.usage.output_tokens | Tokens produced (output) |

Tool span

| Attribute | Description | |-----------|-------------| | tool.name | Tool name (bash, read, edit, write, etc.) | | tool.call_id | Unique tool call ID | | tool.args_summary | Brief summary of arguments (truncated) | | tool.is_error | Whether execution failed | | tool.duration_ms | Execution time in milliseconds |

Configuration

| Environment Variable | Default | Description | |---------------------|---------|-------------| | OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4318 | OTLP HTTP endpoint | | OTEL_SERVICE_NAME | pi-coding-agent | Service name in traces | | PI_OTEL_ENABLED | true | Set to false to disable | | PI_OTEL_DEBUG | false | Set to true to also log spans/metrics to console | | OTEL_METRIC_EXPORT_INTERVAL | 10000 | Metric export interval in ms |

Quick Start

With Jaeger (local)

# Start Jaeger with OTLP support
docker run -d --name jaeger \
  -p 16686:16686 \
  -p 4318:4318 \
  jaegertracing/jaeger:2 \
  --set receivers.otlp.protocols.http.endpoint=0.0.0.0:4318

# Start pi (extension auto-discovered from ~/.pi/agent/extensions/)
pi

# Open Jaeger UI
open http://localhost:16686

With Grafana Tempo

OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4318 pi

Debug mode (console output)

PI_OTEL_DEBUG=true pi

Disable

PI_OTEL_ENABLED=false pi

Installation

Already installed at ~/.pi/agent/extensions/otel-telemetry/. The extension is auto-discovered by pi.

To reinstall dependencies:

cd ~/.pi/agent/extensions/otel-telemetry
npm install