Skip to main content

Install

Instrument

instrument_crewai wraps a single Crew instance. Call it once per crew — after construction, before kickoff().

What gets captured

  • A crew root span around every kickoff() call, with the inputs as span input and the final crew result as output.
  • One agent child span per agent task execution, nested under the crew span.
  • tool spans for any @tool-decorated functions invoked by an agent.
  • LLM calls inside agents produce llm spans when the underlying provider (OpenAI, Anthropic, etc.) is also instrumented — combine with instrument_openai / instrument_anthropic.

Known gotchas

  • One crew, one call. Each instrument_crewai call binds to a specific Crew instance. Re-instrumenting the same crew is a no-op; instantiating a new crew requires a new call.
  • Trace context is required. Unlike instrument_openai, this function needs an active TraceContext passed in — call it inside a with trulayer.trace(...) block or pass an explicit trace.
  • Parallel tasks. When Crew(process="hierarchical") runs tasks in parallel, span parent-child order still reflects the logical task graph (not wall-clock nesting).