diff --git a/dbmi_client/reporting.py b/dbmi_client/reporting.py new file mode 100644 index 0000000..5c7ca6f --- /dev/null +++ b/dbmi_client/reporting.py @@ -0,0 +1,27 @@ +import sentry_sdk +from furl import furl + +def config(service, sentry_dsn=None, sentry_trace_rate=0.0, sentry_profile_rate=0.0): + + def filter_transactions(event, hint): + parsed_url = furl(event["request"]["url"]) + + # Do not sample healthcheck requests + if parsed_url.path == "/healthcheck": + return None + + return event + + # Setup sentry + sentry_sdk.init( + dsn=sentry_dsn, + # Filter transactions + before_send_transaction=filter_transactions, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=sentry_trace_rate, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=sentry_profile_rate, + ) diff --git a/requirements.txt b/requirements.txt index 49a1694..357ee3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ requests furl pyjwt<3.0,>2.0 django-bootstrap3 -raven>=6.9.0 +sentry-sdk[django]<3.0 pytz diff --git a/setup.py b/setup.py index 2f0693a..acce7d4 100644 --- a/setup.py +++ b/setup.py @@ -43,18 +43,16 @@ def get_version(package): classifiers=[ "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 2.2", - "Framework :: Django :: 3", - "Framework :: Django :: 4", + "Framework :: Django :: 4.2", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", # example license "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", ],