Skip to main content
Welcome — in this lesson you’ll learn how to add distributed tracing to AI agents running with KAgent and inspect traces in Jaeger. As agent ecosystems grow, visibility into agent actions and their LLM interactions is essential for debugging, cost analysis, and observability. Objectives:
  • Introduce Jaeger and the minimal configuration used in this lab.
  • Install Jaeger (all-in-one, in-memory) and KAgent.
  • Configure KAgent to export OpenTelemetry (OTEL) traces to Jaeger.
  • Generate agent traffic and inspect the traces in the Jaeger UI.
This lab focuses on integrating KAgent with an OTEL backend; Jaeger is used as a simple example. KAgent supports exporting to any OTEL-compatible backend.
This lesson uses Jaeger in all-in-one (development) mode with in-memory storage. Traces are transient and will be lost if the Jaeger pod restarts.

1. Jaeger configuration (all-in-one, in-memory)

The Helm values below run Jaeger in all-in-one mode with in-memory storage — suitable for development and short-lived labs. Because storage is memory, traces are not persisted across restarts.
Ports and OTEL endpoints to be aware of:
  • Jaeger UI (query): port 16686.
  • Jaeger collector OTLP: port 4317 (gRPC) and 4318 (HTTP/protobuf). In this lab we point KAgent to the OTLP gRPC endpoint (4317).
Install Jaeger using Helm (example chart version 3.4.1 used in this lab):

2. KAgent values (enable OTEL tracing)

The trimmed KAgent values file below enables a minimal set of agents and configures OTEL tracing to send data to the Jaeger collector via OTLP gRPC. The critical section is otel.tracing.exporter.otlp.endpoint.
Install KAgent with Helm:
CRDs and ModelConfig are assumed to be pre-installed for this lab.

3. Patch the KAgent UI service for external (lab) access

In the lab environment we expose the KAgent UI externally by changing the service type to NodePort and mapping port 8080 to node port 30080. The JSON payload contains curly braces and is provided as a code block to avoid MDX parsing issues.
Verify pods are running in the kagent namespace:
Example expected output:
If any pod is not ready, investigate with kubectl describe and kubectl logs.

4. Generate agent traffic and inspect traces in Jaeger

With KAgent exporting OTEL traces to Jaeger, exercise the agent (for example: list pods, query deployments, or perform model calls via the KAgent UI). These activities generate traces that appear in Jaeger. Steps to inspect traces:
  1. Open the KAgent UI and use the built-in link to the Jaeger UI (or open Jaeger at the cluster-exposed query endpoint).
  2. In Jaeger:
    • Select the kagent service (or KAgent depending on naming).
    • Filter by operation (e.g., openai.chat) and choose an appropriate time range.
    • Open individual traces to expand spans and view tags.
When viewing a trace you can expect to see:
  • Services involved and span hierarchy.
  • Start timestamps and durations per span.
  • Tags containing LLM prompt content and token usage (e.g., genai.usage.prompt_tokens).
  • OTEL instrumentation metadata (e.g., otel.library.name, otel.library.version).
Example system prompt captured in a trace:
Example trace metadata snippet showing prompt content, timing, and OTEL library information:
Note: token usage tags (genai.usage.prompt_tokens, genai.usage.completion_tokens, etc.) are useful for cost analysis and assessing how much context is being sent to the model.
This lab uses in-memory Jaeger storage. For production systems, do not use in-memory storage — switch to a persistent backend (e.g., Cassandra, Elasticsearch) or a managed OTEL backend to retain traces and ensure availability.

5. Inspect Jaeger services and endpoints

You can validate the services created by the Helm chart to confirm the collector and query endpoints: If you need details on any specific service or endpoint:

Wrap-up and recommendations

  • This lesson demonstrated configuring Jaeger (all-in-one, in-memory) and KAgent to export OTEL traces to Jaeger.
  • Use the KAgent UI and Jaeger UI to inspect agent traces, including LLM prompts and token usage for debugging and cost analysis.
  • For production:
    • Replace in-memory Jaeger storage with a persistent backend (Cassandra, Elasticsearch) or a managed OTEL backend.
    • Deploy Jaeger (or OTEL collector) in a highly available configuration.
    • Secure OTLP endpoints with TLS and authentication where supported.
Next steps: run additional agents, increase load, or integrate with a persistent OTEL backend to observe trace retention and scale behavior. That’s it for this lesson — proceed to hands-on exercises to generate traces and explore span details in Jaeger.

Watch Video