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

Commit dd2e5b0

Browse files
Sorunomerichvdh
authored andcommitted
add report_stats_endpoint config option (#6012)
This PR adds the optional `report_stats_endpoint` to configure where stats are reported to, if enabled.
1 parent a8251da commit dd2e5b0

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
@@ -985,6 +985,11 @@ metrics_flags:
985985
# Whether or not to report anonymized homeserver usage statistics.
986986
# report_stats: true|false
987987

988+
# The endpoint to report the anonymized homeserver usage statistics to.
989+
# Defaults to https://matrix.org/report-usage-stats/push
990+
#
991+
#report_stats_endpoint: https://example.com/report-usage-stats/push
992+
988993

989994
## API Configuration ##
990995

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_simple_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)