Package: h-pyramid-sentry
Hypothesis Pyramid Sentry ExtensionA library which integrates Sentry logging into Pyramid with the ability to filter out unwanted messages.This is a Pyramid extension that wrapssentry-sdk's Pyramid integrationand adds some additional customization and features.FeaturesInitializes sentry-sdk with its Pyramid integration for you.
Your app just has to set any"h_pyramid_sentry.*"settings that you want
and then doconfig.include("h_pyramid_sentry")(see instructions below for details).Prevents retryable exceptions from being reported to Sentry if your app is usingpyramid_retryand the request is going to be retried
(requires the"h_pyramid_sentry.retry_support": Truesetting, see below).Retryable exceptions will still be reported to Sentry if the request is not
going to be retried again because it has run out of retry attempts or because
one of the retries fails with a non-retryable exception. When this happens
only the exception from the request's final attempt is reported to Sentry, so
you get a single Sentry event per request not multiple, but information about
the previous failed attempts' exceptions is added to the single Sentry event.Ignores errors logged byexc_loggerif your app is usingpyramid_exclog.pyramid_exclog logs all exceptions with log-level ERROR, and these all
get picked up by sentry_sdk'senabled-by-default logging integration.
This would mean that all exceptions in Sentry appear to come from
exc_logger, and that some handled exceptions that wouldn't normally be
reported to Sentry nowwouldget reported. This extension prevents the
interference by telling sentry_sdk to ignore exc_logger.Provides a convenient method for apps to register their own filters for
exceptions and logged errors that they don't want to be reported to Sentry.
See the"h_pyramid_sentry.filters"setting below.Usageconfig.add_settings({...})# See below for available settings.config.include("h_pyramid_sentry")FiltersIn your Pyramid configuration you can provide a list of filter functions in the
settingh_pyramid_sentry.filters.These functions are passedEventobjects which
they can inspect. If the function returnsTrue, then the event is not sent to
Sentry.For example to prevent reporting ofValueErrors:config.add_settings({"h_pyramid_sentry.filters":[lambdaevent:instanceof(event.exception,ValueError)],})SettingsThe extension will listen to the following Pyramid deployment settings:Pyramid settingEffecth_pyramid_sentry.initA dict of anyoptions understood bysentry_sdk.init()h_pyramid_sentry.filtersA list of functions to apply as filtersh_pyramid_sentry.retry_support*Enable retry detection and filteringh_pyramid_sentry.celery_support*EnableCelery support for Sentryh_pyramid_sentry.sqlalchemy_support*EnableSQLAlchemy support for Sentry* Enabling retry or celery support requires your application to list the relevant dependency (pyramid_retryorcelery) as a dependency.As per theSentry docs, the
environment variableSENTRY_DSNwill be automatically read if set, although this can
also be passed along with any other Sentry SDK options viah_pyramid_sentry.init.Setting up Your Hypothesis Pyramid Sentry Extension Development EnvironmentFirst you'll need to install:Git.
On Ubuntu:sudo apt install git, on macOS:brew install git.GNU Make.
This is probably already installed, runmake --versionto check.pyenv.
Follow the instructions in pyenv's README to install it.
TheHomebrewmethod works best on macOS.
TheBasic GitHub Checkoutmethod works best on Ubuntu.
Youdon'tneed to set up pyenv's shell integration ("shims"), you canuse pyenv without shims.Then to set up your development environment:git clone https://github.com/hypothesis/h-pyramid-sentry.git
cd h_pyramid_sentry
make helpReleasing a New Version of the ProjectFirst, to get PyPI publishing working you need to go to:https://github.com/organizations/hypothesis/settings/secrets/actions/PYPI_TOKENand add h-pyramid-sentry to thePYPI_TOKENsecret's selected
repositories.Now that the h-pyramid-sentry project has access to thePYPI_TOKENsecret
you can release a new version by justcreating a new GitHub release.
Publishing a new GitHub release will automatically triggera GitHub Actions workflowthat will build the new version of your Python package and upload it tohttps://pypi.org/project/h-pyramid-sentry.Changing the Project's Python VersionsTo change what versions of Python the project uses:Change the Python versions in thecookiecutter.jsonfile. For example:"python_versions":"3.10.4, 3.9.12",Re-run the cookiecutter template:make templateCommit everything to git and send a pull requestChanging the Project's Python DependenciesTo change the production dependencies in thesetup.cfgfile:Change the dependencies in the.cookiecutter/includes/setuptools/install_requiresfile.
If this file doesn't exist yet create it and add some dependencies to it.
For example:pyramid
sqlalchemy
celeryRe-run the cookiecutter template:make templateCommit everything to git and send a pull requestTo change the project's formatting, linting and test dependencies:Change the dependencies in the.cookiecutter/includes/tox/depsfile.
If this file doesn't exist yet create it and add some dependencies to it.
Use tox'sfactor-conditional settingsto limit which environment(s) each dependency is used in.
For example:lint: flake8,
format: autopep8,
lint,tests: pytest-faker,Re-run the cookiecutter template:make templateCommit everything to git and send a pull request