-
Notifications
You must be signed in to change notification settings - Fork 347
Remove metrics
listener type in favor of http
listener with metrics
resource
#18584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 10 commits
bb31f60
1fe3fa4
6e47458
3e16b88
3b05b5e
54b836c
8ccd52c
bb3904c
adaf5b0
cfdacb8
16e87ed
07c6806
d060446
04084ae
b849bed
6c662e0
03ae604
1ce74d4
467084d
25585b4
95eab21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove `metrics` listener (serves metrics at `/metrics`) type in favor of `http` listener with `metrics` resource (serves metrics at `/_synapse/metrics`). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unclear to me why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that @erikjohnston pointed out is that the dedicated Looking at the git history, the threading aspect just seems like the way it was originally implemented and not something explicitly called out for the benefit described above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even with the updated conclusion from #18592 (comment) which most likely means we will continue to use the global (assuming we can't come up with a benefit/compelling reason for why we want both) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having thought about it a bit: I think it is worth keeping the separate Even if we keep the separate listener, I think we should still make them render from the same source and remove any differences. If needed its easy enough to change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How sure are we that we care about this? Feels like a use case that we're just holding onto especially when we can't find any evidence. From what I'm reading,
I don't see an easy way forward as I don't know how to start another Twisted server in another thread in order to share the I can pull out some of the clean-up from this PR to ship separately. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted this file in favor of re-organizing the remaining pieces in more relevant file names. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,10 @@ | |
# [This file includes modifications made by New Vector Limited] | ||
# | ||
# | ||
from importlib import metadata | ||
from typing import Dict, Protocol, Tuple | ||
from unittest.mock import patch | ||
|
||
from pkg_resources import parse_version | ||
from prometheus_client.core import Sample | ||
|
||
from synapse.app._base import _set_prometheus_client_use_created_metrics | ||
from synapse.metrics import REGISTRY, InFlightGauge, generate_latest | ||
from synapse.util.caches.deferred_cache import DeferredCache | ||
|
||
|
@@ -184,30 +180,3 @@ def test_cache_metric(self) -> None: | |
|
||
self.assertEqual(items["synapse_util_caches_cache_size"], "1.0") | ||
self.assertEqual(items["synapse_util_caches_cache_max_size"], "777.0") | ||
|
||
|
||
class PrometheusMetricsHackTestCase(unittest.HomeserverTestCase): | ||
if parse_version(metadata.version("prometheus_client")) < parse_version("0.14.0"): | ||
skip = "prometheus-client too old" | ||
|
||
def test_created_metrics_disabled(self) -> None: | ||
""" | ||
Tests that a brittle hack, to disable `_created` metrics, works. | ||
This involves poking at the internals of prometheus-client. | ||
It's not the end of the world if this doesn't work. | ||
|
||
This test gives us a way to notice if prometheus-client changes | ||
their internals. | ||
""" | ||
Comment on lines
-189
to
-201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this test as it claims to "gives us a way to notice if prometheus-client changes their internals." but we already have that benefit from the hack function The test provides no further benefit beside asserting that the attribute was set which feels pretty useless. A proper test would ensure that before running the utility, we see the legacy |
||
import prometheus_client.metrics | ||
|
||
PRIVATE_FLAG_NAME = "_use_created" | ||
|
||
# By default, the pesky `_created` metrics are enabled. | ||
# Check this assumption is still valid. | ||
self.assertTrue(getattr(prometheus_client.metrics, PRIVATE_FLAG_NAME)) | ||
|
||
with patch("prometheus_client.metrics") as mock: | ||
setattr(mock, PRIVATE_FLAG_NAME, True) | ||
_set_prometheus_client_use_created_metrics(False) | ||
self.assertFalse(getattr(mock, PRIVATE_FLAG_NAME, False)) |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opinions on calling out the upgrade notes from the changelog entry itself? It looks like usually we prefer to call it out at the top of the changelog section for the version. Doesn't seem like it would hurt to have it in both places. The only problem being the chicken and egg problem of the upgrade notes being written later in order to have the link filled in.