Skip to content

Commit e3cb053

Browse files
authored
Barebones openai agents tracer (#3805)
1 parent 114e590 commit e3cb053

File tree

10 files changed

+3247
-2485
lines changed

10 files changed

+3247
-2485
lines changed

instrumentation-genai/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| --------------- | ------------------ | --------------- | -------------- |
44
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.0.0 | No | development
55
| [opentelemetry-instrumentation-langchain](./opentelemetry-instrumentation-langchain) | langchain >= 0.3.21 | No | development
6+
| [opentelemetry-instrumentation-openai-agents](./opentelemetry-instrumentation-openai-agents) | openai-agents >= 0.3.3 | No | development
67
| [opentelemetry-instrumentation-openai-v2](./opentelemetry-instrumentation-openai-v2) | openai >= 1.26.0 | Yes | development
78
| [opentelemetry-instrumentation-vertexai](./opentelemetry-instrumentation-vertexai) | google-cloud-aiplatform >= 1.64 | No | development
89
| [opentelemetry-instrumentation-weaviate](./opentelemetry-instrumentation-weaviate) | weaviate-client >= 3.0.0,<5.0.0 | No | development
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
examples/.env
2+
examples/openai_agents_multi_agent_travel/.env
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
- Initial barebones package skeleton: minimal instrumentor stub, version module,
11+
and packaging metadata/entry point.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity granting the License.
13+
14+
"Legal Entity" shall mean the union of the acting entity and all
15+
other entities that control, are controlled by, or are under common
16+
control with that entity. For the purposes of this definition,
17+
"control" means (i) the power, direct or indirect, to cause the
18+
direction or management of such entity, whether by contract or
19+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
20+
outstanding shares, or (iii) beneficial ownership of such entity.
21+
22+
"You" (or "Your") shall mean an individual or Legal Entity
23+
exercising permissions granted by this License.
24+
25+
"Source" form shall mean the preferred form for making modifications,
26+
including but not limited to software source code, documentation
27+
source, and configuration files.
28+
29+
"Object" form shall mean any form resulting from mechanical
30+
transformation or translation of a Source form, including but
31+
not limited to compiled object code, generated documentation,
32+
and conversions to other media types.
33+
34+
"Work" shall mean the work of authorship, whether in Source or
35+
Object form, made available under the License, as indicated by a
36+
copyright notice that is included in or attached to the work
37+
(which shall not include communication that is clearly marked or
38+
otherwise designated in writing by the copyright owner as "Not a Work").
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based upon (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and derivative works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control
57+
systems, and issue tracking systems that are managed by, or on behalf
58+
of, the Licensor for the purpose of discussing and improving the Work,
59+
but excluding communication that is clearly marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to use, reproduce, modify, distribute, and prepare
70+
Derivative Works of, publicly display, publicly perform, sublicense,
71+
and distribute the Work and such Derivative Works in Source or Object
72+
form.
73+
74+
3. Grant of Patent License. Subject to the terms and conditions of
75+
this License, each Contributor hereby grants to You a perpetual,
76+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77+
(except as stated in this section) patent license to make, have made,
78+
use, offer to sell, sell, import, and otherwise transfer the Work,
79+
where such license applies only to those patent claims licensable
80+
by such Contributor that are necessarily infringed by their
81+
Contribution(s) alone or by combination of their Contribution(s)
82+
with the Work to which such Contribution(s) was submitted. If You
83+
institute patent litigation against any entity (including a
84+
cross-claim or counterclaim in a lawsuit) alleging that the Work
85+
or a Contribution incorporated within the Work constitutes direct
86+
or contributory patent infringement, then any patent licenses
87+
granted to You under this License for that Work shall terminate
88+
as of the date such litigation is filed.
89+
90+
4. Redistribution. You may reproduce and distribute copies of the
91+
Work or Derivative Works thereof in any medium, with or without
92+
modifications, and in Source or Object form, provided that You
93+
meet the following conditions:
94+
95+
(a) You must give any other recipients of the Work or
96+
Derivative Works a copy of this License; and
97+
98+
(b) You must cause any modified files to carry prominent notices
99+
stating that You changed the files; and
100+
101+
(c) You must retain, in the Source form of any Derivative Works
102+
that You distribute, all copyright, trademark, patent,
103+
attribution and other notices from the Source form of the Work,
104+
excluding those notices that do not pertain to any part of
105+
the Derivative Works; and
106+
107+
(d) If the Work includes a "NOTICE" text file as part of its
108+
distribution, then any Derivative Works that You distribute must
109+
include a readable copy of the attribution notices contained
110+
within such NOTICE file, excluding those notices that do not
111+
pertain to any part of the Derivative Works, in at least one
112+
of the following places: within a NOTICE text file distributed
113+
as part of the Derivative Works; within the Source form or
114+
documentation, if provided along with the Derivative Works; or,
115+
within a display generated by the Derivative Works, if and
116+
wherever such third-party notices normally appear. The contents
117+
of the NOTICE file are for informational purposes only and
118+
do not modify the License. You may add Your own attribution
119+
notices within Derivative Works that You distribute, alongside
120+
or as an addendum to the NOTICE text from the Work, provided
121+
that such additional attribution notices cannot be construed
122+
as modifying the License.
123+
124+
You may add Your own copyright notice to Your modifications and
125+
may provide additional or different license terms and conditions
126+
for use, reproduction, or distribution of Your modifications, or
127+
for any such Derivative Works as a whole, provided Your use,
128+
reproduction, and distribution of the Work otherwise complies with
129+
the conditions stated in this License.
130+
131+
5. Submission of Contributions. Unless You explicitly state otherwise,
132+
any Contribution intentionally submitted for inclusion in the Work
133+
by You to the Licensor shall be under the terms and conditions of
134+
this License, without any additional terms or conditions.
135+
Notwithstanding the above, nothing herein shall supersede or modify
136+
the terms of any separate license agreement you may have executed
137+
with Licensor regarding such Contributions.
138+
139+
6. Trademarks. This License does not grant permission to use the trade
140+
names, trademarks, service marks, or product names of the Licensor,
141+
except as required for reasonable and customary use in describing the
142+
origin of the Work and reproducing the content of the NOTICE file.
143+
144+
7. Disclaimer of Warranty. Unless required by applicable law or
145+
agreed to in writing, Licensor provides the Work (and each
146+
Contributor provides its Contributions) on an "AS IS" BASIS,
147+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148+
implied, including, without limitation, any warranties or conditions
149+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150+
PARTICULAR PURPOSE. You are solely responsible for determining the
151+
appropriateness of using or redistributing the Work and assume any
152+
risks associated with Your exercise of permissions under this License.
153+
154+
8. Limitation of Liability. In no event and under no legal theory,
155+
whether in tort (including negligence), contract, or otherwise,
156+
unless required by applicable law (such as deliberate and grossly
157+
negligent acts) or agreed to in writing, shall any Contributor be
158+
liable to You for damages, including any direct, indirect, special,
159+
incidental, or consequential damages of any character arising as a
160+
result of this License or out of the use or inability to use the
161+
Work (including but not limited to damages for loss of goodwill,
162+
work stoppage, computer failure or malfunction, or any and all
163+
other commercial damages or losses), even if such Contributor
164+
has been advised of the possibility of such damages.
165+
166+
9. Accepting Warranty or Support. When redistributing the Work or
167+
Derivative Works thereof, You may choose to offer, and charge a fee
168+
for, acceptance of support, warranty, indemnity, or other liability
169+
obligations and/or rights consistent with this License. However, in
170+
accepting such obligations, You may act only on Your own behalf and on
171+
Your sole responsibility, not on behalf of any other Contributor, and
172+
only if You agree to indemnify, defend, and hold each Contributor
173+
harmless for any liability incurred by, or claims asserted against,
174+
such Contributor by reason of your accepting any such warranty or support.
175+
176+
END OF TERMS AND CONDITIONS
177+
178+
APPENDIX: How to apply the Apache License to your work.
179+
180+
To apply the Apache License to your work, attach the following
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182+
replaced with your own identifying information. (Don't include
183+
the brackets!) The text should be enclosed in the appropriate
184+
comment syntax for the file format. We also recommend that a
185+
file or class name and description of purpose be included on the
186+
same "printed page" as the copyright notice for easier
187+
identification within third-party archives.
188+
189+
Copyright [yyyy] [name of copyright owner]
190+
191+
Licensed under the Apache License, Version 2.0 (the "License");
192+
you may not use this file except in compliance with the License.
193+
You may obtain a copy of the License at
194+
195+
http://www.apache.org/licenses/LICENSE-2.0
196+
197+
Unless required by applicable law or agreed to in writing, software
198+
distributed under the License is distributed on an "AS IS" BASIS,
199+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200+
See the License for the specific language governing permissions and
201+
limitations under the License.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "opentelemetry-instrumentation-openai-agents"
7+
dynamic = ["version"]
8+
description = "OpenTelemetry OpenAI Agents instrumentation (barebones)"
9+
license = "Apache-2.0"
10+
requires-python = ">=3.9"
11+
authors = [
12+
{ name = "OpenTelemetry Authors", email = "[email protected]" },
13+
]
14+
classifiers = [
15+
"Development Status :: 3 - Alpha",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: Apache Software License",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
]
26+
dependencies = [
27+
"opentelemetry-api >= 1.37",
28+
"opentelemetry-instrumentation >= 0.58b0",
29+
"opentelemetry-semantic-conventions >= 0.58b0"
30+
]
31+
32+
[project.optional-dependencies]
33+
instruments = [
34+
"openai-agents >= 0.3.3",
35+
]
36+
37+
[project.entry-points.opentelemetry_instrumentor]
38+
openai_agents = "opentelemetry.instrumentation.openai_agents:OpenAIAgentsInstrumentor"
39+
40+
[project.urls]
41+
Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation-genai/opentelemetry-instrumentation-openai-agents"
42+
Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib"
43+
44+
[tool.hatch.version]
45+
path = "src/opentelemetry/instrumentation/openai_agents/version.py"
46+
47+
[tool.hatch.build.targets.sdist]
48+
include = [
49+
"/src",
50+
]
51+
52+
[tool.hatch.build.targets.wheel]
53+
packages = ["src/opentelemetry"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Barebones OpenAI Agents instrumentation package.
16+
17+
This branch provides only the minimal package skeleton:
18+
- Instrumentor class stub
19+
- Version module
20+
- Packaging metadata/entry point
21+
"""
22+
23+
from typing import Collection
24+
25+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
26+
27+
from .package import _instruments
28+
from .version import __version__ # noqa: F401
29+
30+
__all__ = [
31+
"OpenAIAgentsInstrumentor",
32+
]
33+
34+
35+
class OpenAIAgentsInstrumentor(BaseInstrumentor):
36+
"""Minimal instrumentor stub (no-op)."""
37+
38+
def _instrument(self, **kwargs) -> None: # pragma: no cover - stub
39+
return
40+
41+
def _uninstrument(self, **kwargs) -> None: # pragma: no cover - stub
42+
return
43+
44+
def instrumentation_dependencies(self) -> Collection[str]:
45+
return _instruments
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
_instruments = ("openai-agents >= 0.3.3",)
16+
_supports_metrics = False
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__version__ = "0.1.0.dev"

scripts/generate_instrumentation_bootstrap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
# development. This filter will get removed once it is further along in its
7373
# development lifecycle and ready to be included by default.
7474
"opentelemetry-instrumentation-weaviate",
75+
# OpenAI Agents instrumentation is currently excluded because it is still in early
76+
# development. This filter will get removed once it is further along in its
77+
# development lifecycle and ready to be included by default.
78+
"opentelemetry-instrumentation-openai-agents",
7579
]
7680

7781
# Static version specifiers for instrumentations that are released independently

0 commit comments

Comments
 (0)