Skip to content

Commit b83e454

Browse files
authored
Sync with master (#2596)
1 parent 89af1e2 commit b83e454

31 files changed

+232
-146
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- master
77
- release/**
8+
- sentry-sdk-2.0
89

910
pull_request:
1011

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ master ]
16+
branches:
17+
- master
18+
- sentry-sdk-2.0
1719
pull_request:
1820
# The branches below must be a subset of the branches above
19-
branches: [ master ]
21+
branches:
22+
- master
23+
- sentry-sdk-2.0
2024
schedule:
2125
- cron: '18 18 * * 3'
2226

.github/workflows/enforce-license-compliance.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ name: Enforce License Compliance
22

33
on:
44
push:
5-
branches: [master, main, release/*]
5+
branches:
6+
- master
7+
- main
8+
- release/*
9+
- sentry-sdk-2.0
610
pull_request:
7-
branches: [master, main]
11+
branches:
12+
- master
13+
- main
14+
- sentry-sdk-2.0
815

916
jobs:
1017
enforce-license-compliance:

.github/workflows/test-integrations-aws-lambda.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
89
# this to run on forks with access to the secrets necessary to run the test suite.
910
# Prefer to use `pull_request` when possible.

.github/workflows/test-integrations-cloud-computing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

.github/workflows/test-integrations-data-processing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

.github/workflows/test-integrations-web-frameworks-2.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release/**
7+
- sentry-sdk-2.0
78
pull_request:
89
# Cancel in progress workflows on pull_requests.
910
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value

CHANGELOG.md

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

3+
## 1.39.1
4+
5+
### Various fixes & improvements
6+
7+
- Fix psycopg2 detection in the Django integration (#2593) by @sentrivana
8+
- Filter out empty string releases (#2591) by @sentrivana
9+
- Fixed local var not present when there is an error in a user's `error_sampler` function (#2511) by @antonpirker
10+
- Fixed typing in `aiohttp` (#2590) by @antonpirker
11+
312
## 1.39.0
413

514
### Various fixes & improvements

docs/conf.py

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

33-
release = "1.39.0"
33+
release = "1.39.1"
3434
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3535

3636

linter-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mypy
22
black
33
flake8==5.0.4 # flake8 depends on pyflakes>=3.0.0 and this dropped support for Python 2 "# type:" comments
44
types-certifi
5-
types-protobuf
5+
types-protobuf==4.24.0.4 # newer raises an error on mypy sentry_sdk
66
types-redis
77
types-setuptools
88
pymongo # There is no separate types module.

scripts/split-tox-gh-actions/templates/base.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- master
88
- release/**
9+
- sentry-sdk-2.0
910

1011
{% if needs_github_secrets %}
1112
# XXX: We are using `pull_request_target` instead of `pull_request` because we want

sentry_sdk/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"internal",
5555
"profile",
5656
"statsd",
57-
"check_in",
57+
"monitor",
5858
]
5959
SessionStatus = Literal["ok", "exited", "crashed", "abnormal"]
6060
EndpointType = Literal["store", "envelope"]

sentry_sdk/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ def _setup_instrumentation(self, functions_to_trace):
198198
module_obj = import_module(module_name)
199199
class_obj = getattr(module_obj, class_name)
200200
function_obj = getattr(class_obj, function_name)
201-
setattr(class_obj, function_name, trace(function_obj))
201+
function_type = type(class_obj.__dict__[function_name])
202+
traced_function = trace(function_obj)
203+
204+
if function_type in (staticmethod, classmethod):
205+
traced_function = staticmethod(traced_function)
206+
207+
setattr(class_obj, function_name, traced_function)
202208
setattr(module_obj, class_name, class_obj)
203209
logger.debug("Enabled tracing for %s", function_qualname)
204210

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,4 @@ def _get_default_options():
316316
del _get_default_options
317317

318318

319-
VERSION = "1.39.0"
319+
VERSION = "1.39.1"

sentry_sdk/envelope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def data_category(self):
263263
elif ty == "statsd":
264264
return "statsd"
265265
elif ty == "check_in":
266-
return "check_in"
266+
return "monitor"
267267
else:
268268
return "default"
269269

sentry_sdk/integrations/aiohttp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async def sentry_app_handle(self, request, *args, **kwargs):
141141
transaction.set_http_status(response.status)
142142
return response
143143

144-
Application._handle = sentry_app_handle # type: ignore[method-assign]
144+
Application._handle = sentry_app_handle
145145

146146
old_urldispatcher_resolve = UrlDispatcher.resolve
147147

@@ -173,7 +173,7 @@ async def sentry_urldispatcher_resolve(self, request):
173173

174174
return rv
175175

176-
UrlDispatcher.resolve = sentry_urldispatcher_resolve # type: ignore[method-assign]
176+
UrlDispatcher.resolve = sentry_urldispatcher_resolve
177177

178178
old_client_session_init = ClientSession.__init__
179179

@@ -190,7 +190,7 @@ def init(*args, **kwargs):
190190
kwargs["trace_configs"] = client_trace_configs
191191
return old_client_session_init(*args, **kwargs)
192192

193-
ClientSession.__init__ = init # type: ignore[method-assign]
193+
ClientSession.__init__ = init
194194

195195

196196
def create_trace_config():

sentry_sdk/integrations/arq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ async def _sentry_coroutine(ctx, *args, **kwargs):
169169
# type: (Dict[Any, Any], *Any, **Any) -> Any
170170
hub = Hub.current
171171
if hub.get_integration(ArqIntegration) is None:
172-
return await coroutine(*args, **kwargs)
172+
return await coroutine(ctx, *args, **kwargs)
173173

174174
hub.scope.add_event_processor(
175175
_make_event_processor({**ctx, "job_name": name}, *args, **kwargs)

sentry_sdk/integrations/django/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def _set_db_data(span, cursor_or_db):
697697
is_psycopg2 = (
698698
hasattr(cursor_or_db, "connection")
699699
and hasattr(cursor_or_db.connection, "get_dsn_parameters")
700-
and inspect.isfunction(cursor_or_db.connection.get_dsn_parameters)
700+
and inspect.isroutine(cursor_or_db.connection.get_dsn_parameters)
701701
)
702702
if is_psycopg2:
703703
connection_params = cursor_or_db.connection.get_dsn_parameters()
@@ -706,7 +706,7 @@ def _set_db_data(span, cursor_or_db):
706706
hasattr(cursor_or_db, "connection")
707707
and hasattr(cursor_or_db.connection, "info")
708708
and hasattr(cursor_or_db.connection.info, "get_parameters")
709-
and inspect.isfunction(cursor_or_db.connection.info.get_parameters)
709+
and inspect.isroutine(cursor_or_db.connection.info.get_parameters)
710710
)
711711
if is_psycopg3:
712712
connection_params = cursor_or_db.connection.info.get_parameters()

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

tests/conftest.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import socket
44
from threading import Thread
5+
from contextlib import contextmanager
56

67
import pytest
78
import jsonschema
@@ -27,8 +28,13 @@
2728
from http.server import BaseHTTPRequestHandler, HTTPServer
2829

2930

31+
try:
32+
from unittest import mock
33+
except ImportError:
34+
import mock
35+
3036
import sentry_sdk
31-
from sentry_sdk._compat import iteritems, reraise, string_types
37+
from sentry_sdk._compat import iteritems, reraise, string_types, PY2
3238
from sentry_sdk.envelope import Envelope
3339
from sentry_sdk.integrations import _processed_integrations # noqa: F401
3440
from sentry_sdk.profiler import teardown_profiler
@@ -37,6 +43,12 @@
3743

3844
from tests import _warning_recorder, _warning_recorder_mgr
3945

46+
from sentry_sdk._types import TYPE_CHECKING
47+
48+
if TYPE_CHECKING:
49+
from typing import Optional
50+
from collections.abc import Iterator
51+
4052

4153
SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json"
4254

@@ -620,3 +632,23 @@ def werkzeug_set_cookie(client, servername, key, value):
620632
client.set_cookie(servername, key, value)
621633
except TypeError:
622634
client.set_cookie(key, value)
635+
636+
637+
@contextmanager
638+
def patch_start_tracing_child(fake_transaction_is_none=False):
639+
# type: (bool) -> Iterator[Optional[mock.MagicMock]]
640+
if not fake_transaction_is_none:
641+
fake_transaction = mock.MagicMock()
642+
fake_start_child = mock.MagicMock()
643+
fake_transaction.start_child = fake_start_child
644+
else:
645+
fake_transaction = None
646+
fake_start_child = None
647+
648+
version = "2" if PY2 else "3"
649+
650+
with mock.patch(
651+
"sentry_sdk.tracing_utils_py%s.get_current_span" % version,
652+
return_value=fake_transaction,
653+
):
654+
yield fake_start_child

tests/integrations/arq/test_arq.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import pytest
33

4-
from sentry_sdk import start_transaction
4+
from sentry_sdk import start_transaction, Hub
55
from sentry_sdk.integrations.arq import ArqIntegration
66

77
import arq.worker
@@ -234,3 +234,21 @@ async def dummy_job(_):
234234
assert len(event["spans"])
235235
assert event["spans"][0]["op"] == "queue.submit.arq"
236236
assert event["spans"][0]["description"] == "dummy_job"
237+
238+
239+
@pytest.mark.asyncio
240+
async def test_execute_job_without_integration(init_arq):
241+
async def dummy_job(_ctx):
242+
pass
243+
244+
dummy_job.__qualname__ = dummy_job.__name__
245+
246+
pool, worker = init_arq([dummy_job])
247+
# remove the integration to trigger the edge case
248+
Hub.current.client.integrations.pop("arq")
249+
250+
job = await pool.enqueue_job("dummy_job")
251+
252+
await worker.run_job(job.job_id, timestamp_ms())
253+
254+
assert await job.result() is None

0 commit comments

Comments
 (0)