Skip to content

Commit 22e3b3d

Browse files
authored
Merge branch 'master' into ivana/add-transport-timeouts
2 parents 63cd59f + 6a1364d commit 22e3b3d

File tree

5 files changed

+65
-32
lines changed

5 files changed

+65
-32
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
steps:
2121
- name: Get auth token
2222
id: token
23-
uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
23+
uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 # v2.0.2
2424
with:
2525
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
2626
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}

scripts/populate_tox/populate_tox.py

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010
from bisect import bisect_left
1111
from collections import defaultdict
12-
from datetime import datetime, timezone
12+
from datetime import datetime, timedelta, timezone # noqa: F401
1313
from importlib.metadata import metadata
1414
from packaging.specifiers import SpecifierSet
1515
from packaging.version import Version
@@ -29,13 +29,19 @@
2929
from split_tox_gh_actions.split_tox_gh_actions import GROUPS
3030

3131

32+
# Set CUTOFF this to a datetime to ignore packages older than CUTOFF
33+
CUTOFF = None
34+
# CUTOFF = datetime.now(tz=timezone.utc) - timedelta(days=365 * 5)
35+
3236
TOX_FILE = Path(__file__).resolve().parent.parent.parent / "tox.ini"
3337
ENV = Environment(
3438
loader=FileSystemLoader(Path(__file__).resolve().parent),
3539
trim_blocks=True,
3640
lstrip_blocks=True,
3741
)
3842

43+
PYPI_COOLDOWN = 0.15 # seconds to wait between requests to PyPI
44+
3945
PYPI_PROJECT_URL = "https://pypi.python.org/pypi/{project}/json"
4046
PYPI_VERSION_URL = "https://pypi.python.org/pypi/{project}/{version}/json"
4147
CLASSIFIER_PREFIX = "Programming Language :: Python :: "
@@ -88,27 +94,34 @@
8894
}
8995

9096

91-
@functools.cache
92-
def fetch_package(package: str) -> dict:
93-
"""Fetch package metadata from PyPI."""
94-
url = PYPI_PROJECT_URL.format(project=package)
95-
pypi_data = requests.get(url)
97+
def fetch_url(url: str) -> Optional[dict]:
98+
for attempt in range(3):
99+
pypi_data = requests.get(url)
96100

97-
if pypi_data.status_code != 200:
98-
print(f"{package} not found")
101+
if pypi_data.status_code == 200:
102+
return pypi_data.json()
99103

100-
return pypi_data.json()
104+
backoff = PYPI_COOLDOWN * 2**attempt
105+
print(
106+
f"{url} returned an error: {pypi_data.status_code}. Attempt {attempt + 1}/3. Waiting {backoff}s"
107+
)
108+
time.sleep(backoff)
109+
110+
return None
101111

102112

103113
@functools.cache
104-
def fetch_release(package: str, version: Version) -> dict:
105-
url = PYPI_VERSION_URL.format(project=package, version=version)
106-
pypi_data = requests.get(url)
114+
def fetch_package(package: str) -> Optional[dict]:
115+
"""Fetch package metadata from PyPI."""
116+
url = PYPI_PROJECT_URL.format(project=package)
117+
return fetch_url(url)
107118

108-
if pypi_data.status_code != 200:
109-
print(f"{package} not found")
110119

111-
return pypi_data.json()
120+
@functools.cache
121+
def fetch_release(package: str, version: Version) -> Optional[dict]:
122+
"""Fetch release metadata from PyPI."""
123+
url = PYPI_VERSION_URL.format(project=package, version=version)
124+
return fetch_url(url)
112125

113126

114127
def _prefilter_releases(
@@ -153,9 +166,13 @@ def _prefilter_releases(
153166
if meta["yanked"]:
154167
continue
155168

156-
if older_than is not None:
157-
if datetime.fromisoformat(meta["upload_time_iso_8601"]) > older_than:
158-
continue
169+
uploaded = datetime.fromisoformat(meta["upload_time_iso_8601"])
170+
171+
if older_than is not None and uploaded > older_than:
172+
continue
173+
174+
if CUTOFF is not None and uploaded < CUTOFF:
175+
continue
159176

160177
version = Version(release)
161178

@@ -229,8 +246,14 @@ def get_supported_releases(
229246
expected_python_versions = SpecifierSet(f">={MIN_PYTHON_VERSION}")
230247

231248
def _supports_lowest(release: Version) -> bool:
232-
time.sleep(0.1) # don't DoS PYPI
233-
py_versions = determine_python_versions(fetch_release(package, release))
249+
time.sleep(PYPI_COOLDOWN) # don't DoS PYPI
250+
251+
pypi_data = fetch_release(package, release)
252+
if pypi_data is None:
253+
print("Failed to fetch necessary data from PyPI. Aborting.")
254+
sys.exit(1)
255+
256+
py_versions = determine_python_versions(pypi_data)
234257
target_python_versions = TEST_SUITE_CONFIG[integration].get("python")
235258
if target_python_versions:
236259
target_python_versions = SpecifierSet(target_python_versions)
@@ -499,7 +522,11 @@ def _add_python_versions_to_release(
499522
integration: str, package: str, release: Version
500523
) -> None:
501524
release_pypi_data = fetch_release(package, release)
502-
time.sleep(0.1) # give PYPI some breathing room
525+
if release_pypi_data is None:
526+
print("Failed to fetch necessary data from PyPI. Aborting.")
527+
sys.exit(1)
528+
529+
time.sleep(PYPI_COOLDOWN) # give PYPI some breathing room
503530

504531
target_python_versions = TEST_SUITE_CONFIG[integration].get("python")
505532
if target_python_versions:
@@ -592,6 +619,9 @@ def main(fail_on_changes: bool = False) -> None:
592619

593620
# Fetch data for the main package
594621
pypi_data = fetch_package(package)
622+
if pypi_data is None:
623+
print("Failed to fetch necessary data from PyPI. Aborting.")
624+
sys.exit(1)
595625

596626
# Get the list of all supported releases
597627

sentry_sdk/integrations/logging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ def _capture_log_from_record(client, record):
358358
# type: (BaseClient, LogRecord) -> None
359359
scope = sentry_sdk.get_current_scope()
360360
otel_severity_number, otel_severity_text = _python_level_to_otel(record.levelno)
361-
attrs = {} # type: dict[str, str | bool | float | int]
361+
attrs = {
362+
"sentry.origin": "auto.logger.log",
363+
} # type: dict[str, str | bool | float | int]
362364
if isinstance(record.msg, str):
363365
attrs["sentry.message.template"] = record.msg
364366
if record.args is not None:

tests/test_logs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def test_logger_integration_warning(sentry_init, capture_envelopes):
283283
assert attrs["sentry.environment"] == "production"
284284
assert attrs["sentry.message.parameters.0"] == "1"
285285
assert attrs["sentry.message.parameters.1"] == "2"
286+
assert attrs["sentry.origin"] == "auto.logger.log"
286287
assert logs[0]["severity_number"] == 13
287288
assert logs[0]["severity_text"] == "warn"
288289

tox.ini

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-04-03T11:46:44.595900+00:00
13+
# Last generated: 2025-04-08T10:33:11.499210+00:00
1414

1515
[tox]
1616
requires =
@@ -179,7 +179,7 @@ envlist =
179179

180180
{py3.7,py3.12,py3.13}-statsig-v0.55.3
181181
{py3.7,py3.12,py3.13}-statsig-v0.56.0
182-
{py3.7,py3.12,py3.13}-statsig-v0.57.1
182+
{py3.7,py3.12,py3.13}-statsig-v0.57.2
183183

184184
{py3.8,py3.12,py3.13}-unleash-v6.0.1
185185
{py3.8,py3.12,py3.13}-unleash-v6.1.0
@@ -202,7 +202,7 @@ envlist =
202202
{py3.8,py3.10,py3.11}-strawberry-v0.209.8
203203
{py3.8,py3.11,py3.12}-strawberry-v0.227.7
204204
{py3.8,py3.11,py3.12}-strawberry-v0.245.0
205-
{py3.9,py3.12,py3.13}-strawberry-v0.263.0
205+
{py3.9,py3.12,py3.13}-strawberry-v0.263.2
206206

207207

208208
# ~~~ Network ~~~
@@ -215,7 +215,7 @@ envlist =
215215
# ~~~ Tasks ~~~
216216
{py3.6,py3.7,py3.8}-celery-v4.4.7
217217
{py3.6,py3.7,py3.8}-celery-v5.0.5
218-
{py3.8,py3.12,py3.13}-celery-v5.5.0
218+
{py3.8,py3.12,py3.13}-celery-v5.5.1
219219

220220
{py3.6,py3.7}-dramatiq-v1.9.0
221221
{py3.6,py3.8,py3.9}-dramatiq-v1.12.3
@@ -260,7 +260,7 @@ envlist =
260260
{py3.8,py3.10,py3.11}-litestar-v2.0.1
261261
{py3.8,py3.11,py3.12}-litestar-v2.5.5
262262
{py3.8,py3.11,py3.12}-litestar-v2.10.0
263-
{py3.8,py3.12,py3.13}-litestar-v2.15.1
263+
{py3.8,py3.12,py3.13}-litestar-v2.15.2
264264

265265
{py3.6}-pyramid-v1.8.6
266266
{py3.6,py3.8,py3.9}-pyramid-v1.10.8
@@ -542,7 +542,7 @@ deps =
542542

543543
statsig-v0.55.3: statsig==0.55.3
544544
statsig-v0.56.0: statsig==0.56.0
545-
statsig-v0.57.1: statsig==0.57.1
545+
statsig-v0.57.2: statsig==0.57.2
546546
statsig: typing_extensions
547547

548548
unleash-v6.0.1: UnleashClient==6.0.1
@@ -574,7 +574,7 @@ deps =
574574
strawberry-v0.209.8: strawberry-graphql[fastapi,flask]==0.209.8
575575
strawberry-v0.227.7: strawberry-graphql[fastapi,flask]==0.227.7
576576
strawberry-v0.245.0: strawberry-graphql[fastapi,flask]==0.245.0
577-
strawberry-v0.263.0: strawberry-graphql[fastapi,flask]==0.263.0
577+
strawberry-v0.263.2: strawberry-graphql[fastapi,flask]==0.263.2
578578
strawberry: httpx
579579
strawberry-v0.209.8: pydantic<2.11
580580
strawberry-v0.227.7: pydantic<2.11
@@ -595,7 +595,7 @@ deps =
595595
# ~~~ Tasks ~~~
596596
celery-v4.4.7: celery==4.4.7
597597
celery-v5.0.5: celery==5.0.5
598-
celery-v5.5.0: celery==5.5.0
598+
celery-v5.5.1: celery==5.5.1
599599
celery: newrelic
600600
celery: redis
601601
py3.7-celery: importlib-metadata<5.0
@@ -683,7 +683,7 @@ deps =
683683
litestar-v2.0.1: litestar==2.0.1
684684
litestar-v2.5.5: litestar==2.5.5
685685
litestar-v2.10.0: litestar==2.10.0
686-
litestar-v2.15.1: litestar==2.15.1
686+
litestar-v2.15.2: litestar==2.15.2
687687
litestar: pytest-asyncio
688688
litestar: python-multipart
689689
litestar: requests

0 commit comments

Comments
 (0)