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

add report_stats_endpoint config option #6012

Merged
merged 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6012.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add report_stats_endpoint option to configure where stats are reported to, if enabled
Sorunome marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ metrics_flags:
# Whether or not to report anonymized homeserver usage statistics.
# report_stats: true|false

# The endpoint where to report the anonymized homeserver usage statistics to. Defaults to matrix.org
Sorunome marked this conversation as resolved.
Show resolved Hide resolved
Sorunome marked this conversation as resolved.
Show resolved Hide resolved
# report_stats_endpoint: "https://matrix.org/report-usage-stats/push"
Sorunome marked this conversation as resolved.
Show resolved Hide resolved

## API Configuration ##

Expand Down
13 changes: 9 additions & 4 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,16 @@ def phone_stats_home():

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: %s" % (stats,))
Sorunome marked this conversation as resolved.
Show resolved Hide resolved
try:
yield hs.get_simple_http_client().put_json(
"https://matrix.org/report-usage-stats/push", stats
)
if hs.config.report_stats_endpoint:
yield hs.get_simple_http_client().put_json(
hs.config.report_stats_endpoint, stats
)
else:
yield hs.get_simple_http_client().put_json(
"https://matrix.org/report-usage-stats/push", stats
)
except Exception as e:
logger.warn("Error reporting stats: %s", e)

Expand Down
1 change: 1 addition & 0 deletions synapse/config/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ 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", None)
Sorunome marked this conversation as resolved.
Show resolved Hide resolved
self.metrics_port = config.get("metrics_port")
self.metrics_bind_host = config.get("metrics_bind_host", "127.0.0.1")

Expand Down