mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-21 23:01:00 +00:00
Add debug environment and sentry experiment (#372)
The "debug" environment allows for an additional label in Sentry. I use this to isolate issues/traces only present on my server with DEBUG enabled, for faster development and tracing. The sentry _experiments is a optional list of beta-grade experiments that Sentry is developing. Profile traces is one of those experiments, to adding it disabled by default. Developers can enable it with the provided setting.
This commit is contained in:
parent
d8cee4097f
commit
20edb20563
1 changed files with 10 additions and 1 deletions
|
@ -41,7 +41,7 @@ def as_bool(v: str | list[str] | None):
|
|||
return v[0].lower() in ("true", "yes", "t", "1")
|
||||
|
||||
|
||||
Environments = Literal["development", "production", "test"]
|
||||
Environments = Literal["debug", "development", "production", "test"]
|
||||
|
||||
TAKAHE_ENV_FILE = os.environ.get(
|
||||
"TAKAHE_ENV_FILE", "test.env" if "pytest" in sys.modules else ".env"
|
||||
|
@ -95,6 +95,7 @@ class Settings(BaseSettings):
|
|||
SENTRY_SAMPLE_RATE: float = 1.0
|
||||
SENTRY_TRACES_SAMPLE_RATE: float = 0.01
|
||||
SENTRY_CAPTURE_MESSAGES: bool = False
|
||||
SENTRY_EXPERIMENTAL_PROFILES_TRACES_SAMPLE_RATE: float = 0.0
|
||||
|
||||
#: Fallback domain for links.
|
||||
MAIN_DOMAIN: str = "example.com"
|
||||
|
@ -337,6 +338,13 @@ if SETUP.USE_PROXY_HEADERS:
|
|||
if SETUP.SENTRY_DSN:
|
||||
from sentry_sdk.integrations.httpx import HttpxIntegration
|
||||
|
||||
sentry_experiments = {}
|
||||
|
||||
if SETUP.SENTRY_EXPERIMENTAL_PROFILES_TRACES_SAMPLE_RATE > 0:
|
||||
sentry_experiments[
|
||||
"profiles_sample_rate"
|
||||
] = SETUP.SENTRY_EXPERIMENTAL_PROFILES_TRACES_SAMPLE_RATE
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=SETUP.SENTRY_DSN,
|
||||
integrations=[
|
||||
|
@ -347,6 +355,7 @@ if SETUP.SENTRY_DSN:
|
|||
sample_rate=SETUP.SENTRY_SAMPLE_RATE,
|
||||
send_default_pii=True,
|
||||
environment=SETUP.ENVIRONMENT,
|
||||
_experiments=sentry_experiments,
|
||||
)
|
||||
sentry_sdk.set_tag("takahe.version", __version__)
|
||||
|
||||
|
|
Loading…
Reference in a new issue