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.2.tar.gz (13.6 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.2.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 70489e7c4dc2af7f6199b71cc70f774b93e8b4394c419cd8307e0f1c3c89f41b
MD5 a056177cd3b69e6c0ad95582d6fbdd5f
BLAKE2b-256 76e7d9d385d035a935bb2e713da8c26b2bb2c11637d26418df2142b2cb76666c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for splunk_otel_instrumentation_crewai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a078383bdacdd239f56c50ff205a80916e037fa6cd39166d552b56b9da9a499
MD5 adfa7dc62ff72ccdd4e4b73edb5e6010
BLAKE2b-256 5c5f0a2b498192ef3c6a917b723a09aaaf52c021d621ea06f8054658581f29ef

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