https://github.com/c-ehrlich/trace-amp
OTel Tracing wrapper for Amp
https://github.com/c-ehrlich/trace-amp
Last synced: 3 months ago
JSON representation
OTel Tracing wrapper for Amp
- Host: GitHub
- URL: https://github.com/c-ehrlich/trace-amp
- Owner: c-ehrlich
- Created: 2026-02-05T08:03:19.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-05T10:01:49.000Z (5 months ago)
- Last Synced: 2026-04-04T04:53:53.887Z (3 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/trace-amp
- Size: 94.7 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# trace-amp
OpenTelemetry instrumentation for [Amp](https://ampcode.com) CLI.

Fully vibe coded, use at your own risk.
## Installation
```bash
npm install -g trace-amp
```
## Usage
Set the required environment variables:
```bash
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.axiom.co/v1/traces"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-api-token,X-Axiom-Dataset=your-dataset"
```
Then run:
```bash
trace-amp "ask the oracle to add 2+2"
```
Or use `npx` without installing globally:
```bash
npx trace-amp "ask the oracle to add 2+2"
```
## TypeScript Usage
### Standalone (new OTel setup)
```typescript
import { initTracing, shutdownTracing, createAmpClient } from 'instrument-amp';
initTracing({
serviceName: 'my-amp-agent',
otlpEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
});
const amp = createAmpClient();
const result = await amp.invoke('What files are in this directory?');
console.log(result.finalResult);
await shutdownTracing();
```
### With existing OTel setup
If you already have OpenTelemetry configured, skip `initTracing()` - spans will automatically use your existing provider. Pass `parentContext` to nest Amp spans under an existing trace:
```typescript
import { trace, context } from '@opentelemetry/api';
import { createAmpClient } from 'instrument-amp';
const amp = createAmpClient();
// Option 1: Amp spans nest under the current active span automatically
await amp.invoke('prompt');
// Option 2: Explicit parent context (e.g., from incoming request)
const parentContext = trace.setSpanContext(context.active(), {
traceId: requestTraceId,
spanId: requestSpanId,
traceFlags: 1,
});
await amp.invoke('prompt', { parentContext });
```