Skip to content

Commit b5db56f

Browse files
committed
Merge branch 'master' into potel-base
2 parents 1e69dab + e6c8798 commit b5db56f

File tree

17 files changed

+333
-154
lines changed

17 files changed

+333
-154
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
fail-fast: false
9393
matrix:
94-
python-version: ["3.8","3.9","3.11","3.12"]
94+
python-version: ["3.8","3.9","3.10","3.11","3.12","3.13"]
9595
os: [ubuntu-22.04]
9696
steps:
9797
- uses: actions/[email protected]

.github/workflows/test-integrations-web-1.yml

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -22,82 +22,6 @@ env:
2222
CACHED_BUILD_PATHS: |
2323
${{ github.workspace }}/dist-serverless
2424
jobs:
25-
test-web_1-latest:
26-
name: Web 1 (latest)
27-
timeout-minutes: 30
28-
runs-on: ${{ matrix.os }}
29-
strategy:
30-
fail-fast: false
31-
matrix:
32-
python-version: ["3.8","3.12","3.13"]
33-
os: [ubuntu-22.04]
34-
services:
35-
postgres:
36-
image: postgres
37-
env:
38-
POSTGRES_PASSWORD: sentry
39-
# Set health checks to wait until postgres has started
40-
options: >-
41-
--health-cmd pg_isready
42-
--health-interval 10s
43-
--health-timeout 5s
44-
--health-retries 5
45-
# Maps tcp port 5432 on service container to the host
46-
ports:
47-
- 5432:5432
48-
env:
49-
SENTRY_PYTHON_TEST_POSTGRES_HOST: localhost
50-
SENTRY_PYTHON_TEST_POSTGRES_USER: postgres
51-
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry
52-
steps:
53-
- uses: actions/[email protected]
54-
- uses: actions/setup-python@v5
55-
with:
56-
python-version: ${{ matrix.python-version }}
57-
allow-prereleases: true
58-
- name: Setup Test Env
59-
run: |
60-
pip install "coverage[toml]" tox
61-
- name: Erase coverage
62-
run: |
63-
coverage erase
64-
- name: Test django latest
65-
run: |
66-
set -x # print commands that are executed
67-
./scripts/runtox.sh "py${{ matrix.python-version }}-django-latest"
68-
- name: Test flask latest
69-
run: |
70-
set -x # print commands that are executed
71-
./scripts/runtox.sh "py${{ matrix.python-version }}-flask-latest"
72-
- name: Test starlette latest
73-
run: |
74-
set -x # print commands that are executed
75-
./scripts/runtox.sh "py${{ matrix.python-version }}-starlette-latest"
76-
- name: Test fastapi latest
77-
run: |
78-
set -x # print commands that are executed
79-
./scripts/runtox.sh "py${{ matrix.python-version }}-fastapi-latest"
80-
- name: Generate coverage XML
81-
if: ${{ !cancelled() }}
82-
run: |
83-
coverage combine .coverage-sentry-*
84-
coverage xml
85-
- name: Upload coverage to Codecov
86-
if: ${{ !cancelled() }}
87-
uses: codecov/[email protected]
88-
with:
89-
token: ${{ secrets.CODECOV_TOKEN }}
90-
files: coverage.xml
91-
# make sure no plugins alter our coverage reports
92-
plugin: noop
93-
verbose: true
94-
- name: Upload test results to Codecov
95-
if: ${{ !cancelled() }}
96-
uses: codecov/test-results-action@v1
97-
with:
98-
token: ${{ secrets.CODECOV_TOKEN }}
99-
files: .junitxml
100-
verbose: true
10125
test-web_1-pinned:
10226
name: Web 1 (pinned)
10327
timeout-minutes: 30

CHANGELOG.md

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

3+
## 2.26.1
4+
5+
### Various fixes & improvements
6+
7+
- fix(threading): Data leak in ThreadingIntegration between threads (#4281) by @antonpirker
8+
- fix(logging): Clarify separate warnings case is for Python <3.11 (#4296) by @szokeasaurusrex
9+
- fix(logging): Add formatted message to log events (#4292) by @szokeasaurusrex
10+
- fix(logging): Send raw logging parameters (#4291) by @szokeasaurusrex
11+
- fix: Revert "chore: Deprecate `same_process_as_parent` (#4244)" (#4290) by @sentrivana
12+
13+
## 2.26.0
14+
15+
### Various fixes & improvements
16+
17+
- fix(debug): Do not consider parent loggers for debug logging (#4286) by @szokeasaurusrex
18+
- test(tracing): Simplify static/classmethod tracing tests (#4278) by @szokeasaurusrex
19+
- feat(transport): Add a timeout (#4252) by @sentrivana
20+
- meta: Change CODEOWNERS back to Python SDK owners (#4269) by @sentrivana
21+
- feat(logs): Add sdk name and version as log attributes (#4262) by @AbhiPrasad
22+
- feat(logs): Add server.address to logs (#4257) by @AbhiPrasad
23+
- chore: Deprecate `same_process_as_parent` (#4244) by @sentrivana
24+
- feat(logs): Add sentry.origin attribute for log handler (#4250) by @AbhiPrasad
25+
- feat(tests): Add optional cutoff to toxgen (#4243) by @sentrivana
26+
- toxgen: Retry & fail if we fail to fetch PyPI data (#4251) by @sentrivana
27+
- build(deps): bump actions/create-github-app-token from 1.12.0 to 2.0.2 (#4248) by @dependabot
28+
- Trying to prevent the grpc setup from being flaky (#4233) by @antonpirker
29+
- feat(breadcrumbs): add `_meta` information for truncation of breadcrumbs (#4007) by @shellmayr
30+
- tests: Move django under toxgen (#4238) by @sentrivana
31+
- fix: Handle JSONDecodeError gracefully in StarletteRequestExtractor (#4226) by @moodix
32+
- fix(asyncio): Remove shutdown handler (#4237) by @sentrivana
33+
334
## 2.25.1
435

536
### Various fixes & improvements

docs/conf.py

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

36-
release = "2.25.1"
36+
release = "2.26.1"
3737
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3838

3939

scripts/populate_tox/config.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@
5555
"package": "falcon",
5656
"python": "<3.13",
5757
},
58+
"fastapi": {
59+
"package": "fastapi",
60+
"deps": {
61+
"*": [
62+
"httpx",
63+
"pytest-asyncio",
64+
"python-multipart",
65+
"requests",
66+
"anyio<4",
67+
],
68+
# There's an incompatibility between FastAPI's TestClient, which is
69+
# actually Starlette's TestClient, which is actually httpx's Client.
70+
# httpx dropped a deprecated Client argument in 0.28.0, Starlette
71+
# dropped it from its TestClient in 0.37.2, and FastAPI only pinned
72+
# Starlette>=0.37.2 from version 0.110.1 onwards -- so for older
73+
# FastAPI versions we use older httpx which still supports the
74+
# deprecated argument.
75+
"<0.110.1": ["httpx<0.28.0"],
76+
"py3.6": ["aiocontextvars"],
77+
},
78+
},
5879
"flask": {
5980
"package": "flask",
6081
"deps": {
@@ -137,7 +158,8 @@
137158
"jinja2",
138159
"httpx",
139160
],
140-
"<0.37": ["httpx<0.28.0"],
161+
# See the comment on FastAPI's httpx bound for more info
162+
"<0.37.2": ["httpx<0.28.0"],
141163
"<0.15": ["jinja2<3.1"],
142164
"py3.6": ["aiocontextvars"],
143165
},

scripts/populate_tox/populate_tox.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,8 @@
7575
"boto3",
7676
"chalice",
7777
"cohere",
78-
"fastapi",
7978
"gcp",
8079
"httpx",
81-
"huey",
82-
"huggingface_hub",
8380
"langchain",
8481
"langchain_notiktoken",
8582
"openai",

scripts/populate_tox/tox.jinja

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ envlist =
8080
{py3.9,py3.11,py3.12}-cohere-v5
8181
{py3.9,py3.11,py3.12}-cohere-latest
8282

83-
# FastAPI
84-
{py3.7,py3.10}-fastapi-v{0.79}
85-
{py3.8,py3.12,py3.13}-fastapi-latest
86-
8783
# GCP
8884
{py3.7}-gcp
8985

@@ -245,16 +241,6 @@ deps =
245241
cohere-v5: cohere~=5.3.3
246242
cohere-latest: cohere
247243
248-
# FastAPI
249-
fastapi: httpx
250-
# (this is a dependency of httpx)
251-
fastapi: anyio<4.0.0
252-
fastapi: pytest-asyncio
253-
fastapi: python-multipart
254-
fastapi: requests
255-
fastapi-v{0.79}: fastapi~=0.79.0
256-
fastapi-latest: fastapi
257-
258244
# HTTPX
259245
httpx-v0.16: pytest-httpx==0.10.0
260246
httpx-v0.18: pytest-httpx==0.12.0

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,4 +985,4 @@ def _get_default_options():
985985
del _get_default_options
986986

987987

988-
VERSION = "2.25.1"
988+
VERSION = "2.26.1"

sentry_sdk/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def filter(self, record):
1818

1919
def init_debug_support():
2020
# type: () -> None
21-
if not logger.hasHandlers():
21+
if not logger.handlers:
2222
configure_logger()
2323

2424

sentry_sdk/integrations/logging.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import sys
23
from datetime import datetime, timezone
34
from fnmatch import fnmatch
45

@@ -253,29 +254,25 @@ def _emit(self, record):
253254
event["level"] = level # type: ignore[typeddict-item]
254255
event["logger"] = record.name
255256

256-
# Log records from `warnings` module as separate issues
257-
record_captured_from_warnings_module = (
258-
record.name == "py.warnings" and record.msg == "%s"
259-
)
260-
if record_captured_from_warnings_module:
261-
# use the actual message and not "%s" as the message
262-
# this prevents grouping all warnings under one "%s" issue
263-
msg = record.args[0] # type: ignore
264-
265-
event["logentry"] = {
266-
"message": msg,
267-
"params": (),
268-
}
269-
257+
if (
258+
sys.version_info < (3, 11)
259+
and record.name == "py.warnings"
260+
and record.msg == "%s"
261+
):
262+
# warnings module on Python 3.10 and below sets record.msg to "%s"
263+
# and record.args[0] to the actual warning message.
264+
# This was fixed in https://github.com/python/cpython/pull/30975.
265+
message = record.args[0]
266+
params = ()
270267
else:
271-
event["logentry"] = {
272-
"message": to_string(record.msg),
273-
"params": (
274-
tuple(str(arg) if arg is None else arg for arg in record.args)
275-
if record.args
276-
else ()
277-
),
278-
}
268+
message = record.msg
269+
params = record.args
270+
271+
event["logentry"] = {
272+
"message": to_string(message),
273+
"formatted": record.getMessage(),
274+
"params": params,
275+
}
279276

280277
event["extra"] = self._extra_from_record(record)
281278

sentry_sdk/integrations/threading.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import warnings
23
from functools import wraps
34
from threading import Thread, current_thread
45

@@ -35,6 +36,15 @@ def setup_once():
3536
# type: () -> None
3637
old_start = Thread.start
3738

39+
try:
40+
from django import VERSION as django_version # noqa: N811
41+
import channels # type: ignore[import-not-found]
42+
43+
channels_version = channels.__version__
44+
except ImportError:
45+
django_version = None
46+
channels_version = None
47+
3848
@wraps(old_start)
3949
def sentry_start(self, *a, **kw):
4050
# type: (Thread, *Any, **Any) -> Any
@@ -43,8 +53,27 @@ def sentry_start(self, *a, **kw):
4353
return old_start(self, *a, **kw)
4454

4555
if integration.propagate_scope:
46-
isolation_scope = sentry_sdk.get_isolation_scope()
47-
current_scope = sentry_sdk.get_current_scope()
56+
if (
57+
sys.version_info < (3, 9)
58+
and channels_version is not None
59+
and channels_version < "4.0.0"
60+
and django_version is not None
61+
and django_version >= (3, 0)
62+
and django_version < (4, 0)
63+
):
64+
warnings.warn(
65+
"There is a known issue with Django channels 2.x and 3.x when using Python 3.8 or older. "
66+
"(Async support is emulated using threads and some Sentry data may be leaked between those threads.) "
67+
"Please either upgrade to Django channels 4.0+, use Django's async features "
68+
"available in Django 3.1+ instead of Django channels, or upgrade to Python 3.9+.",
69+
stacklevel=2,
70+
)
71+
isolation_scope = sentry_sdk.get_isolation_scope()
72+
current_scope = sentry_sdk.get_current_scope()
73+
74+
else:
75+
isolation_scope = sentry_sdk.get_isolation_scope().fork()
76+
current_scope = sentry_sdk.get_current_scope().fork()
4877
else:
4978
isolation_scope = None
5079
current_scope = None

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.25.1",
24+
version="2.26.1",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",

tests/integrations/django/asgi/test_asgi.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,25 @@ async def test_basic(sentry_init, capture_events, application):
3838

3939
events = capture_events()
4040

41-
comm = HttpCommunicator(application, "GET", "/view-exc?test=query")
42-
response = await comm.get_response()
43-
await comm.wait()
41+
import channels # type: ignore[import-not-found]
42+
43+
if (
44+
sys.version_info < (3, 9)
45+
and channels.__version__ < "4.0.0"
46+
and django.VERSION >= (3, 0)
47+
and django.VERSION < (4, 0)
48+
):
49+
# We emit a UserWarning for channels 2.x and 3.x on Python 3.8 and older
50+
# because the async support was not really good back then and there is a known issue.
51+
# See the TreadingIntegration for details.
52+
with pytest.warns(UserWarning):
53+
comm = HttpCommunicator(application, "GET", "/view-exc?test=query")
54+
response = await comm.get_response()
55+
await comm.wait()
56+
else:
57+
comm = HttpCommunicator(application, "GET", "/view-exc?test=query")
58+
response = await comm.get_response()
59+
await comm.wait()
4460

4561
assert response["status"] == 500
4662

0 commit comments

Comments
 (0)