phycool-otel-micro-collector

Collects Claude CLI OTLP telemetry into JSON Lines for token tracking.

10|3|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-otel-micro-collector-cynthia1070711
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phycool-otel-micro-collector
Source: https://github.com/Cynthia1070711/PHYCOOL_Tools/tree/main/config-templates/claude/skills/phycool-otel-micro-collector
Command: npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-otel-micro-collector-cynthia1070711

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Claude CLI's console exporter writes telemetry to stdout, but stdout cannot be redirected without breaking the TUI, so token usage data was silently lost. This Skill runs a lightweight local OTLP HTTP/JSON collector that receives telemetry and writes it to JSON Lines files, enabling accurate token and cost tracking for both pipeline runs and main-window sessions. ## Core Features & Use Cases - Dual-mode collection: Pipeline mode spawns a collector on a dynamic port per phase, while main-window mode runs a persistent collector on fixed port 49200 with SessionStart/SessionEnd hooks. - Daily rotation with SSoT: The collector self-rotates JSONL files at UTC+8 day boundaries and atomically publishes the active file path in main-otel-info.json, so aggregation never loses or double-counts records. - Idempotent aggregation: A SessionEnd hook reads JSONL files with per-file marker offsets and updates workflow_executions token and cost fields in the database. - Use Case: You run multi-phase story pipelines and want per-phase token costs in your DevConsole dashboard; the collector captures every api_request event and the watchdog aggregates them into the database automatically. ## Quick Start Ask the AI to set up OTel token tracking for the main window by starting the micro collector on port 49200 and verifying that telemetry is written to the daily JSONL log.

Frequently Asked Questions about phycool-otel-micro-collector

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I track Claude CLI token usage with OpenTelemetry?

Enable telemetry by setting CLAUDE_CODE_ENABLE_TELEMETRY=1 and the OTLP exporter environment variables, then run a local collector that receives OTLP HTTP/JSON exports. The collector writes api_request events with input, output, and cache token counts to JSON Lines files for later aggregation.

How to collect OTLP telemetry without breaking the Claude CLI TUI?

Use the OTLP HTTP exporter instead of the console exporter, since the console exporter writes to stdout which cannot be redirected without breaking isatty detection. The collector listens on localhost and receives telemetry over HTTP, leaving stdout untouched.

Does the OTel collector work with multiple parallel pipeline windows?

Yes, pipeline mode assigns each run a random port in the 49152-65535 range with up to 10 retry attempts on conflicts, so concurrent pipelines stay isolated. A manual per-session mode also exists for precise multi-window attribution.

Why are my workflow token counts showing zero in the dashboard?

Zero tokens usually mean the collector was not running or the aggregator could not find the current JSONL file, such as after a day boundary with a stale fixed filename. The rotation SSoT design fixes this by having the collector publish the active file path atomically in main-otel-info.json.

What are the limitations of shared main-window token tracking?

In shared mode, sessions are matched to token records by time range, so overlapping windows achieve roughly 90 percent attribution accuracy. Token data only reaches the database at SessionEnd unless you manually run the aggregation script mid-session.