OpenInference CrewAI Instrumentation
raw JSON → 1.1.3 verified Mon Apr 27 auth: no python
OpenTelemetry instrumentation for CrewAI agents and tasks, enabling distributed tracing and observability via the OpenInference semantic conventions. Version 1.1.3, supports Python 3.10 to 3.13, part of the Arize AI openinference ecosystem. Released as needed alongside crewai updates.
pip install openinference-instrumentation-crewai Common errors
error ImportError: cannot import name 'CrewAIInstrumentor' from 'openinference.instrumentation.crewai' ↓
cause Old import path using underscore or incorrect package name.
fix
Use
from openinference.instrumentation.crewai import CrewAIInstrumentor. error opentelemetry.sdk.trace.TraceError: failed to set tracer provider ↓
cause TracerProvider not set before instrumentation.
fix
Call
trace.set_tracer_provider(TracerProvider()) before CrewAIInstrumentor().instrument(). error TypeError: 'NoneType' object is not callable ↓
cause Instrument() called without setting up a span processor or exporter; spans have no destination.
fix
Add a span processor, e.g.,
trace.get_tracer_provider().add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter())). Warnings
breaking Requires Python 3.10+ and crewai version >=0.30.0. Older crewai versions are not supported and will fail to instrument. ↓
fix Upgrade crewai to latest version (pip install --upgrade crewai).
gotcha Must call instrument() before importing or instantiating crewai components to ensure proper monkey-patching. If instrument() is called after crewai is already loaded, it may not work correctly. ↓
fix Reorder imports: call instrument() before any crewai imports, or use suppress_imports=True and then import crewai after instrument().
deprecated The module `openinference_instrumentation_crewai` (underscore style) is deprecated; use `openinference.instrumentation.crewai` (dot style). ↓
fix Use `from openinference.instrumentation.crewai import CrewAIInstrumentor`.
Imports
- CrewAIInstrumentor
from openinference.instrumentation.crewai import CrewAIInstrumentor
Quickstart
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
from openinference.instrumentation.crewai import CrewAIInstrumentor
# Set up OTEL tracing
trace.set_tracer_provider(TracerProvider())
span_processor = SimpleSpanProcessor(ConsoleSpanExporter())
trace.get_tracer_provider().add_span_processor(span_processor)
# Instrument CrewAI
CrewAIInstrumentor().instrument()
# Now run CrewAI code; spans will be exported to console
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("example"):
# Your CrewAI agent/task code here
pass