-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add support for openai agents #161
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
Open
minimAluminiumalism
wants to merge
7
commits into
alibaba:main
Choose a base branch
from
minimAluminiumalism:feat/openai-agents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b85b84b
feat: add support for openai agents
minimAluminiumalism a2afd26
chore: add license header
minimAluminiumalism 4796ce8
fix comments
minimAluminiumalism d73a674
fix comments
minimAluminiumalism 0b49bde
fix comments
minimAluminiumalism f4ef609
chore(openai-agents): register tox envs and regenerate workflows
minimAluminiumalism 49f8f21
Merge branch 'main' of https://github.com/alibaba/loongsuite-python-a…
minimAluminiumalism 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
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-openai-agents/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 OpenAI Agents SDK | ||
| ([#161](https://github.com/alibaba/loongsuite-python-agent/pull/161)) | ||
49 changes: 49 additions & 0 deletions
49
instrumentation-loongsuite/loongsuite-instrumentation-openai-agents/README.rst
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,49 @@ | ||
| OpenTelemetry OpenAI Agents SDK Instrumentation | ||
|
minimAluminiumalism marked this conversation as resolved.
|
||
| ================================================ | ||
|
|
||
| |pypi| | ||
|
|
||
| .. |pypi| image:: https://badge.fury.io/py/loongsuite-instrumentation-openai-agents.svg | ||
| :target: https://pypi.org/project/loongsuite-instrumentation-openai-agents/ | ||
|
|
||
| This library provides automatic instrumentation for the | ||
| `OpenAI Agents SDK <https://github.com/openai/openai-agents-python>`_, | ||
| capturing telemetry data for agent runs, tool executions, LLM generations, | ||
| handoffs, and guardrails. | ||
|
|
||
| Installation | ||
| ------------ | ||
|
|
||
| :: | ||
|
|
||
| pip install loongsuite-instrumentation-openai-agents | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from opentelemetry.instrumentation.openai_agents import OpenAIAgentsInstrumentor | ||
|
|
||
| OpenAIAgentsInstrumentor().instrument() | ||
|
|
||
| # Your OpenAI Agents SDK code works as normal | ||
| from agents import Agent, Runner | ||
|
|
||
| agent = Agent(name="assistant", instructions="You are helpful.") | ||
| result = Runner.run_sync(agent, "Hello!") | ||
|
|
||
| The instrumentation automatically captures: | ||
|
|
||
| - Agent invocation spans (``invoke_agent``) | ||
| - Tool execution spans (``execute_tool``) | ||
| - LLM generation spans (``chat``) | ||
| - Agent handoff spans | ||
| - Guardrail execution spans | ||
|
|
||
| References | ||
| ---------- | ||
|
|
||
| * `OpenTelemetry Project <https://opentelemetry.io/>`_ | ||
| * `OpenAI Agents SDK documentation <https://openai.github.io/openai-agents-python/>`_ | ||
| * `OpenTelemetry GenAI Semantic Conventions <https://opentelemetry.io/docs/specs/semconv/gen-ai/>`_ | ||
59 changes: 59 additions & 0 deletions
59
instrumentation-loongsuite/loongsuite-instrumentation-openai-agents/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,59 @@ | ||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [project] | ||
| name = "loongsuite-instrumentation-openai-agents" | ||
| dynamic = ["version"] | ||
| description = "LoongSuite OpenAI Agents SDK instrumentation" | ||
| readme = "README.rst" | ||
| license = "Apache-2.0" | ||
| requires-python = ">=3.10" | ||
| authors = [ | ||
|
minimAluminiumalism marked this conversation as resolved.
|
||
| { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, | ||
| { name = "minimAluminiumalism", email = "caixuesen@outlook.com" }, | ||
| ] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: Apache Software License", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| ] | ||
| dependencies = [ | ||
| "opentelemetry-api ~= 1.37", | ||
| "opentelemetry-instrumentation ~= 0.58b0", | ||
| "opentelemetry-semantic-conventions ~= 0.58b0", | ||
| "opentelemetry-util-genai", | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| instruments = [ | ||
| "openai-agents >= 0.0.7", | ||
| ] | ||
|
|
||
| [project.entry-points.opentelemetry_instrumentor] | ||
| openai_agents = "opentelemetry.instrumentation.openai_agents:OpenAIAgentsInstrumentor" | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/alibaba/loongsuite-python-agent/tree/main/instrumentation-loongsuite/loongsuite-instrumentation-openai-agents" | ||
| Repository = "https://github.com/alibaba/loongsuite-python-agent" | ||
|
|
||
| [tool.hatch.version] | ||
| path = "src/opentelemetry/instrumentation/openai_agents/version.py" | ||
|
|
||
| [tool.hatch.build.targets.sdist] | ||
| include = [ | ||
| "/src", | ||
| "/tests", | ||
| ] | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/opentelemetry"] | ||
|
|
||
| [tool.pytest.ini_options] | ||
| asyncio_mode = "auto" | ||
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.