From 3d0edfd6387c9e35bddac572d3613c741cc3c3d0 Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Mon, 9 Sep 2024 11:22:25 +0000 Subject: [PATCH 1/4] release: 2.14.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ docs/conf.py | 2 +- sentry_sdk/consts.py | 2 +- setup.py | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54fa4a2133..85e3920251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 2.14.0 + +### Various fixes & improvements + +- tests: Remove broken bottle tests (#3505) by @sentrivana +- Fixed config for old coverage versions (#3504) by @antonpirker +- Fix AWS Lambda tests (#3495) by @antonpirker +- Better test coverage reports (#3498) by @antonpirker +- feat(celery): Add wrapper for `Celery().send_task` to support behavior as `Task.apply_async` (#2377) by @divaltor +- fix(django): SentryWrappingMiddleware.__init__ fails if super() is object (#2466) by @cameron-simpson +- feat(strawberry): Support Strawberry 0.239.2 (#3491) by @szokeasaurusrex +- ref: Remove obsolete object as superclass (#3480) by @sentrivana +- Fix data_category for sessions envelope items (#3473) by @sl0thentr0py +- fix: Fix non-UTC timestamps (#3461) by @szokeasaurusrex +- Add separate pii_denylist to EventScrubber and run it always (#3463) by @sl0thentr0py +- Revert "Pin httpx till upstream gets resolved (#3465)" (#3466) by @sl0thentr0py +- feat(integrations): New `SysExitIntegration` (#3401) by @szokeasaurusrex +- ref(types): Replace custom TYPE_CHECKING with stdlib typing.TYPE_CHECKING (#3447) by @dev-satoshi +- Pin httpx till upstream gets resolved (#3465) by @sl0thentr0py +- chore(tracing): Refactor `tracing_utils.py` (#3452) by @rominf +- feat: Add SENTRY_SPOTLIGHT env variable support (#3443) by @BYK +- style: explicitly export symbols instead of ignoring (#3400) by @hartungstenio + ## 2.13.0 ### Various fixes & improvements diff --git a/docs/conf.py b/docs/conf.py index c30f18c8a8..875dfcb575 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year) author = "Sentry Team and Contributors" -release = "2.13.0" +release = "2.14.0" version = ".".join(release.split(".")[:2]) # The short X.Y version. diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index 5581f191b7..5f79031787 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -567,4 +567,4 @@ def _get_default_options(): del _get_default_options -VERSION = "2.13.0" +VERSION = "2.14.0" diff --git a/setup.py b/setup.py index ee1d52b2e8..c11b6b771e 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def get_file_text(file_name): setup( name="sentry-sdk", - version="2.13.0", + version="2.14.0", author="Sentry Team and Contributors", author_email="hello@sentry.io", url="https://github.com/getsentry/sentry-python", From 1e73ce9fa12ea04250a708c14531d94827501a1d Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 9 Sep 2024 13:33:13 +0200 Subject: [PATCH 2/4] Updated changelog --- CHANGELOG.md | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e3920251..0fa0621afb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,24 +4,25 @@ ### Various fixes & improvements -- tests: Remove broken bottle tests (#3505) by @sentrivana -- Fixed config for old coverage versions (#3504) by @antonpirker -- Fix AWS Lambda tests (#3495) by @antonpirker -- Better test coverage reports (#3498) by @antonpirker -- feat(celery): Add wrapper for `Celery().send_task` to support behavior as `Task.apply_async` (#2377) by @divaltor -- fix(django): SentryWrappingMiddleware.__init__ fails if super() is object (#2466) by @cameron-simpson -- feat(strawberry): Support Strawberry 0.239.2 (#3491) by @szokeasaurusrex -- ref: Remove obsolete object as superclass (#3480) by @sentrivana +- New `SysExitIntegration` (#3401) by @szokeasaurusrex + + For more information, see the documentation for the [SysExitIntegration](https://docs.sentry.io/platforms/python/integrations/sys_exit). + +- Add `SENTRY_SPOTLIGHT` env variable support (#3443) by @BYK +- Support Strawberry `0.239.2` (#3491) by @szokeasaurusrex +- Add separate `pii_denylist` to `EventScrubber` and run it always (#3463) by @sl0thentr0py +- Celery: Add wrapper for `Celery().send_task` to support behavior as `Task.apply_async` (#2377) by @divaltor +- Django: SentryWrappingMiddleware.__init__ fails if super() is object (#2466) by @cameron-simpson - Fix data_category for sessions envelope items (#3473) by @sl0thentr0py -- fix: Fix non-UTC timestamps (#3461) by @szokeasaurusrex -- Add separate pii_denylist to EventScrubber and run it always (#3463) by @sl0thentr0py -- Revert "Pin httpx till upstream gets resolved (#3465)" (#3466) by @sl0thentr0py -- feat(integrations): New `SysExitIntegration` (#3401) by @szokeasaurusrex -- ref(types): Replace custom TYPE_CHECKING with stdlib typing.TYPE_CHECKING (#3447) by @dev-satoshi -- Pin httpx till upstream gets resolved (#3465) by @sl0thentr0py -- chore(tracing): Refactor `tracing_utils.py` (#3452) by @rominf -- feat: Add SENTRY_SPOTLIGHT env variable support (#3443) by @BYK -- style: explicitly export symbols instead of ignoring (#3400) by @hartungstenio +- Fix non-UTC timestamps (#3461) by @szokeasaurusrex +- Remove obsolete object as superclass (#3480) by @sentrivana +- Replace custom `TYPE_CHECKING` with stdlib `typing.TYPE_CHECKING` (#3447) by @dev-satoshi +- Refactor `tracing_utils.py` (#3452) by @rominf +- Explicitly export symbol in subpackages instead of ignoring (#3400) by @hartungstenio +- Better test coverage reports (#3498) by @antonpirker +- Fixed config for old coverage versions (#3504) by @antonpirker +- Fix AWS Lambda tests (#3495) by @antonpirker +- Remove broken Bottle tests (#3505) by @sentrivana ## 2.13.0 From 22f62b0d3236e888b1bf40a4532a11b289703172 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 10 Sep 2024 14:59:03 +0200 Subject: [PATCH 3/4] fix(breadcrumbs): Fix sorting (#3511) - best-effort coerce string timestamps into datetimes before sorting - ignore errors while breadcrumb sorting (better to have unsorted crumbs than breaking anything) --- sentry_sdk/scope.py | 12 +++++++++++- sentry_sdk/utils.py | 9 +++++++++ tests/test_basics.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 6e0d0925c8..b6a23253e8 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -30,6 +30,7 @@ capture_internal_exception, capture_internal_exceptions, ContextVar, + datetime_from_isoformat, disable_capture_event, event_from_exception, exc_info_from_error, @@ -1307,7 +1308,16 @@ def _apply_breadcrumbs_to_event(self, event, hint, options): event.setdefault("breadcrumbs", {}).setdefault("values", []).extend( self._breadcrumbs ) - event["breadcrumbs"]["values"].sort(key=lambda crumb: crumb["timestamp"]) + + # Attempt to sort timestamps + try: + for crumb in event["breadcrumbs"]["values"]: + if isinstance(crumb["timestamp"], str): + crumb["timestamp"] = datetime_from_isoformat(crumb["timestamp"]) + + event["breadcrumbs"]["values"].sort(key=lambda crumb: crumb["timestamp"]) + except Exception: + pass def _apply_user_to_event(self, event, hint, options): # type: (Event, Hint, Optional[Dict[str, Any]]) -> None diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 9f49b9470f..38ab7e3618 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -239,6 +239,15 @@ def format_timestamp(value): return utctime.strftime("%Y-%m-%dT%H:%M:%S.%fZ") +def datetime_from_isoformat(value): + # type: (str) -> datetime + try: + return datetime.fromisoformat(value) + except AttributeError: + # py 3.6 + return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f") + + def event_hint_with_exc_info(exc_info=None): # type: (Optional[ExcInfo]) -> Dict[str, Optional[ExcInfo]] """Creates a hint with the exc info filled in.""" diff --git a/tests/test_basics.py b/tests/test_basics.py index c9d80118c2..6f77353c8a 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -425,6 +425,37 @@ def test_breadcrumb_ordering(sentry_init, capture_events): assert timestamps_from_event == sorted(timestamps) +def test_breadcrumb_ordering_different_types(sentry_init, capture_events): + sentry_init() + events = capture_events() + + timestamps = [ + datetime.datetime.now() - datetime.timedelta(days=10), + datetime.datetime.now() - datetime.timedelta(days=8), + datetime.datetime.now() - datetime.timedelta(days=12), + ] + + for i, timestamp in enumerate(timestamps): + add_breadcrumb( + message="Authenticated at %s" % timestamp, + category="auth", + level="info", + timestamp=timestamp if i % 2 == 0 else timestamp.isoformat(), + ) + + capture_exception(ValueError()) + (event,) = events + + assert len(event["breadcrumbs"]["values"]) == len(timestamps) + timestamps_from_event = [ + datetime.datetime.strptime( + x["timestamp"].replace("Z", ""), "%Y-%m-%dT%H:%M:%S.%f" + ) + for x in event["breadcrumbs"]["values"] + ] + assert timestamps_from_event == sorted(timestamps) + + def test_attachments(sentry_init, capture_envelopes): sentry_init() envelopes = capture_envelopes() From c635e3e1181304e70ec86ccfc486edae58286c26 Mon Sep 17 00:00:00 2001 From: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:17:13 +0200 Subject: [PATCH 4/4] ref(metrics): Deprecate `sentry_sdk.metrics` (#3512) Raise a `DeprecationWarning` on import of the `sentry_sdk.metrics` module. Closes #3502 --- sentry_sdk/metrics.py | 9 +++++++++ sentry_sdk/tracing.py | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/metrics.py b/sentry_sdk/metrics.py index 05dc13042c..da6d77c69a 100644 --- a/sentry_sdk/metrics.py +++ b/sentry_sdk/metrics.py @@ -5,6 +5,7 @@ import sys import threading import time +import warnings import zlib from abc import ABC, abstractmethod from contextlib import contextmanager @@ -54,6 +55,14 @@ from sentry_sdk._types import MetricValue +warnings.warn( + "The sentry_sdk.metrics module is deprecated and will be removed in the next major release. " + "Sentry will reject all metrics sent after October 7, 2024. " + "Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics", + DeprecationWarning, + stacklevel=2, +) + _in_metrics = ContextVar("in_metrics", default=False) _set = set # set is shadowed below diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 3ca9744b54..41525b4676 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -1298,4 +1298,8 @@ async def my_async_function(): has_tracing_enabled, maybe_create_breadcrumbs_from_span, ) -from sentry_sdk.metrics import LocalAggregator + +with warnings.catch_warnings(): + # The code in this file which uses `LocalAggregator` is only called from the deprecated `metrics` module. + warnings.simplefilter("ignore", DeprecationWarning) + from sentry_sdk.metrics import LocalAggregator