Splyntra
PostShare
Back to all guides
crewaiobservabilityai-agentsmulti-agentopentelemetrytracing

CrewAI Observability: How to Trace and Monitor Multi-Agent Crews

A production guide to observability for CrewAI multi-agent systems. Learn how to trace hierarchical delegations, monitor inter-agent latency, debug tool failures, and track sub-agent LLM costs with OpenTelemetry.

AR
Alex Rivera
Head of Infrastructure & Observability
11 min read

CrewAI has emerged as one of the most popular frameworks for orchestrating autonomous multi-agent teams. By assigning agents distinct roles, goals, backstories, and tools, CrewAI enables complex collaborative workflows—from automated market research to multi-stage code reviews.

However, multi-agent architectures introduce unique operational challenges:

  • When a manager agent delegates sub-tasks to three specialized worker agents, where is latency accumulating?
  • Which agent in the crew repeatedly retries failing tool calls?
  • How much does each agent in the crew contribute to total token spend?

This guide demonstrates how to implement CrewAI Observability using standard OpenTelemetry distributed tracing and Splyntra.


The Hierarchy of a CrewAI Execution Trace

In CrewAI, execution operates in either Sequential or Hierarchical mode. In hierarchical mode, a manager agent plans tasks, delegates to specialist agents, and synthesizes results.

Root Span: crewai.crew_execution (Crew: "Investment Research Team")
│
├── Span: crewai.agent.task (Agent: "Lead Financial Analyst")
│   ├── Span: llm.generate (Model: "gpt-4o", tokens: 2100)
│   └── Span: crewai.delegate (To: "Securities Researcher")
│       │
│       └── Span: crewai.agent.task (Agent: "Securities Researcher")
│           ├── Span: tool.financial_api (Endpoint: "/v1/stocks/AAPL")
│           └── Span: llm.generate (Model: "claude-3-5-haiku", tokens: 950)
│
└── Span: crewai.agent.task (Agent: "Risk & Compliance Officer")
    ├── Span: security.risk_scan (Risk Score: 0.04)
    └── Span: llm.generate (Model: "gpt-4o", tokens: 1800)

1. Instrumenting CrewAI Agents with OpenTelemetry

Here is how to wrap CrewAI agent task executions, model generations, and tool invocations with standard OpenTelemetry spans:

from crewai import Agent, Task, Crew, Process
from opentelemetry import trace
from opentelemetry.trace import Status, StatusCode

tracer = trace.get_tracer("splyntra.crewai", "1.0.0")

def create_traced_crew(topic: str) -> Crew:
    with tracer.start_as_current_span(
        "crewai.setup",
        attributes={"crewai.topic": topic}
    ):
        # 1. Define Specialist Agents
        researcher = Agent(
            role='Senior Research Analyst',
            goal=f'Conduct in-depth technical research on {topic}',
            backstory='You are a seasoned research scientist who values primary sources.',
            verbose=False,
            memory=True
        )

        writer = Agent(
            role='Technical Content Strategist',
            goal=f'Draft a comprehensive engineering brief on {topic}',
            backstory='You translate complex technical data into concise architectural summaries.',
            verbose=False
        )

        # 2. Define Tasks
        task1 = Task(
            description=f'Research recent OpenTelemetry GenAI standards for {topic}.',
            expected_output='Key findings with source URLs.',
            agent=researcher
        )

        task2 = Task(
            description='Synthesize research findings into a production readiness report.',
            expected_output='Structured markdown document.',
            agent=writer
        )

        # 3. Assemble Hierarchical Crew
        crew = Crew(
            agents=[researcher, writer],
            tasks=[task1, task2],
            process=Process.sequential,
            verbose=False
        )
        
        return crew

def run_production_crew(topic: str):
    crew = create_traced_crew(topic)
    
    # Root Crew Span
    with tracer.start_as_current_span(
        "crewai.run",
        attributes={
            "gen_ai.system": "crewai",
            "crewai.agent_count": 2,
            "crewai.task_count": 2,
            "crewai.topic": topic,
        }
    ) as root_span:
        try:
            result = crew.kickoff()
            root_span.set_attribute("crewai.output_characters", len(str(result)))
            root_span.set_status(Status(StatusCode.OK))
            return result
        except Exception as e:
            root_span.record_exception(e)
            root_span.set_status(Status(StatusCode.ERROR, str(e)))
            raise e

2. Multi-Agent Spend Breakdown in Splyntra

One of the biggest advantages of per-span OpenTelemetry telemetry is breaking down costs by agent role:

┌─────────────────────────────────────────────────────────────┐
│                 CREW SPEND BREAKDOWN BY ROLE                │
├─────────────────────────────────────────────────────────────┤
│ • Lead Analyst (Planning / Synthesis):  $0.052  (62% spend) │
│ • Web Researcher (Scraping / Extract):  $0.019  (23% spend) │
│ • Formatter (Haiku Extraction):         $0.012  (15% spend) │
├─────────────────────────────────────────────────────────────┤
│ Total Crew Execution Spend:             $0.083 per run      │
└─────────────────────────────────────────────────────────────┘

This telemetry immediately reveals optimization opportunities—for example, downshifting the research agent from gpt-4o to gpt-4o-mini while keeping the frontier model for the Lead Analyst.


3. Key CrewAI Metrics to Monitor in Production

  1. Delegation Hop Latency: Time elapsed between task assignment and worker completion.
  2. Inter-Agent Communication Overhead: Tokens consumed in agent-to-agent prompt messages vs. end-user outputs.
  3. Agent Memory Deserialization Time: Latency overhead of persistent vector memory queries during task transitions.
  4. Tool Failure Retries by Agent: Pinpointing which agent role struggles with tool argument schemas.

AR
Alex Rivera
Head of Infrastructure & Observability

Building the unified OpenTelemetry observability, risk scoring, and FinOps control plane for autonomous AI agents.

Related Technical Guides

Explore more deep dives on OpenTelemetry, agent security, and FinOps.

See your agents clearly with Splyntra

Trace, evaluate, secure, and govern your AI agents on one OpenTelemetry pipeline — every run, with a risk score.

Back to all posts