rewire-cli
v0.0.5
Published
Rewire CLI — run commands with OpenTelemetry collection
Readme
rewire-cli
CLI for Rewire — wrap any command with OpenTelemetry collection. It starts an otelcol-contrib sidecar, creates a run via the Rewire API, injects OTEL environment variables into your subprocess, and streams traces and host metrics to your Rewire dashboard.
Installation
npm install -g rewire-cliOr run directly with npx rewire-cli.
Usage
rewire run [options] -- <command...>Options
| Flag | Default | Description |
|---|---|---|
| --repo <name> | required | Repo name to group this run under |
| --job <name> | default | Job name label |
| --workflow <name> | local | Workflow name label |
| --endpoint <url> | http://localhost:3000 | Rewire server URL |
| --api-key <key> | — | API key (or set REWIRE_API_KEY) |
| --no-collector | false | Skip the OTel collector sidecar |
| --version <ver> | 0.114.0 | otelcol-contrib version to use |
| --help | — | Show help |
Examples
# Run your test suite with telemetry
rewire run --repo my-project -- npm test
# Use a different job name
rewire run --repo my-project --job lint -- npm run lint
# Skip the collector (traces only, no host metrics)
rewire run --repo my-project --no-collector -- npm testConfiguration
Config is resolved in this precedence order (highest first):
- CLI flags
- Environment variables
.rewire.jsonin the current working directory~/.rewire.jsonin your home directory
Environment variables
| Variable | Description |
|---|---|
| REWIRE_API_KEY | API key |
| REWIRE_ENDPOINT | Rewire server URL |
| REWIRE_REPO | Repo name |
Config file (.rewire.json)
{
"apiKey": "rw_...",
"endpoint": "https://rewireci.com",
"repo": "my-project"
}How it works
- Creates a run via the Rewire API (
POST /api/public/v1/runs) - Downloads and caches
otelcol-contribto~/.rewire/bin/(skipped if already cached) - Writes an OTEL collector config and starts the sidecar
- Injects
OTEL_*env vars into the subprocess so it exports traces to the local collector - Runs your command, forwarding stdin/stdout/stderr
- Stops the collector on exit and prints the run URL
Development
npm install
npm run build # type-check + bundle with ncc
npm test # run unit tests
npm run typecheck # type-check onlySupported platforms
- Linux (x64, arm64)
- macOS (x64, arm64)
