# @agentmug/otel

> OpenTelemetry-compatible tracing for AgentMug worker execution. Emits LLM-call and transcription spans/events into your existing OTel SDK pipeline (Honeycomb, Datadog, Jaeger, Tempo, Sentry).

Latest version **17.0.0** (published 2026-08-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @agentmug/otel
pnpm add @agentmug/otel
yarn add @agentmug/otel
bun add @agentmug/otel
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 17.0.0 |
| Published | 2026-08-12 |
| First published | 2026-06-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 25.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Maintainers | dahshanlabs |
| Keywords | ai, agent, agentmug, opentelemetry, otel, tracing, observability, honeycomb, datadog, ai-worker |

## Links

- npm: https://www.npmjs.com/package/@agentmug/otel
- Repository: https://github.com/dahshanlabs/agentmug-core
- Homepage: https://agentmug.com
- Issues: https://github.com/dahshanlabs/agentmug-core/issues
- npm.io page: https://npm.io/package/@agentmug/otel

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 17.0.0 (latest) — 2026-08-12
- 15.0.0 — 2026-08-05
- 13.0.0 — 2026-07-28
- 12.0.0 — 2026-07-12
- 11.0.0 — 2026-07-04
- 10.0.0 — 2026-07-02
- 9.0.0 — 2026-06-18
- 8.0.0 — 2026-06-16
- 6.0.0 — 2026-06-16
- 5.0.0 — 2026-06-16
- 4.0.0 — 2026-06-15
- 3.0.0 — 2026-06-11
- 2.0.0 — 2026-06-03
- 0.1.0 — 2026-06-01

## README

# @agentmug/otel

OpenTelemetry tracing adapter for [@agentmug/runtime](https://npmjs.com/package/@agentmug/runtime). Emits LLM-call + transcription spans into your existing OTel SDK pipeline — Honeycomb, Datadog, Tempo, Jaeger, Sentry, anything that consumes OpenTelemetry.

```bash
npm install @agentmug/otel @opentelemetry/api
# plus whichever OTel SDK + exporter your stack uses
```

## Usage

Set up your OTel SDK once at process start (you almost certainly already have this in your app). Then plug the adapter into `runAgent()`:

```typescript
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.id`
- `agentmug.agent.id`
- `agentmug.llm.model`
- `agentmug.llm.tokens`
- `agentmug.llm.cost_cents`
- `agentmug.llm.latency_ms`
- `agentmug.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

`createOtelPlugin()` packages the adapter as an `AgentMugPlugin`, which is handy
if you already pass plugins around. **It does not register tracing by itself** —
`InMemoryToolRegistry.loadPlugin` only reads `plugin.tools`, and this plugin
ships no tools. You still have to hand the adapter to `runAgent`:

```typescript
import { createOtelPlugin } from "@agentmug/otel";

const otelPlugin = createOtelPlugin();

await runAgent({
  // ...
  adapters: { tracing: otelPlugin.adapters.tracing },
});
```

If you are not already routing plugins through your own wiring, construct
`OtelTracingAdapter` directly as shown above — it is the same instance.

## Custom tracer

Pass your own `Tracer` if you need per-tenant tracing, test isolation, or want to attach resource attributes:

```typescript
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 `onEvent` callback gives you token-by-token output. Wire that to your logging pipeline directly.

## License

Apache-2.0. Existing versions published under MIT remain MIT.

---
_Source: https://npm.io/package/@agentmug/otel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
