@agentmug/otel
v12.0.0
Published
OpenTelemetry tracing adapter for @agentmug/runtime. Emits LLM-call + transcription spans/events into your existing OTel SDK pipeline (Honeycomb, Datadog, Jaeger, Tempo, Sentry, anything OTel-compatible).
Maintainers
Readme
@agentmug/otel
OpenTelemetry tracing adapter for @agentmug/runtime. Emits LLM-call + transcription spans into your existing OTel SDK pipeline — Honeycomb, Datadog, Tempo, Jaeger, Sentry, anything that consumes OpenTelemetry.
npm install @agentmug/otel @opentelemetry/api
# plus whichever OTel SDK + exporter your stack usesUsage
Set up your OTel SDK once at process start (you almost certainly already have this in your app). Then plug the adapter into runAgent():
import { runAgent } from "@agentmug/runtime";
import { OtelTracingAdapter } from "@agentmug/otel";
const result = await runAgent({
agentId: "...",
userId: "...",
userInput: "...",
adapters: {
persistence: yourPersistence,
llm: yourLlmClient,
tracing: new OtelTracingAdapter(), // ← that's it
},
onEvent: () => {},
});Every LLM call becomes a span with these attributes:
agentmug.run.idagentmug.agent.idagentmug.llm.modelagentmug.llm.tokensagentmug.llm.cost_centsagentmug.llm.latency_msagentmug.llm.input_preview(truncated to 512 chars)agentmug.llm.output_preview(truncated to 512 chars)
Transcription calls get their own spans with provider + audio token counts.
As a plugin
If you'd rather wire via the plugin API:
import { InMemoryToolRegistry } from "@agentmug/runtime";
import { createOtelPlugin } from "@agentmug/otel";
const tools = new InMemoryToolRegistry();
tools.loadPlugin(createOtelPlugin());
// the tracing adapter is now available on the plugin's adapters bundleCustom tracer
Pass your own Tracer if you need per-tenant tracing, test isolation, or want to attach resource attributes:
import { trace } from "@opentelemetry/api";
new OtelTracingAdapter({
tracer: trace.getTracer("my-app/agentmug", "2.1.0"),
});What this doesn't do
- SDK setup — every OTel pipeline is different. Configure your
NodeSDK/WebSDK/ exporter as you normally would. - Metrics — token counts live as span attributes. If you want histograms, derive them from spans in your backend.
- Logs — the runtime's
onEventcallback gives you token-by-token output. Wire that to your logging pipeline directly.
License
MIT
