Skip to content

Commit 09425e6

Browse files
committed
Barebone of new integration
1 parent 7cf4ee4 commit 09425e6

File tree

8 files changed

+111
-45
lines changed

8 files changed

+111
-45
lines changed

.github/workflows/test-integrations-ai.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
run: |
6767
set -x # print commands that are executed
6868
./scripts/runtox.sh "py${{ matrix.python-version }}-openai-latest"
69+
- name: Test openai_agents latest
70+
run: |
71+
set -x # print commands that are executed
72+
./scripts/runtox.sh "py${{ matrix.python-version }}-openai_agents-latest"
6973
- name: Test huggingface_hub latest
7074
run: |
7175
set -x # print commands that are executed
@@ -141,6 +145,10 @@ jobs:
141145
run: |
142146
set -x # print commands that are executed
143147
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai"
148+
- name: Test openai_agents pinned
149+
run: |
150+
set -x # print commands that are executed
151+
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai_agents"
144152
- name: Test huggingface_hub pinned
145153
run: |
146154
set -x # print commands that are executed

scripts/populate_tox/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
"loguru": {
140140
"package": "loguru",
141141
},
142+
"openai_agents": {
143+
"package": "openai-agents",
144+
},
142145
"openfeature": {
143146
"package": "openfeature-sdk",
144147
},

scripts/populate_tox/tox.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ setenv =
397397
litestar: TESTPATH=tests/integrations/litestar
398398
loguru: TESTPATH=tests/integrations/loguru
399399
openai: TESTPATH=tests/integrations/openai
400+
openai_agents: TESTPATH=tests/integrations/openai_agents
400401
openfeature: TESTPATH=tests/integrations/openfeature
401402
opentelemetry: TESTPATH=tests/integrations/opentelemetry
402403
potel: TESTPATH=tests/integrations/opentelemetry

scripts/split_tox_gh_actions/split_tox_gh_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"cohere",
6060
"langchain",
6161
"openai",
62+
"openai_agents",
6263
"huggingface_hub",
6364
],
6465
"Cloud": [

sentry_sdk/integrations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def iter_default_integrations(with_auto_enabling_integrations):
145145
"launchdarkly": (9, 8, 0),
146146
"loguru": (0, 7, 0),
147147
"openai": (1, 0, 0),
148+
"openai_agents": (0, 0, 16),
148149
"openfeature": (0, 7, 1),
149150
"quart": (0, 16, 0),
150151
"ray": (2, 7, 0),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sentry_sdk
2+
from sentry_sdk.integrations import DidNotEnable, Integration
3+
from sentry_sdk.utils import event_from_exception
4+
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from typing import Any
9+
10+
try:
11+
from agents import Agent # noqa: F401
12+
except ImportError:
13+
raise DidNotEnable("OpenAI Agents not installed")
14+
15+
16+
class OpenAIAgentsIntegration(Integration):
17+
identifier = "openai_agents"
18+
origin = f"auto.ai.{identifier}"
19+
20+
def __init__(self):
21+
pass
22+
23+
@staticmethod
24+
def setup_once():
25+
# type: () -> None
26+
pass
27+
28+
29+
def _capture_exception(exc):
30+
# type: (Any) -> None
31+
event, hint = event_from_exception(
32+
exc,
33+
client_options=sentry_sdk.get_client().options,
34+
mechanism={"type": OpenAIAgentsIntegration.identifier, "handled": False},
35+
)
36+
sentry_sdk.capture_event(event, hint=hint)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration
2+
3+
4+
def test_basic(sentry_init):
5+
sentry_init(integrations=[OpenAIAgentsIntegration()])
6+
7+
assert True

0 commit comments

Comments
 (0)