Skip to content

Commit 8cd1584

Browse files
authored
Merge branch 'master' into antonpirker/threading-tests
2 parents 160e430 + e71ccbf commit 8cd1584

File tree

8 files changed

+142
-42
lines changed

8 files changed

+142
-42
lines changed

CHANGELOG.md

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

3+
## 2.26.0
4+
5+
### Various fixes & improvements
6+
7+
- fix(debug): Do not consider parent loggers for debug logging (#4286) by @szokeasaurusrex
8+
- test(tracing): Simplify static/classmethod tracing tests (#4278) by @szokeasaurusrex
9+
- feat(transport): Add a timeout (#4252) by @sentrivana
10+
- meta: Change CODEOWNERS back to Python SDK owners (#4269) by @sentrivana
11+
- feat(logs): Add sdk name and version as log attributes (#4262) by @AbhiPrasad
12+
- feat(logs): Add server.address to logs (#4257) by @AbhiPrasad
13+
- chore: Deprecate `same_process_as_parent` (#4244) by @sentrivana
14+
- feat(logs): Add sentry.origin attribute for log handler (#4250) by @AbhiPrasad
15+
- feat(tests): Add optional cutoff to toxgen (#4243) by @sentrivana
16+
- toxgen: Retry & fail if we fail to fetch PyPI data (#4251) by @sentrivana
17+
- build(deps): bump actions/create-github-app-token from 1.12.0 to 2.0.2 (#4248) by @dependabot
18+
- Trying to prevent the grpc setup from being flaky (#4233) by @antonpirker
19+
- feat(breadcrumbs): add `_meta` information for truncation of breadcrumbs (#4007) by @shellmayr
20+
- tests: Move django under toxgen (#4238) by @sentrivana
21+
- fix: Handle JSONDecodeError gracefully in StarletteRequestExtractor (#4226) by @moodix
22+
- fix(asyncio): Remove shutdown handler (#4237) by @sentrivana
23+
324
## 2.25.1
425

526
### Various fixes & improvements

docs/conf.py

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

34-
release = "2.25.1"
34+
release = "2.26.0"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,4 +966,4 @@ def _get_default_options():
966966
del _get_default_options
967967

968968

969-
VERSION = "2.25.1"
969+
VERSION = "2.26.0"

sentry_sdk/debug.py

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

2020
def init_debug_support():
2121
# type: () -> None
22-
if not logger.hasHandlers():
22+
if not logger.handlers:
2323
configure_logger()
2424

2525

sentry_sdk/integrations/logging.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,7 @@ def _emit(self, record):
265265
else:
266266
event["logentry"] = {
267267
"message": to_string(record.msg),
268-
"params": (
269-
tuple(str(arg) if arg is None else arg for arg in record.args)
270-
if record.args
271-
else ()
272-
),
268+
"params": record.args,
273269
}
274270

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

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

tests/integrations/logging/test_logging.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,33 @@ def test_ignore_logger_wildcard(sentry_init, capture_events):
234234

235235
(event,) = events
236236
assert event["logentry"]["message"] == "hi"
237+
238+
239+
def test_logging_dictionary_interpolation(sentry_init, capture_events):
240+
"""Here we test an entire dictionary being interpolated into the log message."""
241+
sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
242+
events = capture_events()
243+
244+
logger.error("this is a log with a dictionary %s", {"foo": "bar"})
245+
246+
(event,) = events
247+
assert event["logentry"]["message"] == "this is a log with a dictionary %s"
248+
assert event["logentry"]["params"] == {"foo": "bar"}
249+
250+
251+
def test_logging_dictionary_args(sentry_init, capture_events):
252+
"""Here we test items from a dictionary being interpolated into the log message."""
253+
sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
254+
events = capture_events()
255+
256+
logger.error(
257+
"the value of foo is %(foo)s, and the value of bar is %(bar)s",
258+
{"foo": "bar", "bar": "baz"},
259+
)
260+
261+
(event,) = events
262+
assert (
263+
event["logentry"]["message"]
264+
== "the value of foo is %(foo)s, and the value of bar is %(bar)s"
265+
)
266+
assert event["logentry"]["params"] == {"foo": "bar", "bar": "baz"}

tests/test_basics.py

Lines changed: 86 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytest
1010
from sentry_sdk.client import Client
1111
from sentry_sdk.utils import datetime_from_isoformat
12-
from tests.conftest import patch_start_tracing_child
1312

1413
import sentry_sdk
1514
import sentry_sdk.scope
@@ -935,46 +934,100 @@ def class_(cls, arg):
935934
return cls, arg
936935

937936

938-
def test_staticmethod_tracing(sentry_init):
939-
test_staticmethod_name = "tests.test_basics.TracingTestClass.static"
937+
# We need to fork here because the test modifies tests.test_basics.TracingTestClass
938+
@pytest.mark.forked
939+
def test_staticmethod_class_tracing(sentry_init, capture_events):
940+
sentry_init(
941+
debug=True,
942+
traces_sample_rate=1.0,
943+
functions_to_trace=[
944+
{"qualified_name": "tests.test_basics.TracingTestClass.static"}
945+
],
946+
)
940947

941-
assert (
942-
".".join(
943-
[
944-
TracingTestClass.static.__module__,
945-
TracingTestClass.static.__qualname__,
946-
]
947-
)
948-
== test_staticmethod_name
949-
), "The test static method was moved or renamed. Please update the name accordingly"
948+
events = capture_events()
950949

951-
sentry_init(functions_to_trace=[{"qualified_name": test_staticmethod_name}])
950+
with sentry_sdk.start_transaction(name="test"):
951+
assert TracingTestClass.static(1) == 1
952952

953-
for instance_or_class in (TracingTestClass, TracingTestClass()):
954-
with patch_start_tracing_child() as fake_start_child:
955-
assert instance_or_class.static(1) == 1
956-
assert fake_start_child.call_count == 1
953+
(event,) = events
954+
assert event["type"] == "transaction"
955+
assert event["transaction"] == "test"
957956

957+
(span,) = event["spans"]
958+
assert span["description"] == "tests.test_basics.TracingTestClass.static"
958959

959-
def test_classmethod_tracing(sentry_init):
960-
test_classmethod_name = "tests.test_basics.TracingTestClass.class_"
961960

962-
assert (
963-
".".join(
964-
[
965-
TracingTestClass.class_.__module__,
966-
TracingTestClass.class_.__qualname__,
967-
]
968-
)
969-
== test_classmethod_name
970-
), "The test class method was moved or renamed. Please update the name accordingly"
961+
# We need to fork here because the test modifies tests.test_basics.TracingTestClass
962+
@pytest.mark.forked
963+
def test_staticmethod_instance_tracing(sentry_init, capture_events):
964+
sentry_init(
965+
debug=True,
966+
traces_sample_rate=1.0,
967+
functions_to_trace=[
968+
{"qualified_name": "tests.test_basics.TracingTestClass.static"}
969+
],
970+
)
971+
972+
events = capture_events()
973+
974+
with sentry_sdk.start_transaction(name="test"):
975+
assert TracingTestClass().static(1) == 1
976+
977+
(event,) = events
978+
assert event["type"] == "transaction"
979+
assert event["transaction"] == "test"
971980

972-
sentry_init(functions_to_trace=[{"qualified_name": test_classmethod_name}])
981+
(span,) = event["spans"]
982+
assert span["description"] == "tests.test_basics.TracingTestClass.static"
983+
984+
985+
# We need to fork here because the test modifies tests.test_basics.TracingTestClass
986+
@pytest.mark.forked
987+
def test_classmethod_class_tracing(sentry_init, capture_events):
988+
sentry_init(
989+
debug=True,
990+
traces_sample_rate=1.0,
991+
functions_to_trace=[
992+
{"qualified_name": "tests.test_basics.TracingTestClass.class_"}
993+
],
994+
)
995+
996+
events = capture_events()
997+
998+
with sentry_sdk.start_transaction(name="test"):
999+
assert TracingTestClass.class_(1) == (TracingTestClass, 1)
1000+
1001+
(event,) = events
1002+
assert event["type"] == "transaction"
1003+
assert event["transaction"] == "test"
1004+
1005+
(span,) = event["spans"]
1006+
assert span["description"] == "tests.test_basics.TracingTestClass.class_"
1007+
1008+
1009+
# We need to fork here because the test modifies tests.test_basics.TracingTestClass
1010+
@pytest.mark.forked
1011+
def test_classmethod_instance_tracing(sentry_init, capture_events):
1012+
sentry_init(
1013+
debug=True,
1014+
traces_sample_rate=1.0,
1015+
functions_to_trace=[
1016+
{"qualified_name": "tests.test_basics.TracingTestClass.class_"}
1017+
],
1018+
)
1019+
1020+
events = capture_events()
1021+
1022+
with sentry_sdk.start_transaction(name="test"):
1023+
assert TracingTestClass().class_(1) == (TracingTestClass, 1)
1024+
1025+
(event,) = events
1026+
assert event["type"] == "transaction"
1027+
assert event["transaction"] == "test"
9731028

974-
for instance_or_class in (TracingTestClass, TracingTestClass()):
975-
with patch_start_tracing_child() as fake_start_child:
976-
assert instance_or_class.class_(1) == (TracingTestClass, 1)
977-
assert fake_start_child.call_count == 1
1029+
(span,) = event["spans"]
1030+
assert span["description"] == "tests.test_basics.TracingTestClass.class_"
9781031

9791032

9801033
def test_last_event_id(sentry_init):

0 commit comments

Comments
 (0)