Skip to content

Commit

Permalink
Add setting for sentry profiling configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna committed Oct 25, 2023
1 parent e89083f commit bd280c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions composed_configuration/_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class SentryMixin(ConfigMixin):
The `DJANGO_SENTRY_DSN` environment variable should be externally set to a Sentry DSN.
The `DJANGO_SENTRY_ENVIRONMENT`, `DJANGO_SENTRY_RELEASE`, and `DJANGO_SENTRY_TRACES_SAMPLE_RATE`
environment variables may also be set, if desired.
The `DJANGO_SENTRY_ENVIRONMENT`, `DJANGO_SENTRY_RELEASE`, `DJANGO_SENTRY_TRACES_SAMPLE_RATE`,
and `DJANGO_SENTRY_PROFILES_SAMPLE_RATE` environment variables may also be set, if desired.
"""

@staticmethod
Expand All @@ -29,6 +29,7 @@ def mutate_configuration(configuration: Type[ComposedConfiguration]) -> None:

SENTRY_RELEASE = values.Value(None)

# None is a valid default value, but if this is set via environment variable,
# the value must be interpretable as a float
# None is a valid default value for these rates, but if set via environment variable,
# the values must be interpretable as floats
SENTRY_TRACES_SAMPLE_RATE = values.FloatValue(None)
SENTRY_PROFILES_SAMPLE_RATE = values.FloatValue(None)
3 changes: 2 additions & 1 deletion composed_configuration/sentry/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def ready(self):
attach_stacktrace=True,
# Submit request User info from Django
send_default_pii=True,
# This is None by default, so performance monitoring is opt-in
# These are None by default, so performance monitoring/profiling is opt-in
traces_sample_rate=settings.SENTRY_TRACES_SAMPLE_RATE,
profiles_sample_rate=settings.SENTRY_PROFILES_SAMPLE_RATE,
)

0 comments on commit bd280c9

Please sign in to comment.