Skip to main content

ATI Integration for CrewAI

This package provides OpenTelemetry instrumentation for CrewAI agents using Iocane ATI.

It automatically captures:

  • Agent execution: Task assignments, inputs, outputs, and execution time.
  • Crew orchestration: The overall planning and delegation flow.

Installation

pip install ati-integrations-crewai opentelemetry-sdk opentelemetry-exporter-otlp

Configuration

Set the standard OpenTelemetry environment variables to point to your Iocane collector:

export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.iocane.ai/v1/traces"
export OTEL_EXPORTER_OTLP_HEADERS="x-iocane-key=YOUR_KEY,x-ati-env=YOUR_ENV_ID"
export OTEL_SERVICE_NAME="my-crewai-agent"

Usage

Here is the robust pattern for instrumenting CrewAI scripts.

Important: Because CrewAI or other libraries might initialize OpenTelemetry internally, it is best practice to attempt to set the provider, but always retrieve the active global provider to attach your exporters.

import os
from ati_crewai import CrewAIInstrumentor
from crewai import Agent, Crew, Process, Task
from langchain_openai import ChatOpenAI

# OpenTelemetry Imports
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.resources import Resource, SERVICE_NAME
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

def main():
    # 1. Configure OpenTelemetry (Robust Pattern)
    resource = Resource.create(attributes={SERVICE_NAME: "my-crew-service"})
    
    try:
        # Try to set the global provider
        provider = TracerProvider(resource=resource)
        trace.set_tracer_provider(provider)
    except Exception:
        # If it fails (e.g., already set), ignore and fetch the active one below
        pass

    # ALWAYS get the global provider to ensure we attach to the active pipeline
    provider = trace.get_tracer_provider()

    # 2. Configure Exporter (Iocane)
    # Ensure usage of the correct endpoint from env or default
    endpoint = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT")
    if endpoint and endpoint.endswith("/v1/traces"):
        exporter = OTLPSpanExporter(endpoint=endpoint)
    else:
        exporter = OTLPSpanExporter()
        
    # Check if the provider supports add_span_processor (it typically does)
    if hasattr(provider, "add_span_processor"):
        provider.add_span_processor(BatchSpanProcessor(exporter))
    else:
        print("WARNING: TracerProvider does not support add_span_processor.")

    # 3. Instrument CrewAI
    CrewAIInstrumentor().instrument()

    try:
        # 4. Your CrewAI Code
        llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
        
        agent = Agent(role='Researcher', goal='...', backstory='...', llm=llm)
        task = Task(description='...', agent=agent, expected_output='...')
        crew = Crew(agents=[agent], tasks=[task], verbose=True)

        result = crew.kickoff()
        print(result)

    finally:
        # 5. Uninstrument and Flush
        CrewAIInstrumentor().uninstrument()
        if hasattr(provider, "shutdown"):
            provider.shutdown()

if __name__ == "__main__":
    main()

Environment Variables for Instrumentation

Variable Description Default
ATI_CAPTURE_PAYLOADS set to true to capture task descriptions and results as span events false

Metadata

Release files for ati-integrations-crewai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ati-integrations-crewai 0.1.1
File Size Uploaded
ati_integrations_crewai-0.1.1.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ati-integrations-crewai 0.1.1
File Interpreter ABI Platform
ati_integrations_crewai-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / ati_integrations_crewai-0.1.1.tar.gz

Download URL ati_integrations_crewai-0.1.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
70177b0c93bcfc4e344e3c7d04131e69f5f61ebe1d5c8822f165d9c6970d61d3
BLAKE2b-256 checksum
How to use checksums
f5b32c84dc6415cc5bb502c523375e3db8e42945ed8bdb1ddfec951e84c8235d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / ati_integrations_crewai-0.1.1-py3-none-any.whl

Download URL ati_integrations_crewai-0.1.1-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a8dc4d8d914d7b47865780292ed23a95c4591bd328d87a69016ce3434a69d87
BLAKE2b-256 checksum
How to use checksums
8f7d346fdd3c4a0dc666148eb4ee1d8e863a43b6b0fc0a6eb309df437fa87248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page