Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-sentry-sdk for openSUSE:Factory checked in at 2021-05-07 16:45:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-sentry-sdk (Old) and /work/SRC/openSUSE:Factory/.python-sentry-sdk.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sentry-sdk" Fri May 7 16:45:44 2021 rev:15 rq:891161 version:1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-sentry-sdk/python-sentry-sdk.changes 2021-03-11 20:12:39.776699695 +0100 +++ /work/SRC/openSUSE:Factory/.python-sentry-sdk.new.2988/python-sentry-sdk.changes 2021-05-07 16:46:07.164217695 +0200 @@ -1,0 +2,14 @@ +Thu May 6 18:54:28 UTC 2021 - ecsos <ec...@opensuse.org> + +- Update to 1.1.0 + - Fix for AWSLambda integration returns value of original handler + #1106 + - Fix for RQ integration that only captures exception if RQ job + has failed and ignore retries #1076 + - Feature that supports Tracing for the Tornado integration #1060 + - Feature that supports wild cards in ignore_logger in the + Logging Integration #1053 + - Fix for django that deals with template span description names + that are either lists or tuples #1054 + +------------------------------------------------------------------- Old: ---- sentry-python-1.0.0.tar.gz New: ---- sentry-python-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-sentry-sdk.spec ++++++ --- /var/tmp/diff_new_pack.GrTTy2/_old 2021-05-07 16:46:07.692216034 +0200 +++ /var/tmp/diff_new_pack.GrTTy2/_new 2021-05-07 16:46:07.696216022 +0200 @@ -20,7 +20,7 @@ # nothing provides python2-venusian >= 1.0 needed by python2-pyramid %define skip_python2 1 Name: python-sentry-sdk -Version: 1.0.0 +Version: 1.1.0 Release: 0 Summary: Python SDK for Sentry.io License: BSD-2-Clause @@ -58,12 +58,12 @@ BuildRequires: %{python_module tox} # /SECTION # SECTION extra requirements - which rise up buildtime error or missing in openSUSE +#BuildRequires: %%{python_module pyspark >= 2.4.4} #BuildRequires: %%{python_module Django >= 1.8} -#BuildRequires: %%{python_module sanic >= 0.8} #BuildRequires: %%{python_module apache-beam >= 2.12} -#BuildRequires: %%{python_module pyspark >= 2.4.4} -#BuildRequires: %%{python_module pure_eval} #BuildRequires: %%{python_module chalice >= 1.16.0} +#BuildRequires: %%{python_module pure_eval} +#BuildRequires: %%{python_module sanic >= 0.8} # /SECTION Requires: python-Flask >= 0.11 Requires: python-SQLAlchemy >= 1.2 ++++++ sentry-python-1.0.0.tar.gz -> sentry-python-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/.github/workflows/ci.yml new/sentry-python-1.1.0/.github/workflows/ci.yml --- old/sentry-python-1.0.0/.github/workflows/ci.yml 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/.github/workflows/ci.yml 2021-05-06 18:58:30.000000000 +0200 @@ -77,7 +77,7 @@ strategy: matrix: python-version: - ["2.7", "pypy-2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9"] + ["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9"] services: # Label used to access the service container diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/.github/workflows/codeql-analysis.yml new/sentry-python-1.1.0/.github/workflows/codeql-analysis.yml --- old/sentry-python-1.0.0/.github/workflows/codeql-analysis.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/sentry-python-1.1.0/.github/workflows/codeql-analysis.yml 2021-05-06 18:58:30.000000000 +0200 @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '18 18 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ?????? Command-line programs to run using the OS shell. + # ???? https://git.io/JvXDl + + # ?????? If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/CHANGELOG.md new/sentry-python-1.1.0/CHANGELOG.md --- old/sentry-python-1.0.0/CHANGELOG.md 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/CHANGELOG.md 2021-05-06 18:58:30.000000000 +0200 @@ -10,7 +10,7 @@ - Certain features (e.g. integrations) may be explicitly called out as "experimental" or "unstable" in the documentation. They come with their own versioning policy described in the documentation. -We recommend to pin your version requirements against `0.x.*` or `0.x.y`. +We recommend to pin your version requirements against `1.x.*` or `1.x.y`. Either one of the following is fine: ``` @@ -20,11 +20,19 @@ A major release `N` implies the previous release `N-1` will no longer receive updates. We generally do not backport bugfixes to older versions unless they are security relevant. However, feel free to ask for backports of specific commits on the bugtracker. +## 1.1.0 + +- Fix for `AWSLambda` integration returns value of original handler #1106 +- Fix for `RQ` integration that only captures exception if RQ job has failed and ignore retries #1076 +- Feature that supports Tracing for the `Tornado` integration #1060 +- Feature that supports wild cards in `ignore_logger` in the `Logging` Integration #1053 +- Fix for django that deals with template span description names that are either lists or tuples #1054 + ## 1.0.0 -This release contains breaking changes +This release contains a breaking change -- Feat: Moved `auto_session_tracking` experimental flag to a proper option and removed `session_mode`, hence enabling release health by default #994 +- **BREAKING CHANGE**: Feat: Moved `auto_session_tracking` experimental flag to a proper option and removed explicitly setting experimental `session_mode` in favor of auto detecting its value, hence enabling release health by default #994 - Fixed Django transaction name by setting the name to `request.path_info` rather than `request.path` - Fix for tracing by getting HTTP headers from span rather than transaction when possible #1035 - Fix for Flask transactions missing request body in non errored transactions #1034 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/README.md new/sentry-python-1.1.0/README.md --- old/sentry-python-1.0.0/README.md 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/README.md 2021-05-06 18:58:30.000000000 +0200 @@ -4,6 +4,8 @@ </a> </p> +_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [<kbd>**Check out our open positions**</kbd>](https://sentry.io/careers/)_ + # sentry-python - Sentry SDK for Python [![Build Status](https://travis-ci.com/getsentry/sentry-python.svg?branch=master)](https://travis-ci.com/getsentry/sentry-python) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/docs/conf.py new/sentry-python-1.1.0/docs/conf.py --- old/sentry-python-1.0.0/docs/conf.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/docs/conf.py 2021-05-06 18:58:30.000000000 +0200 @@ -22,7 +22,7 @@ copyright = u"2019, Sentry Team and Contributors" author = u"Sentry Team and Contributors" -release = "1.0.0" +release = "1.1.0" version = ".".join(release.split(".")[:2]) # The short X.Y version. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/docs-requirements.txt new/sentry-python-1.1.0/docs-requirements.txt --- old/sentry-python-1.0.0/docs-requirements.txt 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/docs-requirements.txt 2021-05-06 18:58:30.000000000 +0200 @@ -1,4 +1,4 @@ -sphinx==3.5.1 +sphinx==3.5.3 sphinx-rtd-theme sphinx-autodoc-typehints[type_comments]>=1.8.0 typing-extensions diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/linter-requirements.txt new/sentry-python-1.1.0/linter-requirements.txt --- old/sentry-python-1.0.0/linter-requirements.txt 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/linter-requirements.txt 2021-05-06 18:58:30.000000000 +0200 @@ -1,6 +1,6 @@ black==20.8b1 -flake8==3.8.4 +flake8==3.9.0 flake8-import-order==0.18.1 mypy==0.782 -flake8-bugbear==20.11.1 +flake8-bugbear==21.3.2 pep8-naming==0.11.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/scripts/build_awslambda_layer.py new/sentry-python-1.1.0/scripts/build_awslambda_layer.py --- old/sentry-python-1.0.0/scripts/build_awslambda_layer.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/scripts/build_awslambda_layer.py 2021-05-06 18:58:30.000000000 +0200 @@ -51,12 +51,14 @@ Method that creates the init_serverless_sdk pkg in the sentry-python-serverless zip """ - serverless_sdk_path = f'{self.packages_dir}/sentry_sdk/' \ - f'integrations/init_serverless_sdk' + serverless_sdk_path = ( + f"{self.packages_dir}/sentry_sdk/" f"integrations/init_serverless_sdk" + ) if not os.path.exists(serverless_sdk_path): os.makedirs(serverless_sdk_path) - shutil.copy('scripts/init_serverless_sdk.py', - f'{serverless_sdk_path}/__init__.py') + shutil.copy( + "scripts/init_serverless_sdk.py", f"{serverless_sdk_path}/__init__.py" + ) def zip( self, filename # type: str diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/scripts/init_serverless_sdk.py new/sentry-python-1.1.0/scripts/init_serverless_sdk.py --- old/sentry-python-1.0.0/scripts/init_serverless_sdk.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/scripts/init_serverless_sdk.py 2021-05-06 18:58:30.000000000 +0200 @@ -19,7 +19,7 @@ sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[AwsLambdaIntegration(timeout_warning=True)], - traces_sample_rate=float(os.environ["SENTRY_TRACES_SAMPLE_RATE"]) + traces_sample_rate=float(os.environ["SENTRY_TRACES_SAMPLE_RATE"]), ) @@ -35,4 +35,4 @@ raise ValueError("Incorrect AWS Handler path (Not a path)") lambda_function = __import__(module_name) lambda_handler = getattr(lambda_function, handler_name) - lambda_handler(event, context) + return lambda_handler(event, context) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/_types.py new/sentry-python-1.1.0/sentry_sdk/_types.py --- old/sentry-python-1.0.0/sentry_sdk/_types.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/_types.py 2021-05-06 18:58:30.000000000 +0200 @@ -5,7 +5,6 @@ if MYPY: - from numbers import Real from types import TracebackType from typing import Any from typing import Callable @@ -32,7 +31,7 @@ ErrorProcessor = Callable[[Event, ExcInfo], Optional[Event]] BreadcrumbProcessor = Callable[[Breadcrumb, BreadcrumbHint], Optional[Breadcrumb]] - TracesSampler = Callable[[SamplingContext], Union[Real, bool]] + TracesSampler = Callable[[SamplingContext], Union[float, int, bool]] # https://github.com/python/mypy/issues/5710 NotImplementedType = Any diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/consts.py new/sentry-python-1.1.0/sentry_sdk/consts.py --- old/sentry-python-1.0.0/sentry_sdk/consts.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/consts.py 2021-05-06 18:58:30.000000000 +0200 @@ -99,7 +99,7 @@ del _get_default_options -VERSION = "1.0.0" +VERSION = "1.1.0" SDK_INFO = { "name": "sentry.python", "version": VERSION, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/aiohttp.py new/sentry-python-1.1.0/sentry_sdk/integrations/aiohttp.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/aiohttp.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/aiohttp.py 2021-05-06 18:58:30.000000000 +0200 @@ -92,7 +92,7 @@ weak_request = weakref.ref(request) - with Hub(Hub.current) as hub: + with Hub(hub) as hub: # Scope data will not leak between requests because aiohttp # create a task to wrap each request. with hub.configure_scope() as scope: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/django/__init__.py new/sentry-python-1.1.0/sentry_sdk/integrations/django/__init__.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/django/__init__.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/django/__init__.py 2021-05-06 18:58:30.000000000 +0200 @@ -332,8 +332,9 @@ # Rely on WSGI middleware to start a trace try: if integration.transaction_style == "function_name": + fn = resolve(request.path).func scope.transaction = transaction_from_function( - resolve(request.path).func + getattr(fn, "view_class", fn) ) elif integration.transaction_style == "url": scope.transaction = LEGACY_RESOLVER.resolve(request.path_info) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/django/templates.py new/sentry-python-1.1.0/sentry_sdk/integrations/django/templates.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/django/templates.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/django/templates.py 2021-05-06 18:58:30.000000000 +0200 @@ -42,6 +42,15 @@ return None +def _get_template_name_description(template_name): + # type: (str) -> str + if isinstance(template_name, (list, tuple)): + if template_name: + return "[{}, ...]".format(template_name[0]) + else: + return template_name + + def patch_templates(): # type: () -> None from django.template.response import SimpleTemplateResponse @@ -57,7 +66,8 @@ return real_rendered_content.fget(self) with hub.start_span( - op="django.template.render", description=self.template_name + op="django.template.render", + description=_get_template_name_description(self.template_name), ) as span: span.set_data("context", self.context_data) return real_rendered_content.fget(self) @@ -78,7 +88,8 @@ return real_render(request, template_name, context, *args, **kwargs) with hub.start_span( - op="django.template.render", description=template_name + op="django.template.render", + description=_get_template_name_description(template_name), ) as span: span.set_data("context", context) return real_render(request, template_name, context, *args, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/flask.py new/sentry-python-1.1.0/sentry_sdk/integrations/flask.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/flask.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/flask.py 2021-05-06 18:58:30.000000000 +0200 @@ -65,13 +65,17 @@ @staticmethod def setup_once(): # type: () -> None + + # This version parsing is absolutely naive but the alternative is to + # import pkg_resources which slows down the SDK a lot. try: version = tuple(map(int, FLASK_VERSION.split(".")[:3])) except (ValueError, TypeError): - raise DidNotEnable("Unparsable Flask version: {}".format(FLASK_VERSION)) - - if version < (0, 10): - raise DidNotEnable("Flask 0.10 or newer is required.") + # It's probably a release candidate, we assume it's fine. + pass + else: + if version < (0, 10): + raise DidNotEnable("Flask 0.10 or newer is required.") request_started.connect(_request_started) got_request_exception.connect(_capture_exception) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/logging.py new/sentry-python-1.1.0/sentry_sdk/integrations/logging.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/logging.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/logging.py 2021-05-06 18:58:30.000000000 +0200 @@ -2,6 +2,7 @@ import logging import datetime +from fnmatch import fnmatch from sentry_sdk.hub import Hub from sentry_sdk.utils import ( @@ -98,7 +99,11 @@ def _can_record(record): # type: (LogRecord) -> bool - return record.name not in _IGNORED_LOGGERS + """Prevents ignored loggers from recording""" + for logger in _IGNORED_LOGGERS: + if fnmatch(record.name, logger): + return False + return True def _breadcrumb_from_record(record): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/rq.py new/sentry-python-1.1.0/sentry_sdk/integrations/rq.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/rq.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/rq.py 2021-05-06 18:58:30.000000000 +0200 @@ -3,30 +3,28 @@ import weakref from sentry_sdk.hub import Hub -from sentry_sdk.integrations import Integration, DidNotEnable +from sentry_sdk.integrations import DidNotEnable, Integration +from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.tracing import Transaction from sentry_sdk.utils import capture_internal_exceptions, event_from_exception - try: - from rq.version import VERSION as RQ_VERSION + from rq.queue import Queue from rq.timeouts import JobTimeoutException + from rq.version import VERSION as RQ_VERSION from rq.worker import Worker - from rq.queue import Queue except ImportError: raise DidNotEnable("RQ not installed") from sentry_sdk._types import MYPY if MYPY: - from typing import Any - from typing import Dict - from typing import Callable - - from rq.job import Job + from typing import Any, Callable, Dict - from sentry_sdk.utils import ExcInfo from sentry_sdk._types import EventProcessor + from sentry_sdk.utils import ExcInfo + + from rq.job import Job class RqIntegration(Integration): @@ -89,7 +87,9 @@ def sentry_patched_handle_exception(self, job, *exc_info, **kwargs): # type: (Worker, Any, *Any, **Any) -> Any - _capture_exception(exc_info) # type: ignore + if job.is_failed: + _capture_exception(exc_info) # type: ignore + return old_handle_exception(self, job, *exc_info, **kwargs) Worker.handle_exception = sentry_patched_handle_exception @@ -108,6 +108,8 @@ Queue.enqueue_job = sentry_patched_enqueue_job + ignore_logger("rq.worker") + def _make_event_processor(weak_job): # type: (Callable[[], Job]) -> EventProcessor diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/sentry_sdk/integrations/tornado.py new/sentry-python-1.1.0/sentry_sdk/integrations/tornado.py --- old/sentry-python-1.0.0/sentry_sdk/integrations/tornado.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/sentry_sdk/integrations/tornado.py 2021-05-06 18:58:30.000000000 +0200 @@ -1,7 +1,9 @@ import weakref +import contextlib from inspect import iscoroutinefunction from sentry_sdk.hub import Hub, _should_send_default_pii +from sentry_sdk.tracing import Transaction from sentry_sdk.utils import ( HAS_REAL_CONTEXTVARS, CONTEXTVARS_ERROR_MESSAGE, @@ -32,6 +34,7 @@ from typing import Optional from typing import Dict from typing import Callable + from typing import Generator from sentry_sdk._types import EventProcessor @@ -63,38 +66,16 @@ # Starting Tornado 6 RequestHandler._execute method is a standard Python coroutine (async/await) # In that case our method should be a coroutine function too async def sentry_execute_request_handler(self, *args, **kwargs): - # type: (Any, *Any, **Any) -> Any - hub = Hub.current - integration = hub.get_integration(TornadoIntegration) - if integration is None: - return await old_execute(self, *args, **kwargs) - - weak_handler = weakref.ref(self) - - with Hub(hub) as hub: - with hub.configure_scope() as scope: - scope.clear_breadcrumbs() - processor = _make_event_processor(weak_handler) # type: ignore - scope.add_event_processor(processor) + # type: (RequestHandler, *Any, **Any) -> Any + with _handle_request_impl(self): return await old_execute(self, *args, **kwargs) else: @coroutine # type: ignore - def sentry_execute_request_handler(self, *args, **kwargs): + def sentry_execute_request_handler(self, *args, **kwargs): # type: ignore # type: (RequestHandler, *Any, **Any) -> Any - hub = Hub.current - integration = hub.get_integration(TornadoIntegration) - if integration is None: - return old_execute(self, *args, **kwargs) - - weak_handler = weakref.ref(self) - - with Hub(hub) as hub: - with hub.configure_scope() as scope: - scope.clear_breadcrumbs() - processor = _make_event_processor(weak_handler) # type: ignore - scope.add_event_processor(processor) + with _handle_request_impl(self): result = yield from old_execute(self, *args, **kwargs) return result @@ -110,6 +91,39 @@ RequestHandler.log_exception = sentry_log_exception # type: ignore +@contextlib.contextmanager +def _handle_request_impl(self): + # type: (RequestHandler) -> Generator[None, None, None] + hub = Hub.current + integration = hub.get_integration(TornadoIntegration) + + if integration is None: + yield + + weak_handler = weakref.ref(self) + + with Hub(hub) as hub: + with hub.configure_scope() as scope: + scope.clear_breadcrumbs() + processor = _make_event_processor(weak_handler) # type: ignore + scope.add_event_processor(processor) + + transaction = Transaction.continue_from_headers( + self.request.headers, + op="http.server", + # Like with all other integrations, this is our + # fallback transaction in case there is no route. + # sentry_urldispatcher_resolve is responsible for + # setting a transaction name later. + name="generic Tornado request", + ) + + with hub.start_transaction( + transaction, custom_sampling_context={"tornado_request": self.request} + ): + yield + + def _capture_exception(ty, value, tb): # type: (type, BaseException, Any) -> None hub = Hub.current diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/setup.cfg new/sentry-python-1.1.0/setup.cfg --- old/sentry-python-1.0.0/setup.cfg 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/setup.cfg 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/setup.py new/sentry-python-1.1.0/setup.py --- old/sentry-python-1.0.0/setup.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/setup.py 2021-05-06 18:58:30.000000000 +0200 @@ -21,7 +21,7 @@ setup( name="sentry-sdk", - version="1.0.0", + version="1.1.0", author="Sentry Team and Contributors", author_email="he...@sentry.io", url="https://github.com/getsentry/sentry-python", @@ -72,4 +72,5 @@ "Programming Language :: Python :: 3.9", "Topic :: Software Development :: Libraries :: Python Modules", ], + options={"bdist_wheel": {"universal": "1"}}, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tests/integrations/django/myapp/views.py new/sentry-python-1.1.0/tests/integrations/django/myapp/views.py --- old/sentry-python-1.0.0/tests/integrations/django/myapp/views.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tests/integrations/django/myapp/views.py 2021-05-06 18:58:30.000000000 +0200 @@ -122,7 +122,9 @@ @csrf_exempt def template_test2(request, *args, **kwargs): - return TemplateResponse(request, "user_name.html", {"user_age": 25}) + return TemplateResponse( + request, ("user_name.html", "another_template.html"), {"user_age": 25} + ) @csrf_exempt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tests/integrations/django/test_basic.py new/sentry-python-1.1.0/tests/integrations/django/test_basic.py --- old/sentry-python-1.0.0/tests/integrations/django/test_basic.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tests/integrations/django/test_basic.py 2021-05-06 18:58:30.000000000 +0200 @@ -563,18 +563,25 @@ integrations=[DjangoIntegration()], traces_sample_rate=1.0, ) - views_urls = [reverse("template_test2")] + views_tests = [ + ( + reverse("template_test2"), + '- op="django.template.render": description="[user_name.html, ...]"', + ), + ] if DJANGO_VERSION >= (1, 7): - views_urls.append(reverse("template_test")) + views_tests.append( + ( + reverse("template_test"), + '- op="django.template.render": description="user_name.html"', + ), + ) - for url in views_urls: + for url, expected_line in views_tests: events = capture_events() _content, status, _headers = client.get(url) transaction = events[0] - assert ( - '- op="django.template.render": description="user_name.html"' - in render_span_tree(transaction) - ) + assert expected_line in render_span_tree(transaction) def test_middleware_spans(sentry_init, client, capture_events, render_span_tree): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tests/integrations/logging/test_logging.py new/sentry-python-1.1.0/tests/integrations/logging/test_logging.py --- old/sentry-python-1.0.0/tests/integrations/logging/test_logging.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tests/integrations/logging/test_logging.py 2021-05-06 18:58:30.000000000 +0200 @@ -3,7 +3,7 @@ import pytest import logging -from sentry_sdk.integrations.logging import LoggingIntegration +from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger other_logger = logging.getLogger("testfoo") logger = logging.getLogger(__name__) @@ -134,3 +134,30 @@ (event,) = events assert event["logentry"]["message"] == "hi" + + +def test_ignore_logger(sentry_init, capture_events): + sentry_init(integrations=[LoggingIntegration()], default_integrations=False) + events = capture_events() + + ignore_logger("testfoo") + + other_logger.error("hi") + + assert not events + + +def test_ignore_logger_wildcard(sentry_init, capture_events): + sentry_init(integrations=[LoggingIntegration()], default_integrations=False) + events = capture_events() + + ignore_logger("testfoo.*") + + nested_logger = logging.getLogger("testfoo.submodule") + + logger.error("hi") + + nested_logger.error("bye") + + (event,) = events + assert event["logentry"]["message"] == "hi" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tests/integrations/rq/test_rq.py new/sentry-python-1.1.0/tests/integrations/rq/test_rq.py --- old/sentry-python-1.0.0/tests/integrations/rq/test_rq.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tests/integrations/rq/test_rq.py 2021-05-06 18:58:30.000000000 +0200 @@ -1,8 +1,7 @@ -from sentry_sdk.integrations.rq import RqIntegration - import pytest - from fakeredis import FakeStrictRedis +from sentry_sdk.integrations.rq import RqIntegration + import rq try: @@ -177,3 +176,19 @@ } ) ) + + +@pytest.mark.skipif( + rq.__version__.split(".") < ["1", "5"], reason="At least rq-1.5 required" +) +def test_job_with_retries(sentry_init, capture_events): + sentry_init(integrations=[RqIntegration()]) + events = capture_events() + + queue = rq.Queue(connection=FakeStrictRedis()) + worker = rq.SimpleWorker([queue], connection=queue.connection) + + queue.enqueue(crashing_job, foo=42, retry=rq.Retry(max=1)) + worker.work(burst=True) + + assert len(events) == 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tests/integrations/tornado/test_tornado.py new/sentry-python-1.1.0/tests/integrations/tornado/test_tornado.py --- old/sentry-python-1.0.0/tests/integrations/tornado/test_tornado.py 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tests/integrations/tornado/test_tornado.py 2021-05-06 18:58:30.000000000 +0200 @@ -2,7 +2,7 @@ import pytest -from sentry_sdk import configure_scope +from sentry_sdk import configure_scope, start_transaction from sentry_sdk.integrations.tornado import TornadoIntegration from tornado.web import RequestHandler, Application, HTTPError @@ -40,6 +40,25 @@ scope.set_tag("foo", "42") 1 / 0 + def post(self): + with configure_scope() as scope: + scope.set_tag("foo", "43") + 1 / 0 + + +class HelloHandler(RequestHandler): + async def get(self): + with configure_scope() as scope: + scope.set_tag("foo", "42") + + return b"hello" + + async def post(self): + with configure_scope() as scope: + scope.set_tag("foo", "43") + + return b"hello" + def test_basic(tornado_testcase, sentry_init, capture_events): sentry_init(integrations=[TornadoIntegration()], send_default_pii=True) @@ -82,6 +101,82 @@ assert not scope._tags +@pytest.mark.parametrize( + "handler,code", + [ + (CrashingHandler, 500), + (HelloHandler, 200), + ], +) +def test_transactions(tornado_testcase, sentry_init, capture_events, handler, code): + sentry_init(integrations=[TornadoIntegration()], traces_sample_rate=1.0, debug=True) + events = capture_events() + client = tornado_testcase(Application([(r"/hi", handler)])) + + with start_transaction(name="client") as span: + pass + + response = client.fetch( + "/hi", method="POST", body=b"heyoo", headers=dict(span.iter_headers()) + ) + assert response.code == code + + if code == 200: + client_tx, server_tx = events + server_error = None + else: + client_tx, server_error, server_tx = events + + assert client_tx["type"] == "transaction" + assert client_tx["transaction"] == "client" + + if server_error is not None: + assert server_error["exception"]["values"][0]["type"] == "ZeroDivisionError" + assert ( + server_error["transaction"] + == "tests.integrations.tornado.test_tornado.CrashingHandler.post" + ) + + if code == 200: + assert ( + server_tx["transaction"] + == "tests.integrations.tornado.test_tornado.HelloHandler.post" + ) + else: + assert ( + server_tx["transaction"] + == "tests.integrations.tornado.test_tornado.CrashingHandler.post" + ) + + assert server_tx["type"] == "transaction" + + request = server_tx["request"] + host = request["headers"]["Host"] + assert server_tx["request"] == { + "env": {"REMOTE_ADDR": "127.0.0.1"}, + "headers": { + "Accept-Encoding": "gzip", + "Connection": "close", + **request["headers"], + }, + "method": "POST", + "query_string": "", + "data": {"heyoo": [""]}, + "url": "http://{host}/hi".format(host=host), + } + + assert ( + client_tx["contexts"]["trace"]["trace_id"] + == server_tx["contexts"]["trace"]["trace_id"] + ) + + if server_error is not None: + assert ( + server_error["contexts"]["trace"]["trace_id"] + == server_tx["contexts"]["trace"]["trace_id"] + ) + + def test_400_not_logged(tornado_testcase, sentry_init, capture_events): sentry_init(integrations=[TornadoIntegration()]) events = capture_events() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sentry-python-1.0.0/tox.ini new/sentry-python-1.1.0/tox.ini --- old/sentry-python-1.0.0/tox.ini 2021-03-03 16:55:06.000000000 +0100 +++ new/sentry-python-1.1.0/tox.ini 2021-05-06 18:58:30.000000000 +0200 @@ -76,7 +76,6 @@ {py2.7,py3.7,py3.8,py3.9}-sqlalchemy-{1.2,1.3} - py3.7-spark {py3.5,py3.6,py3.7,py3.8,py3.9}-pure_eval @@ -215,8 +214,6 @@ sqlalchemy-1.2: sqlalchemy>=1.2,<1.3 sqlalchemy-1.3: sqlalchemy>=1.3,<1.4 - spark: pyspark==2.4.4 - linters: -r linter-requirements.txt py3.8: hypothesis @@ -260,7 +257,6 @@ rediscluster: TESTPATH=tests/integrations/rediscluster asgi: TESTPATH=tests/integrations/asgi sqlalchemy: TESTPATH=tests/integrations/sqlalchemy - spark: TESTPATH=tests/integrations/spark pure_eval: TESTPATH=tests/integrations/pure_eval chalice: TESTPATH=tests/integrations/chalice boto3: TESTPATH=tests/integrations/boto3