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

Commit 9af2be1

Browse files
authored
Remove legacy Prometheus metrics names. They were deprecated in Synapse v1.69.0 and disabled by default in Synapse v1.71.0. (#14538)
1 parent 3b4e150 commit 9af2be1

File tree

11 files changed

+70
-338
lines changed

11 files changed

+70
-338
lines changed

Diff for: changelog.d/14538.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove legacy Prometheus metrics names. They were deprecated in Synapse v1.69.0 and disabled by default in Synapse v1.71.0.

Diff for: docs/upgrade.md

+22
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ process, for example:
8888
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8989
```
9090
91+
# Upgrading to v1.73.0
92+
93+
## Legacy Prometheus metric names have now been removed
94+
95+
Synapse v1.69.0 included the deprecation of legacy Prometheus metric names
96+
and offered an option to disable them.
97+
Synapse v1.71.0 disabled legacy Prometheus metric names by default.
98+
99+
This version, v1.73.0, removes those legacy Prometheus metric names entirely.
100+
This also means that the `enable_legacy_metrics` configuration option has been
101+
removed; it will no longer be possible to re-enable the legacy metric names.
102+
103+
If you use metrics and have not yet updated your Grafana dashboard(s),
104+
Prometheus console(s) or alerting rule(s), please consider doing so when upgrading
105+
to this version.
106+
Note that the included Grafana dashboard was updated in v1.72.0 to correct some
107+
metric names which were missed when legacy metrics were disabled by default.
108+
109+
See [v1.69.0: Deprecation of legacy Prometheus metric names](#deprecation-of-legacy-prometheus-metric-names)
110+
for more context.
111+
112+
91113
# Upgrading to v1.72.0
92114
93115
## Dropping support for PostgreSQL 10

Diff for: docs/usage/configuration/config_documentation.md

-25
Original file line numberDiff line numberDiff line change
@@ -2437,31 +2437,6 @@ Example configuration:
24372437
enable_metrics: true
24382438
```
24392439
---
2440-
### `enable_legacy_metrics`
2441-
2442-
Set to `true` to publish both legacy and non-legacy Prometheus metric names,
2443-
or to `false` to only publish non-legacy Prometheus metric names.
2444-
Defaults to `false`. Has no effect if `enable_metrics` is `false`.
2445-
**In Synapse v1.67.0 up to and including Synapse v1.70.1, this defaulted to `true`.**
2446-
2447-
Legacy metric names include:
2448-
- metrics containing colons in the name, such as `synapse_util_caches_response_cache:hits`, because colons are supposed to be reserved for user-defined recording rules;
2449-
- counters that don't end with the `_total` suffix, such as `synapse_federation_client_sent_edus`, therefore not adhering to the OpenMetrics standard.
2450-
2451-
These legacy metric names are unconventional and not compliant with OpenMetrics standards.
2452-
They are included for backwards compatibility.
2453-
2454-
Example configuration:
2455-
```yaml
2456-
enable_legacy_metrics: false
2457-
```
2458-
2459-
See https://github.com/matrix-org/synapse/issues/11106 for context.
2460-
2461-
*Since v1.67.0.*
2462-
2463-
**Will be removed in v1.73.0.**
2464-
---
24652440
### `sentry`
24662441

24672442
Use this option to enable sentry integration. Provide the DSN assigned to you by sentry

Diff for: synapse/app/_base.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -266,26 +266,18 @@ async def wrapper() -> None:
266266
reactor.callWhenRunning(lambda: defer.ensureDeferred(wrapper()))
267267

268268

269-
def listen_metrics(
270-
bind_addresses: Iterable[str], port: int, enable_legacy_metric_names: bool
271-
) -> None:
269+
def listen_metrics(bind_addresses: Iterable[str], port: int) -> None:
272270
"""
273271
Start Prometheus metrics server.
274272
"""
275273
from prometheus_client import start_http_server as start_http_server_prometheus
276274

277-
from synapse.metrics import (
278-
RegistryProxy,
279-
start_http_server as start_http_server_legacy,
280-
)
275+
from synapse.metrics import RegistryProxy
281276

282277
for host in bind_addresses:
283278
logger.info("Starting metrics listener on %s:%d", host, port)
284-
if enable_legacy_metric_names:
285-
start_http_server_legacy(port, addr=host, registry=RegistryProxy)
286-
else:
287-
_set_prometheus_client_use_created_metrics(False)
288-
start_http_server_prometheus(port, addr=host, registry=RegistryProxy)
279+
_set_prometheus_client_use_created_metrics(False)
280+
start_http_server_prometheus(port, addr=host, registry=RegistryProxy)
289281

290282

291283
def _set_prometheus_client_use_created_metrics(new_value: bool) -> None:

Diff for: synapse/app/generic_worker.py

-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def start_listening(self) -> None:
320320
_base.listen_metrics(
321321
listener.bind_addresses,
322322
listener.port,
323-
enable_legacy_metric_names=self.config.metrics.enable_legacy_metrics,
324323
)
325324
else:
326325
logger.warning("Unsupported listener type: %s", listener.type)

Diff for: synapse/app/homeserver.py

-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ def start_listening(self) -> None:
265265
_base.listen_metrics(
266266
listener.bind_addresses,
267267
listener.port,
268-
enable_legacy_metric_names=self.config.metrics.enable_legacy_metrics,
269268
)
270269
else:
271270
# this shouldn't happen, as the listener type should have been checked

Diff for: synapse/config/metrics.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class MetricsConfig(Config):
4343
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
4444
self.enable_metrics = config.get("enable_metrics", False)
4545

46-
self.enable_legacy_metrics = config.get("enable_legacy_metrics", False)
47-
4846
self.report_stats = config.get("report_stats", None)
4947
self.report_stats_endpoint = config.get(
5048
"report_stats_endpoint", "https://matrix.org/report-usage-stats/push"

Diff for: synapse/metrics/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@
4747
# This module is imported for its side effects; flake8 needn't warn that it's unused.
4848
import synapse.metrics._reactor_metrics # noqa: F401
4949
from synapse.metrics._gc import MIN_TIME_BETWEEN_GCS, install_gc_manager
50-
from synapse.metrics._legacy_exposition import (
51-
MetricsResource,
52-
generate_latest,
53-
start_http_server,
54-
)
50+
from synapse.metrics._twisted_exposition import MetricsResource, generate_latest
5551
from synapse.metrics._types import Collector
5652
from synapse.util import SYNAPSE_VERSION
5753

@@ -474,7 +470,6 @@ def register_threadpool(name: str, threadpool: ThreadPool) -> None:
474470
"Collector",
475471
"MetricsResource",
476472
"generate_latest",
477-
"start_http_server",
478473
"LaterGauge",
479474
"InFlightGauge",
480475
"GaugeBucketCollector",

0 commit comments

Comments
 (0)