Skip to main content

OpenTelemetry CrewAI instrumentation

Project description

pypi

This library provides OpenTelemetry instrumentation for CrewAI, a framework for orchestrating autonomous AI agents.

Installation

pip install splunk-otel-instrumentation-crewai

Usage

from opentelemetry.instrumentation.crewai import CrewAIInstrumentor
from crewai import Agent, Task, Crew

# Instrument CrewAI
CrewAIInstrumentor().instrument()

# Create your crew
agent = Agent(
    role="Research Analyst",
    goal="Provide accurate research",
    backstory="Expert researcher with attention to detail",
)

task = Task(
    description="Research the latest AI trends",
    expected_output="A comprehensive report on AI trends",
    agent=agent,
)

crew = Crew(agents=[agent], tasks=[task])

# Run your crew - telemetry is automatically captured
result = crew.kickoff()

What Gets Instrumented

This instrumentation captures:

  • Crews → Mapped to Workflow spans

  • Tasks → Mapped to Step spans

  • Agents → Mapped to AgentInvocation spans

  • Tool Usage → Mapped to ToolCall spans

All spans are properly nested with correct parent-child relationships and include rich attributes about the operation.

Compositional Instrumentation

This instrumentation focuses on CrewAI’s workflow orchestration. For complete observability:

CrewAI Only

from opentelemetry.instrumentation.crewai import CrewAIInstrumentor

CrewAIInstrumentor().instrument()

Provides workflow structure but no LLM call details.

CrewAI + OpenAI

from opentelemetry.instrumentation.crewai import CrewAIInstrumentor
from opentelemetry.instrumentation.openai import OpenAIInstrumentor

CrewAIInstrumentor().instrument()
OpenAIInstrumentor().instrument()

Adds LLM call spans with token usage, model names, and latency metrics.

Full Stack (CrewAI + OpenAI + Vector Store)

from opentelemetry.instrumentation.crewai import CrewAIInstrumentor
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.instrumentation.chromadb import ChromaDBInstrumentor

CrewAIInstrumentor().instrument()
OpenAIInstrumentor().instrument()
ChromaDBInstrumentor().instrument()

Complete RAG workflow visibility with vector store operations.

Configuration

Environment Variables

# Disable CrewAI's built-in telemetry (recommended)
export CREWAI_DISABLE_TELEMETRY=true

Instrumentation Options

from opentelemetry.instrumentation.crewai import CrewAIInstrumentor

# Basic instrumentation
CrewAIInstrumentor().instrument()

# With custom tracer provider
CrewAIInstrumentor().instrument(tracer_provider=my_tracer_provider)

# Uninstrumentation
CrewAIInstrumentor().uninstrument()

Requirements

  • Python >= 3.9

  • CrewAI >= 0.70.0

  • OpenTelemetry API >= 1.38

  • splunk-otel-util-genai >= 0.1.4

Trace Hierarchy Example

Crew: Customer Support (Workflow)
├── Task: inquiry_resolution (Step)
│   └── Agent: Senior Support Representative
│       ├── LLM: gpt-4o-mini (via openai-instrumentation)
│       └── Tool: docs_scrape
└── Task: quality_assurance (Step)
    └── Agent: QA Specialist
        └── LLM: gpt-4o-mini (via openai-instrumentation)

Each span includes rich attributes:

  • gen_ai.system = “crewai”

  • gen_ai.operation.name = “invoke_workflow” | “invoke_agent” | “execute_tool”

  • Framework-specific attributes (agent role, task description, tool names, etc.)

Limitations

  • Async Support: Currently supports synchronous workflows only. Async support (kickoff_async()) is planned for a future release.

  • LLM Calls: Not instrumented here. Use provider-specific instrumentation (e.g., opentelemetry-instrumentation-openai).

Contributing

Contributions are welcome! Please ensure:

  • All tests pass

  • Code follows project style guidelines

  • Instrumentation is defensive (catches exceptions)

  • Documentation is updated

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

splunk_otel_instrumentation_crewai-0.1.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file splunk_otel_instrumentation_crewai-0.1.1.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff1d384fba6f030225e2fb0f6f32f49372c189e9ba50e65053e815aff2578b24
MD5 72ae87e1f6b763807055faa9c2c68d8c
BLAKE2b-256 e46298df68ccc4dd35212aa012007c0911f23c3162db1f3db25d5fcc3cfb29ea

See more details on using hashes here.

File details

Details for the file splunk_otel_instrumentation_crewai-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99500c00412fcf2957771864a8883a51e456ee816d2b0d85f31a71da83bf744f
MD5 9e21f2e7049db55fbd7ae29e31cf01e9
BLAKE2b-256 9fa9a933a8bea3f7b8874bd863e117b7e6e5115ed3d98402e44d062e147e0237

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page