summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/16738.feature1
-rw-r--r--docs/usage/configuration/config_documentation.md7
-rw-r--r--synapse/app/_base.py1
-rw-r--r--synapse/config/metrics.py1
4 files changed, 9 insertions, 1 deletions
diff --git a/changelog.d/16738.feature b/changelog.d/16738.feature
new file mode 100644
index 0000000000..c9ea12a2ab
--- /dev/null
+++ b/changelog.d/16738.feature
@@ -0,0 +1 @@
+Add new Sentry configuration option `environment` for improved system monitoring. Contributed by @zeeshanrafiqrana.
\ No newline at end of file
diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md
index 90ea8d093f..4efbd91dde 100644
--- a/docs/usage/configuration/config_documentation.md
+++ b/docs/usage/configuration/config_documentation.md
@@ -2777,7 +2777,11 @@ enable_metrics: true
 ### `sentry`
 
 Use this option to enable sentry integration. Provide the DSN assigned to you by sentry
-with the `dsn` setting.
+with the `dsn` setting. 
+
+ An optional `environment` field can be used to specify an environment. This allows
+ for log maintenance based on different environments, ensuring better organization
+ and analysis..
 
 NOTE: While attempts are made to ensure that the logs don't contain
 any sensitive information, this cannot be guaranteed. By enabling
@@ -2788,6 +2792,7 @@ through insecure notification channels if so configured.
 Example configuration:
 ```yaml
 sentry:
+    environment: "production"
     dsn: "..."
 ```
 ---
diff --git a/synapse/app/_base.py b/synapse/app/_base.py
index 9ac7e4313e..aed98f03af 100644
--- a/synapse/app/_base.py
+++ b/synapse/app/_base.py
@@ -665,6 +665,7 @@ def setup_sentry(hs: "HomeServer") -> None:
     sentry_sdk.init(
         dsn=hs.config.metrics.sentry_dsn,
         release=SYNAPSE_VERSION,
+        environment=hs.config.metrics.sentry_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"