Skip to content

Commit ab895ff

Browse files
authored
Merge branch 'master' into perf/package-version-lookup
2 parents 06ac994 + d565fed commit ab895ff

10 files changed

Lines changed: 116 additions & 20 deletions

File tree

‎CHANGELOG.md‎

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

3+
## 2.74.0
4+
5+
### New Features ✨
6+
7+
#### Anthropic
8+
9+
- Record reasoning parts in streaming output by @alexander-alderman-webb in [#8193](https://github.com/getsentry/sentry-python/pull/8193)
10+
- Record reasoning parts in nonstreaming output by @alexander-alderman-webb in [#8192](https://github.com/getsentry/sentry-python/pull/8192)
11+
12+
#### Other
13+
14+
- (typesafe) Handle inline images by @alexander-alderman-webb in [#8164](https://github.com/getsentry/sentry-python/pull/8164)
15+
16+
### Bug Fixes 🐛
17+
18+
#### Anthropic
19+
20+
- Preserve cached `_iterator` property by @alexander-alderman-webb in [#8163](https://github.com/getsentry/sentry-python/pull/8163)
21+
- Stop unpacking output arrays by @alexander-alderman-webb in [#8160](https://github.com/getsentry/sentry-python/pull/8160)
22+
23+
#### Other
24+
25+
- (aiohttp) Leave existing `baggage` header alone if it has existin… by @pabloDeputter in [#8116](https://github.com/getsentry/sentry-python/pull/8116)
26+
- (boto3) Adapt to botocore no longer signing baggage by @sentrivana in [#8113](https://github.com/getsentry/sentry-python/pull/8113)
27+
- (ci) Restrict pytest because of incompatibilities by @sentrivana in [#8140](https://github.com/getsentry/sentry-python/pull/8140)
28+
- (falcon) Handle integer HTTP statuses by @jap and @sentrivana in [#8139](https://github.com/getsentry/sentry-python/pull/8139)
29+
- (sampling) Respect incoming sample rate if not explicitly overridden by @sentrivana in [#8185](https://github.com/getsentry/sentry-python/pull/8185)
30+
- (tracing) Drop trailing comma when serializing baggage without third-party items by @alphasafal and @pabloDeputter in [#8119](https://github.com/getsentry/sentry-python/pull/8119)
31+
- (wsgi) Stop overwriting `server.address` by @alexander-alderman-webb in [#8171](https://github.com/getsentry/sentry-python/pull/8171)
32+
33+
### Internal Changes 🔧
34+
35+
#### Deps
36+
37+
- Lock file maintenance by @renovate in [#8055](https://github.com/getsentry/sentry-python/pull/8055)
38+
- Bump grpcio to 1.84.1 by @geoffg-sentry with @sentry-junior in [#8136](https://github.com/getsentry/sentry-python/pull/8136)
39+
- Bump uv to 0.13.5 by @geoffg-sentry with @sentry-junior in [#8135](https://github.com/getsentry/sentry-python/pull/8135)
40+
- Bump brotli to 1.2.1 by @geoffg-sentry with @sentry-junior in [#8122](https://github.com/getsentry/sentry-python/pull/8122)
41+
42+
#### Other
43+
44+
- (mcp) Remove unused select_mcp_transactions fixture by @sentrivana with @sentry-junior in [#8150](https://github.com/getsentry/sentry-python/pull/8150)
45+
- (release) Bump craft to 3.9.0 and update config by @BYK with @sentry-junior in [#8181](https://github.com/getsentry/sentry-python/pull/8181)
46+
- (sessions) Remove unused TERMINAL_SESSION_STATES constant by @sentrivana with @sentry-junior in [#8151](https://github.com/getsentry/sentry-python/pull/8151)
47+
- (starlette) Remove unused \_serialize_request_body_data helper by @sentry-junior in [#8146](https://github.com/getsentry/sentry-python/pull/8146)
48+
- (toxgen) Remove unused `get_file_hash()` and `get_last_updated()` helpers by @sentry-junior in [#8173](https://github.com/getsentry/sentry-python/pull/8173)
49+
- (tracing) Remove unused base64_stripped regex by @sentry-junior in [#8148](https://github.com/getsentry/sentry-python/pull/8148)
50+
- (utils) Remove unused to_timestamp helper and epoch constant by @sentry-junior in [#8147](https://github.com/getsentry/sentry-python/pull/8147)
51+
- 🤖 Update test matrix with new releases (11/02) by @sentrivana with @github-actions in [#8172](https://github.com/getsentry/sentry-python/pull/8172)
52+
- Upgrade `sphinx` and remove `packaging` upper bound by @alexander-alderman-webb in [#8183](https://github.com/getsentry/sentry-python/pull/8183)
53+
- Update test matrix with new releases (27/10) by @alexander-alderman-webb in [#8126](https://github.com/getsentry/sentry-python/pull/8126)
54+
355
## 2.73.0
456

557
### New Features ✨

‎docs/conf.py‎

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

20-
release = "2.73.0"
20+
release = "2.74.0"
2121
version = ".".join(release.split(".")[:2]) # The short X.Y version.
2222

2323

‎sentry_sdk/consts.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,4 +1924,4 @@ def _get_default_options() -> "dict[str, Any]":
19241924
del _get_default_options
19251925

19261926

1927-
VERSION = "2.73.0"
1927+
VERSION = "2.74.0"

‎sentry_sdk/crons/decorator.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ async def inner(*args: "P.args", **kwargs: "P.kwargs") -> "R":
126126
with self:
127127
return await fn(*args, **kwargs)
128128

129+
inner._sentry_monitored = True # type: ignore[attr-defined]
129130
return inner
130131

131132
def _sync_wrapper(self, fn: "Callable[P, R]") -> "Callable[P, R]":
@@ -134,4 +135,5 @@ def inner(*args: "P.args", **kwargs: "P.kwargs") -> "R":
134135
with self:
135136
return fn(*args, **kwargs)
136137

138+
inner._sentry_monitored = True # type: ignore[attr-defined]
137139
return inner

‎sentry_sdk/crons/utils.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import re
2+
from datetime import timedelta, timezone
13
from typing import TYPE_CHECKING
24

35
if TYPE_CHECKING:
6+
from datetime import tzinfo
47
from typing import Optional, Tuple
58

69
from sentry_sdk._types import MonitorConfigSchedule, MonitorConfigScheduleUnit
@@ -27,3 +30,26 @@ def _get_interval_schedule(seconds: float) -> "Optional[MonitorConfigSchedule]":
2730
"unit": unit,
2831
}
2932
return None
33+
34+
35+
# IANA zone names start with an uppercase letter. This rejects names like
36+
# "local" or "localtime" that tzlocal can give a zone.
37+
_IANA_TIMEZONE_NAME = re.compile(r"[A-Z][A-Za-z0-9._+-]*(?:/[A-Za-z0-9._+-]+)*")
38+
39+
40+
def _get_timezone_name(tz: "tzinfo") -> "Optional[str]":
41+
"""
42+
Return the IANA name of the timezone, or None if it has none.
43+
"""
44+
name = getattr(tz, "key", None) or getattr(tz, "zone", None)
45+
if isinstance(name, str):
46+
return name if _IANA_TIMEZONE_NAME.fullmatch(name) else None
47+
48+
if isinstance(tz, timezone):
49+
offset = tz.utcoffset(None)
50+
if offset % timedelta(hours=1):
51+
return None
52+
hours = offset // timedelta(hours=1)
53+
return "Etc/GMT%+d" % -hours if hours else "UTC"
54+
55+
return None

‎sentry_sdk/integrations/arq.py‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import sys
22
import time
3-
from datetime import timedelta, timezone
3+
from functools import wraps
44

55
import sentry_sdk
66
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
77
from sentry_sdk.crons import monitor
8+
from sentry_sdk.crons.utils import _get_timezone_name
89
from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version
910
from sentry_sdk.integrations.logging import ignore_logger
1011
from sentry_sdk.scope import should_send_default_pii
@@ -221,6 +222,7 @@ def event_processor(event: "Event", hint: "Hint") -> "Optional[Event]":
221222

222223

223224
def _wrap_coroutine(name: str, coroutine: "WorkerCoroutine") -> "WorkerCoroutine":
225+
@wraps(coroutine)
224226
async def _sentry_coroutine(
225227
ctx: "Dict[Any, Any]", *args: "Any", **kwargs: "Any"
226228
) -> "Any":
@@ -326,6 +328,9 @@ def _monitor_cron_job(
326328
return
327329
cron_job._sentry_monitored = True
328330

331+
if getattr(cron_job.coroutine, "_sentry_monitored", False):
332+
return
333+
329334
# arq names cron jobs "cron:<function name>" by default.
330335
monitor_slug = cron_job.name
331336
if monitor_slug.startswith("cron:"):
@@ -393,35 +398,23 @@ def _get_crontab(cron_job: "CronJob") -> "Optional[str]":
393398
return " ".join(fields) # type: ignore[arg-type]
394399

395400

396-
def _get_timezone_name(worker: "Worker") -> "Optional[str]":
401+
def _get_worker_timezone_name(worker: "Worker") -> "Optional[str]":
397402
tz = getattr(worker, "timezone", None)
398403
if tz is None:
399404
# Before arq 0.25, cron jobs ran in naive local time.
400405
if time.timezone == 0 and (not time.daylight or time.altzone == 0):
401406
return "UTC"
402407
return None
403408

404-
# zoneinfo and pytz
405-
name = getattr(tz, "key", None) or getattr(tz, "zone", None)
406-
if isinstance(name, str):
407-
return name
408-
409409
# arq defaults to the system's fixed UTC offset at startup.
410-
if isinstance(tz, timezone):
411-
offset = tz.utcoffset(None)
412-
if offset % timedelta(hours=1):
413-
return None
414-
hours = offset // timedelta(hours=1)
415-
return "Etc/GMT%+d" % -hours if hours else "UTC"
416-
417-
return None
410+
return _get_timezone_name(tz)
418411

419412

420413
def _get_monitor_config(
421414
cron_job: "CronJob", worker: "Worker"
422415
) -> "Optional[MonitorConfig]":
423416
crontab = _get_crontab(cron_job)
424-
timezone_name = _get_timezone_name(worker)
417+
timezone_name = _get_worker_timezone_name(worker)
425418
if crontab is None or timezone_name is None:
426419
return None
427420
return {

‎sentry_sdk/traces.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __str__(self) -> str:
7777

7878

7979
# The source of a segment name, see
80-
# https://getsentry.github.io/sentry-conventions/attributes/sentry/#sentry-segment-name-source
80+
# https://conventions.sentry.dev/attributes/sentry/#sentry-segment-name-source
8181
class SegmentNameSource(str, Enum):
8282
COMPONENT = "component"
8383
CUSTOM = "custom"

‎setup.py‎

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

2323
setup(
2424
name="sentry-sdk",
25-
version="2.73.0",
25+
version="2.74.0",
2626
author="Sentry Team and Contributors",
2727
author_email="hello@sentry.io",
2828
url="https://github.com/getsentry/sentry-python",

‎tests/integrations/arq/test_arq_crons.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from arq.connections import ArqRedis
88
from fakeredis.aioredis import FakeRedis
99

10+
import sentry_sdk
1011
from sentry_sdk.integrations.arq import ArqIntegration, _get_monitor_config
1112

1213
try:
@@ -183,6 +184,25 @@ async def test_cron_job_monitored_once(sentry_init, capture_envelopes):
183184
assert statuses[:4] == ["in_progress", "ok", "in_progress", "ok"]
184185

185186

187+
@sentry_sdk.monitor(monitor_slug="decorated")
188+
async def decorated_job(ctx):
189+
pass
190+
191+
192+
@pytest.mark.asyncio
193+
async def test_monitor_decorated_cron_job_reports_once(sentry_init, capture_envelopes):
194+
sentry_init(integrations=[ArqIntegration(monitor_cron_jobs=True)])
195+
envelopes = capture_envelopes()
196+
197+
await _run_cron_jobs(
198+
cron(decorated_job, run_at_startup=True), timezone=timezone.utc
199+
)
200+
201+
check_ins = _check_ins(envelopes)
202+
assert {c["monitor_slug"] for c in check_ins} == {"decorated"}
203+
assert [c["status"] for c in check_ins[:2]] == ["in_progress", "ok"]
204+
205+
186206
class _Worker:
187207
def __init__(self, timezone):
188208
self.timezone = timezone

‎warden.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ reportOn = "medium"
3232

3333
[[skills]]
3434
name = "code-review"
35+
incremental = true
3536

3637
[[skills.triggers]]
3738
type = "pull_request"
3839
actions = ["opened", "synchronize", "reopened"]
3940

4041
[[skills]]
4142
name = "find-bugs"
43+
incremental = true
4244

4345
[[skills.triggers]]
4446
type = "pull_request"
4547
actions = ["opened", "synchronize", "reopened"]
4648

4749
[[skills]]
4850
name = "skill-scanner"
51+
incremental = true
4952

5053
[[skills.triggers]]
5154
type = "pull_request"

0 commit comments

Comments
 (0)