Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/loongsuite_lint_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ jobs:
- name: Run tests
run: tox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-google-adk

lint-loongsuite-instrumentation-openai-agents:
name: LoongSuite loongsuite-instrumentation-openai-agents
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-openai-agents

lint-loongsuite-instrumentation-langchain:
name: LoongSuite loongsuite-instrumentation-langchain
runs-on: ubuntu-latest
Expand Down
152 changes: 152 additions & 0 deletions .github/workflows/loongsuite_test_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,158 @@ jobs:
- name: Run tests
run: tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-google-adk-latest -- -ra

py310-test-loongsuite-instrumentation-openai-agents-oldest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-oldest 3.10 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-openai-agents-oldest -- -ra

py310-test-loongsuite-instrumentation-openai-agents-latest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-latest 3.10 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-openai-agents-latest -- -ra

py311-test-loongsuite-instrumentation-openai-agents-oldest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-oldest 3.11 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-openai-agents-oldest -- -ra

py311-test-loongsuite-instrumentation-openai-agents-latest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-latest 3.11 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-openai-agents-latest -- -ra

py312-test-loongsuite-instrumentation-openai-agents-oldest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-oldest 3.12 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-openai-agents-oldest -- -ra

py312-test-loongsuite-instrumentation-openai-agents-latest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-latest 3.12 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-openai-agents-latest -- -ra

py313-test-loongsuite-instrumentation-openai-agents-oldest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-oldest 3.13 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-openai-agents-oldest -- -ra

py313-test-loongsuite-instrumentation-openai-agents-latest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-openai-agents-latest 3.13 Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install tox
run: pip install tox-uv

- name: Run tests
run: tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-openai-agents-latest -- -ra

py39-test-loongsuite-instrumentation-langchain-oldest_ubuntu-latest:
name: LoongSuite loongsuite-instrumentation-langchain-oldest 3.9 Ubuntu
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ LoongSuite Python Agent 同时也是上游 [OTel Python Agent](https://github.co
| [LiteLLM](https://github.com/BerriAI/litellm) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-litellm/README.md) | [PyPI](https://pypi.org/project/loongsuite-instrumentation-litellm/) |
| [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-mcp/README.md) | in dev |
| [Mem0](https://github.com/mem0ai/mem0) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-mem0/README.md) | [PyPI](https://pypi.org/project/loongsuite-instrumentation-mem0/) |
| [OpenAI Agents SDK](https://github.com/openai/openai-agents-python) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-openai-agents/README.rst) | in dev |

**发行版与辅助组件:**

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Source tree: [`instrumentation-loongsuite/`](instrumentation-loongsuite).
| [LiteLLM](https://github.com/BerriAI/litellm) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-litellm/README.md) | [PyPI](https://pypi.org/project/loongsuite-instrumentation-litellm/) |
| [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-mcp/README.md) | in dev |
| [Mem0](https://github.com/mem0ai/mem0) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-mem0/README.md) | [PyPI](https://pypi.org/project/loongsuite-instrumentation-mem0/) |
| [OpenAI Agents SDK](https://github.com/openai/openai-agents-python) | [GUIDE](instrumentation-loongsuite/loongsuite-instrumentation-openai-agents/README.rst) | in dev |

**Distro and helpers:**

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
Comment thread
minimAluminiumalism marked this conversation as resolved.

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))
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
OpenTelemetry OpenAI Agents SDK Instrumentation
Comment thread
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/>`_
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 = [
Comment thread
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"
Loading
Loading