By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
When a traditional application fails, it throws an exception and stops. When an agent fails, it returns a confident, wrong answer and keeps going. You have no stack trace, no error message—just a user saying the result was bad. To fix it, you need to see the entire chain: what prompt was sent, which model calls happened, what tools were invoked, what data they returned, and how long each step took.
Observability for agents centers on two concepts. A span is one timed operation: a model call, a tool invocation, a memory lookup. A trace is the complete tree of spans for a single user request, from start to finish. Think of a trace as a timeline showing every decision the agent made and how long it spent on each one.
A session groups all traces from one conversation together. Metrics are the numbers you track over time: latency, error rates, token consumption, how many times each tool was called.
The diagram above shows what a real trace looks like. One user question triggers the agent, which calls the model to decide what to do, invokes a tool, retrieves memory, and calls the model again for the final answer. Each box is a span. The total time is 4.2 seconds. If the answer was wrong, you can now see exactly where the problem occurred.
AgentCore Observability emits standard OpenTelemetry (OTEL) data. This means it works with CloudWatch's GenAI Observability dashboard out of the box, and it also works with any other OTEL-compatible observability tool you already own. You are not locked into a proprietary format.
Start with a one-time account setup: enable CloudWatch Transaction Search. Spans take around ten minutes to become searchable the first time, so don't be alarmed by the delay.
If your agent runs on AgentCore Runtime, you are done. Instrumentation happens automatically. Deploy, invoke, open the dashboard.
If your agent runs elsewhere, add three things. First, install aws-opentelemetry-distro in your requirements.txt. Second, set two environment variables: AGENT_OBSERVABILITY_ENABLED=true and OTEL_PYTHON_CONFIGURATOR=aws_configurator. Third, start your agent with the opentelemetry-instrument command.
# Agent NOT hosted on AgentCore Runtime
pip install aws-opentelemetry-distro
export AGENT_OBSERVABILITY_ENABLED=true # activates the ADOT pipeline
export OTEL_PYTHON_CONFIGURATOR=aws_configurator
opentelemetry-instrument python agent.py
When a user reports a bad answer, follow this routine. Step 1: Find their session ID in the GenAI Observability dashboard. Step 2: Open the trace and ask two questions: did the model pick the wrong tool, or did the tool return bad data. Step 3: Look at span durations. A slow span is a bottleneck. Step 4: Fix the prompt, the tool description, or the code. Ship a new Runtime version. Compare the old trace to the new one.
This cycle—observe, diagnose, fix, compare—is how you iterate on agent behavior in production.
Don't log secrets or full personal data into traces. Observability data is sensitive; apply the same access controls as production data.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.