Musterby Elitery
Integrations

Koog (Kotlin)

Trace Kotlin AI agents built with Koog in Muster via the built-in OpenTelemetry exporter.

Koog is a Kotlin-based framework for building and running AI agents in idiomatic Kotlin. Muster captures Koog agent runs through the framework's built-in OpenTelemetry feature.

Setup

1. Configure credentials

export LANGFUSE_BASE_URL="https://app.getmuster.io"   # or your self-hosted Muster URL
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."

2. Install OpenTelemetry feature with the Langfuse exporter

fun main() = runBlocking {
    val agent = AIAgent(
        executor = simpleOpenAIExecutor(ApiKeyService.openAIApiKey),
        llmModel = OpenAIModels.CostOptimized.GPT4oMini,
        systemPrompt = "You are a code assistant. Provide concise code examples.",
    ) {
        install(OpenTelemetry) {
            addLangfuseExporter()
        }
    }

    println("Running agent with Muster tracing")

    val result = agent.run("Tell me a joke about programming")

    println("Result: $result")
}

Captured telemetry

The exporter captures:

  • Agent lifecycle events — start, stop, errors.
  • LLM interactions — prompts, responses, token usage, latency.
  • Tool and API calls — function/tool invocation traces.
  • System context — model name, environment, Koog version.

Span attributes also feed Muster Agent Graphs, correlating agent reasoning with API calls and user inputs.

Koog example trace in Muster

Troubleshooting

  • No traces appear — verify LANGFUSE_BASE_URL, LANGFUSE_PUBLIC_KEY, and LANGFUSE_SECRET_KEY are set.
  • Self-hosted instance — confirm the base URL is reachable from the JVM.
  • Wrong project — make sure the credentials match your intended Muster project.

See also