
codexbar-exporter
github.com/avanderheyde/codexbar-exporter- Category
- Developer Tools
- Rank
- No. 2200Tools index
Previous survey · No. 2169 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- @Alderik_
- Latest release
- v0.1.0
- Date
About
A small dependency-free Go agent that wraps the CodexBar CLI and republishes AI-coding usage data — plan utilization and token cost — as Prometheus metrics, a JSON endpoint, or an outbound push to a service such as Vibe Costs. Because it reads the CLI's existing sessions it needs no provider API keys, and it runs on any macOS or Linux host, making usage on headless agent servers visible instead of only inside the local menu-bar app.
What it does
It periodically runs the existing CodexBar command-line tool, keeps the latest usage and cost snapshot in memory, and converts that local data into forms suitable for monitoring, browser dashboards, or an outbound relay.
Why it's ranked here
This is a focused, credible bridge between local CodexBar sessions and remote observability. It combines useful operational safeguards, clear deployment options, and tests for collection, authentication, browser access, metric formatting, timeouts, and stale-data behavior.
What's good
Collection failures preserve the last successful data while health metrics expose the failure. Command output is capped, calls have timeouts, and relay pushes cannot block indefinitely. Bearer tokens use constant-time comparison, and the default listener stays on localhost.
Tradeoffs
It requires the CodexBar CLI on the same machine, already signed into relevant providers. Cost collection is best-effort, so its failure does not invalidate usage data. Authentication is optional, permissive browser access can be enabled, and metric labels may contain account email addresses.
How to use it well
Use it on an always-on macOS or Linux development machine where CodexBar already collects provider usage. It fits Prometheus monitoring, direct dashboard reads, or outbound relay workflows. It does not replace provider authentication, CodexBar itself, or a visualization dashboard.
Technical notes+
main.go configures periodic collection, environment-backed flags, signal handling, optional HTTP serving, stale snapshot retention, and graceful shutdown. collect.go invokes the CodexBar binary with context deadlines, a 32 MB stdout cap, JSON parsing, and best-effort cost collection. server.go implements /metrics, /usage, /cost, and open /healthz routes with optional CORS and SHA-256-backed constant-time Bearer comparison. metrics.go manually emits Prometheus text exposition without a client library. push.go sends raw JSON snapshots with a 15-second timeout and bounded response draining. types.go models usage and cost payloads. main_test.go, server_test.go, collect_test.go, and metrics_test.go cover the central behaviors. go.mod declares Go 1.24 and no third-party modules.
Observed
- License
- MIT License
- Primary language
- Go
- Install surface
- Release tarballs or Go installation from the module path
- Interfaces
- Command-line agent, Prometheus HTTP endpoint, JSON HTTP endpoints, health endpoint, and outbound HTTP push
- Platform support
- macOS and Linux, with launchd and systemd user-service examples
- Dependencies
- Go module declares no third-party modules; runtime requires the CodexBar CLI
- Tests
- Four Go test files cover storage, HTTP behavior, collection, and metric rendering
Read from README.md, go.mod, main.go, server.go, push.go, types.go, collect.go, metrics.go, main_test.go, server_test.go, collect_test.go, metrics_test.go, LICENSE, contrib/codexbar-exporter.service, contrib/com.codexbar.exporter.plist.
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.