sentry-sdk but quite
Project description
shy-sentry
sentry-sdk but silent
Shh.
Extending getsentry/sentry-python, this package provides the following customizations we found useful in multiple projects:
- default integrations that have a silent
AtexitIntegration.callback
- a
Guard()
context manager / decorator which provides quite sentry feedback on errors for parts of code that cannot let exceptions rock all the way up to killing the process. This is intended for use in our legacy cgi scripts, where console output is undesired. - loading certain
sentry_sdk.init
kwargs (dsn
,environment
,release
) from json by default. - restores
sentry_sdk.serializer.MAX_DATABAG_DEPTH
and expandssentry_sdk.serializer.MAX_DATABAG_BREADTH
for more complete debugging information. This is intended for use in our legacy cgi scripts, where code complexity per function can be higher then desired in non-legacy code.
Table of contents
Badges
master
develop
Install
$ pip install shy-sentry
Usage
Create a JSON configuration file with keys, used to configure sentry sdk:
{
"SENTRY_DSN": "https://client_key@sentry.io/project_id",
"SENTRY_ENVIRONMENT": "dev",
"SENTRY_RELEASE_STRING": "project:branch@version"
}
Then, setup shy-sentry in the desired entry point and guard your entry point using Guard
as a context manager or as a
decorator.
as context manager
import shy_sentry
def main():
print(1/0)
if __name__ == "__main__":
shy_sentry.init(config_path="./sentry_config.json")
with shy_sentry.Guard():
main()
as decorator
import shy_sentry
@shy_sentry.Guard()
def main():
print(1/0)
if __name__ == "__main__":
shy_sentry.init(config_path="./sentry_config.json")
main()
Exceptions outside of Guard()
will get you ZeroDivisionError
issue/event in Sentry AND a traceback in your console,
when using default integrations.
import shy_sentry
def main():
print(1/0)
if __name__ == "__main__":
shy_sentry.init(config_path="./sentry_config.json")
main()
If Guard()
can't get a sentry_sdk.client.Client
instance, it will reraise exceptions instead of ignoring them.
If there are certain exceptions you want reraised from Guard()
, you'll need a sub-class like this:
from shy_sentry import Guard
class MyGuard(Guard):
def __exit__(self, exc_type, exc_val, exc_tb):
if not super().__exit__(exc_type, exc_val, exc_tb):
# super intends to ignore, do we want to ignore?
if isinstance(exc_type, OSError):
return True
return False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shy-sentry-1.2.0.tar.gz
.
File metadata
- Download URL: shy-sentry-1.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b433aecc555ce58850eb308203969692860837809a719058dc4d0693056da87 |
|
MD5 | d3fa8121109714a0f3ecf04fe75190ae |
|
BLAKE2b-256 | 7e4ef39367325498c2fff3b284b72280530b20291f5a57a04ec26b53444abe1b |
File details
Details for the file shy_sentry-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: shy_sentry-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a599e552ba3d0677842800701a0c47b2eaefbf39f0d1370e639750b54afe568f |
|
MD5 | 29c550661b10507173f749489c4d0067 |
|
BLAKE2b-256 | 3d345527231776a15b388502d604c452c907f9226ae25e65908bfc22d6d9f1cd |