summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-02-25 14:26:42 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-02-25 14:26:42 +0000
commit057be548786933454619a8507122d0afd8f3e0e3 (patch)
treea9fa77d935f7659cf9e3874cec65671e1b40b5b8
parentBlow up config if opentracing is missing (#5985) (diff)
parentadd report_stats_endpoint config option (#6012) (diff)
downloadsynapse-057be548786933454619a8507122d0afd8f3e0e3.tar.xz
add report_stats_endpoint config option (#6012)
-rw-r--r--changelog.d/6012.feature1
-rw-r--r--docs/sample_config.yaml5
-rw-r--r--synapse/app/homeserver.py6
-rw-r--r--synapse/config/metrics.py9
4 files changed, 19 insertions, 2 deletions
diff --git a/changelog.d/6012.feature b/changelog.d/6012.feature
new file mode 100644

index 0000000000..25425510c6 --- /dev/null +++ b/changelog.d/6012.feature
@@ -0,0 +1 @@ +Add report_stats_endpoint option to configure where stats are reported to, if enabled. Contributed by @Sorunome. diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml
index e49b9d945e..641108de17 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml
@@ -1142,6 +1142,11 @@ metrics_flags: # Whether or not to report anonymized homeserver usage statistics. # report_stats: true|false +# The endpoint to report the anonymized homeserver usage statistics to. +# Defaults to https://matrix.org/report-usage-stats/push +# +#report_stats_endpoint: https://example.com/report-usage-stats/push + ## API Configuration ## diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index baeafd9e04..3f31bf9490 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py
@@ -561,10 +561,12 @@ def run(hs): stats["database_engine"] = hs.get_datastore().database_engine_name stats["database_server_version"] = hs.get_datastore().get_server_version() - logger.info("Reporting stats to matrix.org: %s" % (stats,)) + logger.info( + "Reporting stats to %s: %s" % (hs.config.report_stats_endpoint, stats) + ) try: yield hs.get_proxied_http_client().put_json( - "https://matrix.org/report-usage-stats/push", stats + hs.config.report_stats_endpoint, stats ) except Exception as e: logger.warn("Error reporting stats: %s", e) diff --git a/synapse/config/metrics.py b/synapse/config/metrics.py
index 9eb1e55ddb..ec35a6b868 100644 --- a/synapse/config/metrics.py +++ b/synapse/config/metrics.py
@@ -37,6 +37,9 @@ class MetricsConfig(Config): def read_config(self, config, **kwargs): self.enable_metrics = config.get("enable_metrics", False) self.report_stats = config.get("report_stats", None) + self.report_stats_endpoint = config.get( + "report_stats_endpoint", "https://matrix.org/report-usage-stats/push" + ) self.metrics_port = config.get("metrics_port") self.metrics_bind_host = config.get("metrics_bind_host", "127.0.0.1") @@ -95,4 +98,10 @@ class MetricsConfig(Config): else: res += "report_stats: %s\n" % ("true" if report_stats else "false") + res += """ + # The endpoint to report the anonymized homeserver usage statistics to. + # Defaults to https://matrix.org/report-usage-stats/push + # + #report_stats_endpoint: https://example.com/report-usage-stats/push + """ return res