Skip to content

Commit c263e02

Browse files
committed
Merge branch 'master' into antonpirker/openai-overhaul
2 parents dca9f30 + ca3241e commit c263e02

File tree

8 files changed

+63
-7
lines changed

8 files changed

+63
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 2.33.1
4+
5+
### Various fixes & improvements
6+
7+
- fix(integrations): allow explicit op parameter in `ai_track` (#4597) by @mshavliuk
8+
- fix: Fix `abs_path` bug in `serialize_frame` (#4599) by @szokeasaurusrex
9+
- Remove pyrsistent from test dependencies (#4588) by @musicinmybrain
10+
- Remove explicit `__del__`'s in threaded classes (#4590) by @sl0thentr0py
11+
- Remove forked from test_transport, separate gevent tests and generalize capturing_server to be module level (#4577) by @sl0thentr0py
12+
- Improve token usage recording (#4566) by @antonpirker
13+
314
## 2.33.0
415

516
### Various fixes & improvements

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
3232
author = "Sentry Team and Contributors"
3333

34-
release = "2.33.0"
34+
release = "2.33.1"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

requirements-testing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pytest-forked
66
pytest-localserver
77
pytest-watch
88
jsonschema
9-
pyrsistent
109
executing
1110
asttokens
1211
responses

sentry_sdk/ai/monitoring.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def decorator(f):
3232
def sync_wrapped(*args, **kwargs):
3333
# type: (Any, Any) -> Any
3434
curr_pipeline = _ai_pipeline_name.get()
35-
op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")
35+
op = span_kwargs.pop("op", "ai.run" if curr_pipeline else "ai.pipeline")
3636

3737
with start_span(name=description, op=op, **span_kwargs) as span:
3838
for k, v in kwargs.pop("sentry_tags", {}).items():
@@ -61,7 +61,7 @@ def sync_wrapped(*args, **kwargs):
6161
async def async_wrapped(*args, **kwargs):
6262
# type: (Any, Any) -> Any
6363
curr_pipeline = _ai_pipeline_name.get()
64-
op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")
64+
op = span_kwargs.pop("op", "ai.run" if curr_pipeline else "ai.pipeline")
6565

6666
with start_span(name=description, op=op, **span_kwargs) as span:
6767
for k, v in kwargs.pop("sentry_tags", {}).items():

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,4 +1186,4 @@ def _get_default_options():
11861186
del _get_default_options
11871187

11881188

1189-
VERSION = "2.33.0"
1189+
VERSION = "2.33.1"

sentry_sdk/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,14 @@ def serialize_frame(
591591
if tb_lineno is None:
592592
tb_lineno = frame.f_lineno
593593

594+
try:
595+
os_abs_path = os.path.abspath(abs_path) if abs_path else None
596+
except Exception:
597+
os_abs_path = None
598+
594599
rv = {
595600
"filename": filename_for_module(module, abs_path) or None,
596-
"abs_path": os.path.abspath(abs_path) if abs_path else None,
601+
"abs_path": os_abs_path,
597602
"function": function or "<unknown>",
598603
"module": module,
599604
"lineno": tb_lineno,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="2.33.0",
24+
version="2.33.1",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",

tests/test_ai_monitoring.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,44 @@ async def async_pipeline():
119119
assert ai_pipeline_span["tags"]["user"] == "czyber"
120120
assert ai_pipeline_span["data"]["some_data"] == "value"
121121
assert ai_run_span["description"] == "my async tool"
122+
123+
124+
def test_ai_track_with_explicit_op(sentry_init, capture_events):
125+
sentry_init(traces_sample_rate=1.0)
126+
events = capture_events()
127+
128+
@ai_track("my tool", op="custom.operation")
129+
def tool(**kwargs):
130+
pass
131+
132+
with sentry_sdk.start_transaction():
133+
tool()
134+
135+
transaction = events[0]
136+
assert transaction["type"] == "transaction"
137+
assert len(transaction["spans"]) == 1
138+
span = transaction["spans"][0]
139+
140+
assert span["description"] == "my tool"
141+
assert span["op"] == "custom.operation"
142+
143+
144+
@pytest.mark.asyncio
145+
async def test_ai_track_async_with_explicit_op(sentry_init, capture_events):
146+
sentry_init(traces_sample_rate=1.0)
147+
events = capture_events()
148+
149+
@ai_track("my async tool", op="custom.async.operation")
150+
async def async_tool(**kwargs):
151+
pass
152+
153+
with sentry_sdk.start_transaction():
154+
await async_tool()
155+
156+
transaction = events[0]
157+
assert transaction["type"] == "transaction"
158+
assert len(transaction["spans"]) == 1
159+
span = transaction["spans"][0]
160+
161+
assert span["description"] == "my async tool"
162+
assert span["op"] == "custom.async.operation"

0 commit comments

Comments
 (0)