Skip to main content

OpenTelemetry instrumentation for Crewai

Project description

Crewai OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the Crewai framework. It enables tracing and monitoring of applications built with Crewai.

Installation

  1. Install traceAI Crewai
pip install traceAI-crewai
  1. Install Crewai and Crewai_tools
pip install crewai crewai_tools

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="crewai_app"
)

Configure Crewai Instrumentation

Instrument the Crewai client to enable telemetry collection. This step ensures that all interactions with the Crewai SDK are tracked and monitored.

from traceai_crewai import CrewAIInstrumentor

CrewAIInstrumentor().instrument(tracer_provider=trace_provider)

Create Crewai Components

Set up your Crewai client with built-in observability.

from crewai import LLM, Agent, Crew, Process, Task
from crewai_tools import SerperDevTool

def story_example():
    llm = LLM(
        model="gpt-4",
        temperature=0.8,
        max_tokens=150,
        top_p=0.9,
        frequency_penalty=0.1,
        presence_penalty=0.1,
        stop=["END"],
        seed=42,
    )

    writer = Agent(
        role="Writer",
        goal="Write creative stories",
        backstory="You are a creative writer with a passion for storytelling",
        allow_delegation=False,
        llm=llm,
    )

    writing_task = Task(
        description="Write a short story about a magical forest",
        agent=writer,
        expected_output="A short story about a magical forest",
    )

    crew = Crew(agents=[writer], tasks=[writing_task])

    # Execute the crew
    result = crew.kickoff()
    print(result)

if __name__ == "__main__":
    story_example()

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

traceai_crewai-0.1.7.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

traceai_crewai-0.1.7-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file traceai_crewai-0.1.7.tar.gz.

File metadata

  • Download URL: traceai_crewai-0.1.7.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_crewai-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a90f938d1a41841863733cd56573d23081747736a5a26f448d8032706d660ca6
MD5 63d26450d39375ef04b900755a8f5111
BLAKE2b-256 345ad99bcd48e625013a043b6989e6501468e19e0acfafab067e3709b2e4b2f1

See more details on using hashes here.

File details

Details for the file traceai_crewai-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: traceai_crewai-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_crewai-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b0754309b8474af30849b659f9ec8a73593eb73e99db29ca35b6fa7e827d5941
MD5 d425754cb9bf41c937062b8f6dfab6de
BLAKE2b-256 0b4d1d83cfa0b1b11f5759b2d433a65b4688e4e18d297abf195d5d0f1d6e6ad0

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