Merge pull request #163 from sartography/feature/fewer-sentry-traces

fewer sentry traces
This commit is contained in:
Kevin Burnett 2022-10-27 14:44:39 +00:00 committed by GitHub
commit 496c131201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -157,18 +157,29 @@ def configure_sentry(app: flask.app.Flask) -> None:
return None
return event
sentry_sample_rate = app.config.get("SENTRY_SAMPLE_RATE")
if sentry_sample_rate is None:
return
sentry_errors_sample_rate = app.config.get("SENTRY_ERRORS_SAMPLE_RATE")
if sentry_errors_sample_rate is None:
raise Exception("SENTRY_ERRORS_SAMPLE_RATE is not set somehow")
sentry_traces_sample_rate = app.config.get("SENTRY_TRACES_SAMPLE_RATE")
if sentry_traces_sample_rate is None:
raise Exception("SENTRY_TRACES_SAMPLE_RATE is not set somehow")
sentry_sdk.init(
dsn=app.config.get("SENTRY_DSN"),
integrations=[
FlaskIntegration(),
],
environment=app.config["ENV_IDENTIFIER"],
# Set traces_sample_rate to 1.0 to capture 100%
# sample_rate is the errors sample rate. we usually set it to 1 (100%)
# so we get all errors in sentry.
sample_rate=float(sentry_errors_sample_rate),
# Set traces_sample_rate to capture a certain percentage
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=float(sentry_sample_rate),
# We recommend adjusting this value to less than 1(00%) in production.
traces_sample_rate=float(sentry_traces_sample_rate),
before_send=before_send,
)

View File

@ -47,7 +47,8 @@ SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
# Sentry Configuration
SENTRY_DSN = environ.get("SENTRY_DSN", default="")
SENTRY_SAMPLE_RATE = environ.get("SENTRY_SAMPLE_RATE", default="1.0")
SENTRY_ERRORS_SAMPLE_RATE = environ.get("SENTRY_ERRORS_SAMPLE_RATE", default="1") # send all errors
SENTRY_TRACES_SAMPLE_RATE = environ.get("SENTRY_TRACES_SAMPLE_RATE", default="0.01") # send 1% of traces
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
"SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="info"