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

@mobrienv/pi-otlp

v0.2.0

Published

OpenTelemetry metrics and events extension for pi-coding-agent

Readme

pi-otlp

OpenTelemetry metrics extension for pi-coding-agent. Track sessions, turns, tool usage, token consumption, costs, and performance timing.

Installation

pi install npm:@mobrienv/pi-otlp

Or add to ~/.pi/agent/settings.json:

{
  "extensions": ["~/path/to/pi-otlp"]
}

Configuration

Enable via environment variables:

# Required: enable the extension
export PI_OTLP_ENABLE=1

# Choose exporters (console, otlp, or both)
export OTEL_METRICS_EXPORTER=console

# For OTLP export (e.g., to Grafana, Datadog, or any OTLP-compatible backend)
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318/v1/metrics

# Optional: export interval (default: 60000ms)
export OTEL_METRIC_EXPORT_INTERVAL=10000

# Optional: OTLP headers for authentication
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer token"

# Optional: debug logging
export PI_OTLP_DEBUG=1

Metrics

Counters

All counters include base attributes: session.id, provider, model

| Metric | Description | Additional Attributes | |--------|-------------|----------------------| | pi.session.count | Sessions started | — | | pi.turn.count | Agent turns (tool-calling loops) | — | | pi.tool_call.count | Tool invocations | tool.name | | pi.tool_result.count | Tool completions | tool.name, success | | pi.prompt.count | User prompts | prompt.length | | pi.token.usage | Token consumption | type (input/output/cache_read/cache_write) | | pi.cost.usage | Cost in USD | type (input/output/cache_read/cache_write) |

Histograms

All histograms include base attributes: session.id, provider, model

| Metric | Description | Unit | Additional Attributes | |--------|-------------|------|----------------------| | pi.session.duration | Session duration | seconds | — | | pi.turn.duration | Turn duration | seconds | — | | pi.tool.duration | Tool execution duration | seconds | tool.name, success |

Commands

  • /otlp-status — Show telemetry status (sessions, turns, tools, tokens, costs, durations)

Example Output

OTLP Telemetry Status:
  Sessions: 1
  Turns: 5
  Tool calls: 23
  Prompts: 3
  Tokens: 45231 (in: 38000, out: 6000, cache: 1200/31)
  Cost: $0.0234 (in: $0.0190, out: $0.0044)
  Durations:
    Session: 5.2s last, 4.1s avg
    Turn: 1.2s last, 0.8s avg
    Tool: 91ms last, 64ms avg
  Exporters: otlp
  Endpoint: http://localhost:4318/v1/metrics

OTLP Backend Setup

Grafana Alloy / OpenTelemetry Collector

receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318

exporters:
  prometheus:
    endpoint: 0.0.0.0:8889

service:
  pipelines:
    metrics:
      receivers: [otlp]
      exporters: [prometheus]

Local Development with Docker

docker run -d --name otel-collector \
  -p 4318:4318 \
  otel/opentelemetry-collector-contrib:latest

Full Stack Demo

See demo/ for a complete Docker Compose setup with OTLP Collector, Prometheus, and pre-configured Grafana dashboards.

Demo Screenshots

Dashboard overview

pi-otlp dashboard overview

Tokens and cost panels

pi-otlp tokens and costs

15-minute activity view

pi-otlp 15 minute dashboard

License

MIT