Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

sentry: Set environment to `staging` on staging hosts.

Alex Vandivera985284b5d41
diff --git a/zproject/config.py b/zproject/config.py
index 42ec637b749..ae7473b150d 100644
--- a/zproject/config.py
+++ b/zproject/config.py
@@ -9,6 +9,7 @@ config_file.read("/etc/zulip/zulip.conf")
# Whether this instance of Zulip is running in a production environment.
PRODUCTION = config_file.has_option("machine", "deploy_type")
+STAGING = config_file.get("machine", "deploy_type", fallback="") == "staging"
DEVELOPMENT = not PRODUCTION
secrets_file = configparser.RawConfigParser()
diff --git a/zproject/sentry.py b/zproject/sentry.py
index c334de23b7a..a260f6bc426 100644
--- a/zproject/sentry.py
+++ b/zproject/sentry.py
@@ -11,7 +11,7 @@ from sentry_sdk.utils import capture_internal_exceptions
from version import ZULIP_VERSION
-from .config import PRODUCTION
+from .config import PRODUCTION, STAGING
if TYPE_CHECKING:
from sentry_sdk._types import Event, Hint
@@ -60,9 +60,16 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
def setup_sentry(dsn: Optional[str], *integrations: Integration) -> None:
if not dsn:
return
+ if PRODUCTION:
+ if STAGING:
+ environment = "staging"
+ else:
+ environment = "production"
+ else:
+ environment = "development"
sentry_sdk.init(
dsn=dsn,
- environment="production" if PRODUCTION else "development",
+ environment=environment,
release=ZULIP_VERSION,
integrations=[
DjangoIntegration(),