Skip to content

Commit f9ab68a

Browse files
committed
Merge remote-tracking branch 'origin/master' into potel-base
2 parents f76b02d + c1c6e0b commit f9ab68a

File tree

12 files changed

+108
-173
lines changed

12 files changed

+108
-173
lines changed

CHANGELOG.md

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,6 @@
22

33
## 3.0.0a3
44

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-
- Setup opentelemetry patch only once (#4595) by @sl0thentr0py
11-
- Don't use remote server in tests.. (#3152) by @sl0thentr0py
12-
- Fix merge (#3152) by @sl0thentr0py
13-
- Remove explicit __del__'s in threaded classes (#4590) by @sl0thentr0py
14-
- ci: Check strictly for success (#4589) by @szokeasaurusrex
15-
- test: Remove `test_installed_modules` (#4593) by @szokeasaurusrex
16-
- Remove forked from test_transport, separate gevent tests and generalize capturing_server to be module level (#4577) by @sl0thentr0py
17-
- Improve token usage recording (#4566) by @antonpirker
18-
- Remove eventlet support (#4584) by @sl0thentr0py
19-
- meta: Update CHANGELOG.md (98b107fd) by @szokeasaurusrex
20-
- release: 2.33.0 (220a235b) by @getsentry-bot
21-
- feat(langchain): Support `BaseCallbackManager` (#4486) by @szokeasaurusrex
22-
- tests: Regenerate tox.ini (#4583) by @sentrivana
23-
- Add custom sampling context testcases (#4579) by @sl0thentr0py
24-
- feat(tracing): Add option to exclude specific span origins (#4463) by @sl0thentr0py
25-
- Cleanup op and description mapping (#4560) by @sl0thentr0py
26-
- Remove all forked markers in test_api (#4576) by @sl0thentr0py
27-
- Remove forked marker in client uwsgi test (#4575) by @sl0thentr0py
28-
- Fix pytest collection warning (#4574) by @sl0thentr0py
29-
- Remove print statements from excepthook test (#4573) by @sl0thentr0py
30-
- Use `span.data` instead of `measurements` for token usage (#4567) by @antonpirker
31-
32-
_Plus 42 more_
33-
34-
## 3.0.0a2
35-
365
We're excited to announce that version 3.0 of the Sentry Python SDK is now
376
available. This release is the result of a long-term effort to use OpenTelemetry
387
under the hood for tracing. This switch opens the door for us to leverage the
@@ -51,25 +20,23 @@ for your feedback. How was the migration? Is everything working as expected? Is
5120
[on GitHub](https://github.com/getsentry/sentry-python/discussions/3936) or
5221
[on Discord](https://discord.com/invite/Ww9hbqr).
5322

54-
## 3.0.0a1
23+
## 2.33.2
5524

56-
We're excited to announce that version 3.0 of the Sentry Python SDK is now
57-
available. This release is the result of a long-term effort to use OpenTelemetry
58-
under the hood for tracing. This switch opens the door for us to leverage the
59-
full power of OpenTelemetry, so stay tuned for more integrations and features
60-
in future releases.
25+
### Various fixes & improvements
6126

62-
Looking to upgrade from Sentry SDK 2.x to 3.x? See the
63-
[full list of changes](MIGRATION_GUIDE.md) for a comprehensive overview
64-
of what's changed. Looking for a more digestible summary? See the
65-
[migration guide in the docs](https://docs.sentry.io/platforms/python/migration/2.x-to-3.x)
66-
with the most common migration patterns.
27+
- ref(spotlight): Do not import `sentry_sdk.spotlight` unless enabled (#4607) by @sentrivana
28+
- ref(gnu-integration): update clickhouse stacktrace parsing (#4598) by @MeredithAnya
6729

68-
⚠️ This is a pre-release. If you feel like taking it for a spin, we'd be grateful
69-
for your feedback. How was the migration? Is everything working as expected? Is
70-
*nothing* working as expected? Something in between? Please let us know
71-
[on GitHub](https://github.com/getsentry/sentry-python/discussions/3936) or
72-
[on Discord](https://discord.com/invite/Ww9hbqr).
30+
## 2.33.1
31+
32+
### Various fixes & improvements
33+
34+
- fix(integrations): allow explicit op parameter in `ai_track` (#4597) by @mshavliuk
35+
- fix: Fix `abs_path` bug in `serialize_frame` (#4599) by @szokeasaurusrex
36+
- Remove pyrsistent from test dependencies (#4588) by @musicinmybrain
37+
- Remove explicit `__del__`'s in threaded classes (#4590) by @sl0thentr0py
38+
- Remove forked from test_transport, separate gevent tests and generalize capturing_server to be module level (#4577) by @sl0thentr0py
39+
- Improve token usage recording (#4566) by @antonpirker
7340

7441
## 2.33.0
7542

scripts/populate_tox/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"deps": {
158158
"*": ["pytest-asyncio"],
159159
},
160+
"python": ">=3.10",
160161
},
161162
"openfeature": {
162163
"package": "openfeature-sdk",

sentry_sdk/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
)
4747
from sentry_sdk.scrubber import EventScrubber
4848
from sentry_sdk.monitor import Monitor
49-
from sentry_sdk.spotlight import setup_spotlight
5049

5150
if TYPE_CHECKING:
5251
from typing import (
@@ -358,6 +357,10 @@ def _capture_envelope(envelope: Envelope) -> None:
358357
)
359358

360359
if self.options.get("spotlight"):
360+
# This is intentionally here to prevent setting up spotlight
361+
# stuff we don't need unless spotlight is explicitly enabled
362+
from sentry_sdk.spotlight import setup_spotlight
363+
361364
self.spotlight = setup_spotlight(self.options)
362365
if not self.options["dsn"]:
363366
sample_all = lambda *_args, **_kwargs: 1.0

sentry_sdk/integrations/gnu_backtrace.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,12 @@
1313
from sentry_sdk._types import Event
1414

1515

16-
MODULE_RE = r"[a-zA-Z0-9/._:\\-]+"
17-
TYPE_RE = r"[a-zA-Z0-9._:<>,-]+"
18-
HEXVAL_RE = r"[A-Fa-f0-9]+"
19-
16+
FUNCTION_RE = r"[^@]+?)\s+@\s+0x[0-9a-fA-F]+"
2017

2118
FRAME_RE = r"""
22-
^(?P<index>\d+)\.\s
23-
(?P<package>{MODULE_RE})\(
24-
(?P<retval>{TYPE_RE}\ )?
25-
((?P<function>{TYPE_RE})
26-
(?P<args>\(.*\))?
27-
)?
28-
((?P<constoffset>\ const)?\+0x(?P<offset>{HEXVAL_RE}))?
29-
\)\s
30-
\[0x(?P<retaddr>{HEXVAL_RE})\]$
19+
^(?P<index>\d+)\.\s+(?P<function>{FUNCTION_RE}\s+in\s+(?P<package>.+)$
3120
""".format(
32-
MODULE_RE=MODULE_RE, HEXVAL_RE=HEXVAL_RE, TYPE_RE=TYPE_RE
21+
FUNCTION_RE=FUNCTION_RE,
3322
)
3423

3524
FRAME_RE = re.compile(FRAME_RE, re.MULTILINE | re.VERBOSE)

sentry_sdk/integrations/threading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def run(*a: Any, **kw: Any) -> Any:
106106
def _run_old_run_func() -> Any:
107107
try:
108108
self = current_thread()
109-
return old_run_func(self, *a, **kw)
109+
return old_run_func(self, *a[1:], **kw)
110110
except Exception:
111111
reraise(*_capture_exception())
112112

tests/integrations/aiohttp/test_aiohttp.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from aiohttp import web, ClientSession
9+
from aiohttp import web
1010
from aiohttp.client import ServerDisconnectedError
1111
from aiohttp.web_exceptions import (
1212
HTTPInternalServerError,
@@ -650,6 +650,7 @@ async def handler(request):
650650
@pytest.mark.asyncio
651651
async def test_span_origin(
652652
sentry_init,
653+
aiohttp_raw_server,
653654
aiohttp_client,
654655
capture_events,
655656
):
@@ -658,10 +659,16 @@ async def test_span_origin(
658659
traces_sample_rate=1.0,
659660
)
660661

662+
# server for making span request
663+
async def handler(request):
664+
return web.Response(text="OK")
665+
666+
raw_server = await aiohttp_raw_server(handler)
667+
661668
async def hello(request):
662-
async with ClientSession() as session:
663-
async with session.get("http://example.com"):
664-
return web.Response(text="hello")
669+
span_client = await aiohttp_client(raw_server)
670+
await span_client.get("/")
671+
return web.Response(text="hello")
665672

666673
app = web.Application()
667674
app.router.add_get(r"/", hello)

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
def mock_client_post(client, post_mock):
1616
# huggingface-hub==0.28.0 deprecates the `post` method
1717
# so patch `_inner_post` instead
18-
client.post = post_mock
19-
client._inner_post = post_mock
18+
if hasattr(client, "post"):
19+
client.post = post_mock
20+
if hasattr(client, "_inner_post"):
21+
client._inner_post = post_mock
2022

2123

2224
@pytest.mark.parametrize(
@@ -33,7 +35,8 @@ def test_nonstreaming_chat_completion(
3335
)
3436
events = capture_events()
3537

36-
client = InferenceClient()
38+
client = InferenceClient(model="https://")
39+
3740
if details_arg:
3841
post_mock = mock.Mock(
3942
return_value=b"""[{
@@ -92,7 +95,7 @@ def test_streaming_chat_completion(
9295
)
9396
events = capture_events()
9497

95-
client = InferenceClient()
98+
client = InferenceClient(model="https://")
9699

97100
post_mock = mock.Mock(
98101
return_value=[
@@ -141,7 +144,7 @@ def test_bad_chat_completion(sentry_init, capture_events):
141144
sentry_init(integrations=[HuggingfaceHubIntegration()], traces_sample_rate=1.0)
142145
events = capture_events()
143146

144-
client = InferenceClient()
147+
client = InferenceClient(model="https://")
145148
post_mock = mock.Mock(side_effect=OverloadedError("The server is overloaded"))
146149
mock_client_post(client, post_mock)
147150

@@ -159,7 +162,7 @@ def test_span_origin(sentry_init, capture_events):
159162
)
160163
events = capture_events()
161164

162-
client = InferenceClient()
165+
client = InferenceClient(model="https://")
163166
post_mock = mock.Mock(
164167
return_value=[
165168
b"""data:{

tests/integrations/openai_agents/test_openai_agents.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
ResponseFunctionToolCall,
2020
)
2121

22+
from openai.types.responses.response_usage import (
23+
InputTokensDetails,
24+
OutputTokensDetails,
25+
)
26+
2227
test_run_config = agents.RunConfig(tracing_disabled=True)
2328

2429

@@ -29,8 +34,8 @@ def mock_usage():
2934
input_tokens=10,
3035
output_tokens=20,
3136
total_tokens=30,
32-
input_tokens_details=MagicMock(cached_tokens=0),
33-
output_tokens_details=MagicMock(reasoning_tokens=5),
37+
input_tokens_details=InputTokensDetails(cached_tokens=0),
38+
output_tokens_details=OutputTokensDetails(reasoning_tokens=5),
3439
)
3540

3641

tests/integrations/stdlib/test_httplib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):
391391

392392
with pytest.raises(TimeoutError):
393393
with start_span(op="op", name="name"):
394-
conn = HTTPSConnection("www.example.com")
394+
conn = HTTPConnection("localhost", port=PORT)
395395
conn.request("GET", "/bla")
396396
conn.getresponse()
397397

@@ -401,4 +401,4 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):
401401

402402
span = transaction["spans"][0]
403403
assert span["op"] == "http.client"
404-
assert span["description"] == "GET https://www.example.com/bla"
404+
assert span["description"] == f"GET http://localhost:{PORT}/bla" # noqa: E231

0 commit comments

Comments
 (0)