Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 057be54

Browse files
committed
add report_stats_endpoint config option (#6012)
2 parents 7fcffa3 + dd2e5b0 commit 057be54

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

changelog.d/6012.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add report_stats_endpoint option to configure where stats are reported to, if enabled. Contributed by @Sorunome.

docs/sample_config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,11 @@ metrics_flags:
11421142
# Whether or not to report anonymized homeserver usage statistics.
11431143
# report_stats: true|false
11441144

1145+
# The endpoint to report the anonymized homeserver usage statistics to.
1146+
# Defaults to https://matrix.org/report-usage-stats/push
1147+
#
1148+
#report_stats_endpoint: https://example.com/report-usage-stats/push
1149+
11451150

11461151
## API Configuration ##
11471152

synapse/app/homeserver.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,12 @@ def phone_stats_home():
561561

562562
stats["database_engine"] = hs.get_datastore().database_engine_name
563563
stats["database_server_version"] = hs.get_datastore().get_server_version()
564-
logger.info("Reporting stats to matrix.org: %s" % (stats,))
564+
logger.info(
565+
"Reporting stats to %s: %s" % (hs.config.report_stats_endpoint, stats)
566+
)
565567
try:
566568
yield hs.get_proxied_http_client().put_json(
567-
"https://matrix.org/report-usage-stats/push", stats
569+
hs.config.report_stats_endpoint, stats
568570
)
569571
except Exception as e:
570572
logger.warn("Error reporting stats: %s", e)

synapse/config/metrics.py

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class MetricsConfig(Config):
3737
def read_config(self, config, **kwargs):
3838
self.enable_metrics = config.get("enable_metrics", False)
3939
self.report_stats = config.get("report_stats", None)
40+
self.report_stats_endpoint = config.get(
41+
"report_stats_endpoint", "https://matrix.org/report-usage-stats/push"
42+
)
4043
self.metrics_port = config.get("metrics_port")
4144
self.metrics_bind_host = config.get("metrics_bind_host", "127.0.0.1")
4245

@@ -95,4 +98,10 @@ def generate_config_section(self, report_stats=None, **kwargs):
9598
else:
9699
res += "report_stats: %s\n" % ("true" if report_stats else "false")
97100

101+
res += """
102+
# The endpoint to report the anonymized homeserver usage statistics to.
103+
# Defaults to https://matrix.org/report-usage-stats/push
104+
#
105+
#report_stats_endpoint: https://example.com/report-usage-stats/push
106+
"""
98107
return res

0 commit comments

Comments
 (0)