Skip to content

Commit

Permalink
feat(reporting): Added a module for configuring reporting via Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
b32147 committed Jul 15, 2024
1 parent f0ba916 commit b16338e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
27 changes: 27 additions & 0 deletions dbmi_client/reporting.py
Original file line number Diff line number Diff line change
@@ -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,
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ requests
furl
pyjwt<3.0,>2.0
django-bootstrap3
raven>=6.9.0
sentry-sdk[django]<3.0
pytz
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down

0 comments on commit b16338e

Please sign in to comment.