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.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

traceai_crewai-0.1.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_crewai-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 9489e4da10e4badd0d12996ea41c81edd2b90e33c5d11422033dbd52feacd22c
MD5 e5f100a5e7d1c4793d24f5db6f3a04b3
BLAKE2b-256 174bd565b5e21909c4560c78ef6f76c7203e7a57471bf537e81bcdc4b8175672

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_crewai-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 859e818c30bbb904d496019750d279461d3076411f0e8aacd31c1831d93a996a
MD5 15e8ceab7113d731f4a2de5af0074a30
BLAKE2b-256 d314e537807b689056ff0797857c1a8a14a83c545915cc59edf26646ad4a90c4

See more details on using hashes here.

Supported by

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