Skip to content

Commit

Permalink
metrics: add option metrics.addr for ipv6 support
Browse files Browse the repository at this point in the history
`prometheus_client` supports IPv6 addresses for a while now[1]. This
isn't used here however because the default 0.0.0.0 is used. Added an
option `metrics.addr` that makes this configurable.

[1] prometheus/client_python@39d2360
  • Loading branch information
Ma27 committed Feb 8, 2024
1 parent 3e22e61 commit c964dbc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mautrix/util/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def start_prometheus(self) -> None:
try:
enabled = self.config["metrics.enabled"]
listen_port = self.config["metrics.listen_port"]
addr = self.config.get("metrics.addr", '0.0.0.0')
except KeyError:
return
if not enabled:
Expand All @@ -197,7 +198,7 @@ def start_prometheus(self) -> None:
"Metrics are enabled in config, but prometheus_client is not installed"
)
return
prometheus.start_http_server(listen_port)
prometheus.start_http_server(listen_port, addr=addr)

def _run(self) -> None:
signal.signal(signal.SIGINT, signal.default_int_handler)
Expand Down

0 comments on commit c964dbc

Please sign in to comment.