Skip to content

c-ehrlich/trace-amp

Repository files navigation

trace-amp

OpenTelemetry instrumentation for Amp CLI.

Amp trace in Axiom

Fully vibe coded, use at your own risk.

Installation

npm install -g trace-amp

Usage

Set the required environment variables:

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:

trace-amp "ask the oracle to add 2+2"

Or use npx without installing globally:

npx trace-amp "ask the oracle to add 2+2"

TypeScript Usage

Standalone (new OTel setup)

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:

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 });

About

OTel Tracing wrapper for Amp

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors