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.3.tar.gz (16.5 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.3.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 00c0a66ce85ee46441fc35849410a1a85b31b4fab7bf461cd27983de288801f1
MD5 b099b30e0e75a1313b9dfb3f3868358a
BLAKE2b-256 1a89db3072c13ade35a8dfc41e9700992c2b18a9bc10a4fa4e1fde161b01252b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 974ff023763daedfc3c89f823ba2f614e1040d27623f86294eeac4cd21664f53
MD5 a656f6cbe5679cc0255cdaabf84bda7e
BLAKE2b-256 ab1853cdf228784aa6abc5278f61739f33931fda7791690e284bc8e7edb8f217

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