Skip to content

Commit

Permalink
add sentry function
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Sep 2, 2024
1 parent 73e2bd8 commit c2ea1b2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pvnet_app/sentry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
""" Sentry tracer function """
import os


def traces_sampler(sampling_context):
"""
Filter tracing for sentry logs.
Examine provided context data (including parent decision, if any)
along with anything in the global namespace to compute the sample rate
or sampling decision for this transaction
"""

if os.getenv("ENVIRONMENT", "local") == "local":
return 0.0
elif "error" in sampling_context["transaction_context"]["name"]:
# These are important - take a big sample
return 1.0
elif sampling_context["parent_sampled"] is True:
# These aren't something worth tracking - drop all transactions like this
return 0.0
else:
# Default sample rate, report all errors
return 1.0

0 comments on commit c2ea1b2

Please sign in to comment.