Trace
Groups related cost events under a single trace ID. Useful for tracking multi-step agent workflows.
Usage
import { NeuraMeter } from '@neurameter/core';
const meter = new NeuraMeter({
apiKey: 'nm_xxx',
projectId: 'proj_xxx',
});
const trace = meter.startTrace({
agentName: 'ResearchAgent',
customerId: 'cust_456',
taskName: 'market-analysis',
tags: { department: 'analytics' },
});TraceOptions
interface TraceOptions {
agentName: string;
customerId?: string;
taskName?: string;
tags?: Record<string, string>;
}| Field | Required | Description |
|---|---|---|
agentName | Yes | Name of the agent |
customerId | No | Customer ID for cost attribution |
taskName | No | Task name for grouping |
tags | No | Arbitrary key-value metadata |
How It Works
When you create a trace via meter.startTrace(), a shared traceId is generated. All events recorded through that trace instance share the same traceId, making it easy to query related events in the dashboard.
Each individual event still gets its own unique spanId.
Dashboard
Traces are visible in the dashboard at /dashboard/traces. Click on a trace to see all events within it, including:
- Total cost across all spans
- Latency breakdown
- Token usage per span
- Model distribution