Observability
@radaros/observability is a separate, opt-in package that adds tracing, metrics, and structured logging to any RadarOS agent. It listens to the agent’s EventBus from the outside — zero changes to core, zero overhead when not installed.
Quick Start
Exporter Shorthands
Pass exporter names as strings — credentials are read from env vars automatically:How It Works
Theinstrument() function attaches three listeners to the agent’s EventBus:
- Tracer — builds a span tree from events (
run.start→tool.call→tool.result→run.complete) - MetricsCollector — counts runs, tool calls, errors, cache hits, and tracks latency histograms
- StructuredLogger — emits JSON log entries correlated with trace IDs
Trace Tree
Everyagent.run() produces a trace like:
Exporters
| Shorthand | Env Vars | Description |
|---|---|---|
"console" | — | Pretty-print trace tree to terminal |
"langfuse" | LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY | Native Langfuse format with generations and spans |
"otel" | OTEL_EXPORTER_OTLP_ENDPOINT | OTLP/HTTP JSON to any OpenTelemetry collector |
"json-file" | — | Append traces to a JSON file |
CallbackExporter for custom integrations:
Metrics
Structured Logging
Three drain modes:traceId for correlation with traces.
Works With Teams & Workflows
UseinstrumentBus() to attach to any EventBus: