generated from openclimatefix/ocf-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73e2bd8
commit c2ea1b2
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |