-
Notifications
You must be signed in to change notification settings - Fork 24
Add OpenTelemetry instrumentation for CrewAI #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
81ee17a
Add OpenTelemetry instrumentation for CrewAI
whoIam0987 15b1da2
Support CrewAI Tracing
whoIam0987 592e6ec
1 support CrewAI uninstrument;
whoIam0987 544f9e3
fix the CI failure.
whoIam0987 a761b91
Maintain a consistent style for status settings.
whoIam0987 f5f095e
Refactor and modify the corresponding unit tests using genai 0.3b0;
whoIam0987 9a565a1
Fix dependency problem in pyproject.toml
whoIam0987 a33bb99
Added these tests as github workflows;
whoIam0987 f9925c2
Use vcrpy to record tests to avoid relying on real requests;
whoIam0987 01a5203
Supplement missing test dependencies.
whoIam0987 753cded
Set the genai.span.kind extended attribute.
whoIam0987 94a622b
Modify the version of genai-util as a dependency.
whoIam0987 91fe3cd
Fix missing license header
whoIam0987 ac7ba99
1 This LISENSE file has been removed;
whoIam0987 a50ff03
polish
whoIam0987 0bc4283
test-requirements fixed.
whoIam0987 390d612
polish again
whoIam0987 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
instrumentation-loongsuite/loongsuite-instrumentation-crewai/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## Unreleased | ||
|
|
||
| ### Added | ||
|
|
||
| - Initialize the instrumentation for CrewAI | ||
| ([#87](https://github.com/alibaba/loongsuite-python-agent/pull/87)) | ||
53 changes: 53 additions & 0 deletions
53
instrumentation-loongsuite/loongsuite-instrumentation-crewai/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # LoongSuite CrewAI Instrumentation | ||
|
|
||
| This library provides automatic instrumentation for [CrewAI](https://www.crewai.com/), a framework for orchestrating role-playing, autonomous AI agents. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| git clone https://github.com/alibaba/loongsuite-python-agent.git | ||
| cd loongsuite-python-agent | ||
| pip install ./instrumentation-loongsuite/loongsuite-instrumentation-crewai | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from opentelemetry.instrumentation.crewai import CrewAIInstrumentor | ||
|
|
||
| # Instrument CrewAI | ||
| CrewAIInstrumentor().instrument() | ||
|
|
||
| # Your CrewAI code here | ||
| from crewai import Agent, Task, Crew | ||
|
|
||
| agent = Agent( | ||
| role='Data Analyst', | ||
| goal='Extract actionable insights', | ||
| backstory='Expert in data analysis', | ||
| verbose=True | ||
| ) | ||
|
|
||
| task = Task( | ||
| description='Analyze the latest AI trends', | ||
| agent=agent | ||
| ) | ||
|
|
||
| crew = Crew( | ||
| agents=[agent], | ||
| tasks=[task], | ||
| verbose=True | ||
| ) | ||
|
|
||
| result = crew.kickoff() | ||
| ``` | ||
|
|
||
| ## Supported Versions | ||
|
|
||
| - CrewAI >= 0.80.0 | ||
|
|
||
| ## References | ||
|
|
||
| - [CrewAI Documentation](https://docs.crewai.com/) | ||
| - [OpenTelemetry Python Documentation](https://opentelemetry-python.readthedocs.io/) | ||
|
|
55 changes: 55 additions & 0 deletions
55
instrumentation-loongsuite/loongsuite-instrumentation-crewai/pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [project] | ||
| name = "loongsuite-instrumentation-crewai" | ||
| dynamic = ["version"] | ||
| description = "LoongSuite CrewAI instrumentation" | ||
| readme = "README.md" | ||
| license = "Apache-2.0" | ||
| requires-python = ">=3.10,<4" | ||
| authors = [ | ||
| { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, | ||
| ] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: Apache Software License", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| ] | ||
| dependencies = [ | ||
| "opentelemetry-api >= 1.37.0", | ||
| "opentelemetry-instrumentation >= 0.58b0", | ||
| "opentelemetry-semantic-conventions >= 0.58b0", | ||
| "wrapt >= 1.0.0, < 2.0.0", | ||
| "opentelemetry-util-genai >= 0.3b0.dev0", | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| instruments = [ | ||
| "crewai >= 0.80.0", | ||
Cirilla-zmh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
|
|
||
| [project.entry-points.opentelemetry_instrumentor] | ||
| crewai = "opentelemetry.instrumentation.crewai:CrewAIInstrumentor" | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/alibaba/loongsuite-python-agent/tree/main/instrumentation-loongsuite/loongsuite-instrumentation-crewai" | ||
| Repository = "https://github.com/alibaba/loongsuite-python-agent" | ||
|
|
||
| [tool.hatch.version] | ||
| path = "src/opentelemetry/instrumentation/crewai/version.py" | ||
|
|
||
| [tool.hatch.build.targets.sdist] | ||
| include = [ | ||
| "/src", | ||
| "/tests", | ||
| ] | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/opentelemetry"] | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.