
Prerequisites
Set the following environment variables before running your agent:Install Koog (Gradle)
Add Koog to your Kotlin project (Kotlin DSL shown):Enable Weave export (OpenTelemetry)
Install Koog’s OpenTelemetry feature and add the Weave exporter. This maps Koog spans to Weave traces using Weave’s OpenTelemetry endpoint. The following example shows how to use theaddWeaveExporter
:
- Uses
weaveEntity
andweaveProjectName
to route traces to a specific team and project. - Sets
weaveOtelBaseUrl
to your trace endpoint (for example,https://<your-subdomain>.wandb.io/<path>
). Use the parameter for dedicated Weave instances.
- Koog’s Weave exporter guide for additional information about the exporter
- Koog’s OpenTelemetry support guide for core concepts about how OpenTelemetry works with Koog
- Weave OTEL docs for information about how Weave ingests OTLP data
What gets traced
When enabled, Koog’s Weave exporter captures the same spans as Koog’s general OTEL integration, including:- Agent lifecycle events (start, stop, errors)
- LLM interactions (prompts, completions, token usage, latency)
- Tool and API calls (function calls and external requests)
- System context (model name, Koog version, environment metadata)
Example notebook
See Koog’s documentation for a runnable notebooks that streams traces to Weave.Troubleshooting
- If traces are missing, first verify that
WEAVE_API_KEY
,WEAVE_ENTITY
, andWEAVE_PROJECT_NAME
are set correctly. - Confirm your environment can reach
https://trace.wandb.ai
and that the exporter is configured as shown above. - For additional troubleshooting and sampling guidance, see Koog’s OpenTelemetry support.