Observability & Governance: Using OTEL, Guardrails & Metrics with MCP Workflows
Written by Om-Shree-0709 on .
- Implementing Observability & Governance in MCP and Strands
- What Happens Behind the Scenes
- Visualizing & Analyzing Observability Data
- Conclusion
- References
In previous articles, we explored how to build, integrate, and deploy Strands Agents SDK with the Model Context Protocol (MCP) for dynamic tool usage and reasoning123. While these agents are functional and scalable, deploying them in production environments demands more than just reliability—it requires visibility and control.
Without observability, it is difficult to trace how an agent made a decision, which tools were invoked, or why certain failures occurred. Similarly, without governance mechanisms like guardrails, agents might make unsafe or inefficient calls, leading to unpredictable outcomes.
In this article, we’ll demonstrate:
- How to add OpenTelemetry (OTEL) for tracing and metrics.
- How to implement governance guardrails within MCP tools.
- How these capabilities work together to monitor, audit, and optimize agentic workflows.
Implementing Observability & Governance in MCP and Strands
a. Adding OpenTelemetry to MCP & Strands Agents
To monitor both MCP tool execution and agent decisions, we can integrate OTEL tracing45.
Installation:
OTEL Setup in MCP Server:
Agent Side Instrumentation: Similarly, you can wrap the agent reasoning process with spans to trace which tools the LLM decides to invoke6.
b. Defining Guardrails on MCP Tools
Guardrails add runtime checks and constraints to ensure tools are used appropriately.
This ensures any misuse of the tool by the agent is caught early, keeping operations within safe parameters.
c. Capturing Custom Metrics
You can also capture quantitative metrics, such as invocation counts or latency.
What Happens Behind the Scenes
Once integrated:
- The Strands Agent, when reasoning over a user prompt, emits OTEL spans capturing which tools it intends to invoke45.
- Upon calling an MCP tool, the MCP server logs a trace span for the tool execution.
- If a tool includes guardrails, violations are raised and logged as part of the trace error details.
- Simultaneously, metrics like tool invocation count, success/failure rates, and execution durations are collected.
- All telemetry is exported to an observability backend like Grafana, AWS X-Ray, or Langfuse for visualization and audit7.
This structured flow ensures you can:
- Debug why an agent took a specific action.
- Monitor operational health in real-time.
- Validate that governance rules are effectively enforced.
Visualizing & Analyzing Observability Data
Once telemetry is wired, you can visualize traces and metrics through various platforms:
- Grafana OTEL dashboards: Visualize tool latency, agent reasoning steps, and invocation frequency.
- AWS X-Ray: Trace the end-to-end request from the agent through MCP tools.
- Langfuse: Integrates with Strands SDK for agent-specific logs and evaluations8.
Example Grafana panel queries:
- Number of tool calls per hour
- Average latency per tool
- Error rates per MCP endpoint
Conclusion
Bringing observability and governance into your MCP + Strands setup isn’t just about monitoring—it’s about making these systems understandable and accountable. With tracing, metrics, and guardrails in place, teams can confidently manage agents in real-world environments. Looking ahead, these practices will be essential as agent workflows become more complex and need stronger assurances around safety, reliability, and auditability.
References
Footnotes
Written by Om-Shree-0709 (@Om-Shree-0709)