added config to turn on sentry profiling w/ burnettk
This commit is contained in:
parent
586ac6b091
commit
27f3da2458
|
@ -1,6 +1,7 @@
|
||||||
"""__init__."""
|
"""__init__."""
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import connexion # type: ignore
|
import connexion # type: ignore
|
||||||
|
@ -207,25 +208,31 @@ def configure_sentry(app: flask.app.Flask) -> None:
|
||||||
"SPIFFWORKFLOW_BACKEND_SENTRY_TRACES_SAMPLE_RATE is not set somehow"
|
"SPIFFWORKFLOW_BACKEND_SENTRY_TRACES_SAMPLE_RATE is not set somehow"
|
||||||
)
|
)
|
||||||
|
|
||||||
# profiling doesn't work on windows, because of an issue like https://github.com/nvdv/vprof/issues/62
|
sentry_configs = {
|
||||||
# but also we commented out profiling because it was causing segfaults (i guess it is marked experimental)
|
"dsn": app.config.get("SPIFFWORKFLOW_BACKEND_SENTRY_DSN"),
|
||||||
# profiles_sample_rate = 0 if sys.platform.startswith("win") else 1
|
"integrations": [
|
||||||
|
|
||||||
sentry_sdk.init(
|
|
||||||
dsn=app.config.get("SPIFFWORKFLOW_BACKEND_SENTRY_DSN"),
|
|
||||||
integrations=[
|
|
||||||
FlaskIntegration(),
|
FlaskIntegration(),
|
||||||
],
|
],
|
||||||
environment=app.config["ENV_IDENTIFIER"],
|
"environment": app.config["ENV_IDENTIFIER"],
|
||||||
# sample_rate is the errors sample rate. we usually set it to 1 (100%)
|
# sample_rate is the errors sample rate. we usually set it to 1 (100%)
|
||||||
# so we get all errors in sentry.
|
# so we get all errors in sentry.
|
||||||
sample_rate=float(sentry_errors_sample_rate),
|
"sample_rate": float(sentry_errors_sample_rate),
|
||||||
# Set traces_sample_rate to capture a certain percentage
|
# Set traces_sample_rate to capture a certain percentage
|
||||||
# of transactions for performance monitoring.
|
# of transactions for performance monitoring.
|
||||||
# We recommend adjusting this value to less than 1(00%) in production.
|
# We recommend adjusting this value to less than 1(00%) in production.
|
||||||
traces_sample_rate=float(sentry_traces_sample_rate),
|
"traces_sample_rate": float(sentry_traces_sample_rate),
|
||||||
traces_sampler=traces_sampler,
|
"traces_sampler": traces_sampler,
|
||||||
# The profiles_sample_rate setting is relative to the traces_sample_rate setting.
|
# The profiles_sample_rate setting is relative to the traces_sample_rate setting.
|
||||||
# _experiments={"profiles_sample_rate": profiles_sample_rate},
|
"before_send": before_send,
|
||||||
before_send=before_send,
|
}
|
||||||
)
|
|
||||||
|
if app.config.get("SPIFFWORKFLOW_BACKEND_SENTRY_PROFILING_ENABLED"):
|
||||||
|
# profiling doesn't work on windows, because of an issue like https://github.com/nvdv/vprof/issues/62
|
||||||
|
# but also we commented out profiling because it was causing segfaults (i guess it is marked experimental)
|
||||||
|
profiles_sample_rate = 0 if sys.platform.startswith("win") else 1
|
||||||
|
if profiles_sample_rate > 0:
|
||||||
|
sentry_configs["_experiments"] = {
|
||||||
|
"profiles_sample_rate": profiles_sample_rate
|
||||||
|
}
|
||||||
|
|
||||||
|
sentry_sdk.init(**sentry_configs)
|
||||||
|
|
|
@ -79,6 +79,10 @@ SPIFFWORKFLOW_BACKEND_SENTRY_ORGANIZATION_SLUG = environ.get(
|
||||||
SPIFFWORKFLOW_BACKEND_SENTRY_PROJECT_SLUG = environ.get(
|
SPIFFWORKFLOW_BACKEND_SENTRY_PROJECT_SLUG = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_SENTRY_PROJECT_SLUG", default=None
|
"SPIFFWORKFLOW_BACKEND_SENTRY_PROJECT_SLUG", default=None
|
||||||
)
|
)
|
||||||
|
SPIFFWORKFLOW_BACKEND_SENTRY_PROFILING_ENABLED = (
|
||||||
|
environ.get("SPIFFWORKFLOW_BACKEND_SENTRY_PROFILING_ENABLED", default="false")
|
||||||
|
== "true"
|
||||||
|
)
|
||||||
|
|
||||||
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="info"
|
"SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="info"
|
||||||
|
|
Loading…
Reference in New Issue