diff --git a/synapse/app/_base.py b/synapse/app/_base.py index 9ac7e4313e..f376a7e521 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -662,9 +662,14 @@ def setup_sentry(hs: "HomeServer") -> None: import sentry_sdk + # Set a default environment if it's not configured + default_environment = "" + environment = hs.config.metrics.sentry_environment or default_environment + sentry_sdk.init( dsn=hs.config.metrics.sentry_dsn, release=SYNAPSE_VERSION, + environment=environment ) # We set some default tags that give some context to this instance diff --git a/synapse/config/metrics.py b/synapse/config/metrics.py index 8c1c9bd12d..cb2a61a1c7 100644 --- a/synapse/config/metrics.py +++ b/synapse/config/metrics.py @@ -61,6 +61,7 @@ class MetricsConfig(Config): check_requirements("sentry") self.sentry_dsn = config["sentry"].get("dsn") + self.sentry_environment = config["sentry"].get("environment") if not self.sentry_dsn: raise ConfigError( "sentry.dsn field is required when sentry integration is enabled"