mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 10:46:06 -04:00
Drop support for ancient prometheus_client (#8426)
Drop compatibility hacks for prometheus-client pre 0.4.0. Debian stretch and Fedora 31 both have newer versions, so hopefully this will be ok.
This commit is contained in:
parent
c429dfc300
commit
ceafb5a1c6
3 changed files with 8 additions and 23 deletions
|
@ -24,7 +24,6 @@ expect, and the newer "best practice" version of the up-to-date official client.
|
|||
|
||||
import math
|
||||
import threading
|
||||
from collections import namedtuple
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from socketserver import ThreadingMixIn
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
@ -35,14 +34,6 @@ from twisted.web.resource import Resource
|
|||
|
||||
from synapse.util import caches
|
||||
|
||||
try:
|
||||
from prometheus_client.samples import Sample
|
||||
except ImportError:
|
||||
Sample = namedtuple( # type: ignore[no-redef] # noqa
|
||||
"Sample", ["name", "labels", "value", "timestamp", "exemplar"]
|
||||
)
|
||||
|
||||
|
||||
CONTENT_TYPE_LATEST = str("text/plain; version=0.0.4; charset=utf-8")
|
||||
|
||||
|
||||
|
@ -93,17 +84,6 @@ def sample_line(line, name):
|
|||
)
|
||||
|
||||
|
||||
def nameify_sample(sample):
|
||||
"""
|
||||
If we get a prometheus_client<0.4.0 sample as a tuple, transform it into a
|
||||
namedtuple which has the names we expect.
|
||||
"""
|
||||
if not isinstance(sample, Sample):
|
||||
sample = Sample(*sample, None, None)
|
||||
|
||||
return sample
|
||||
|
||||
|
||||
def generate_latest(registry, emit_help=False):
|
||||
|
||||
# Trigger the cache metrics to be rescraped, which updates the common
|
||||
|
@ -144,7 +124,7 @@ def generate_latest(registry, emit_help=False):
|
|||
)
|
||||
)
|
||||
output.append("# TYPE {0} {1}\n".format(mname, mtype))
|
||||
for sample in map(nameify_sample, metric.samples):
|
||||
for sample in metric.samples:
|
||||
# Get rid of the OpenMetrics specific samples
|
||||
for suffix in ["_created", "_gsum", "_gcount"]:
|
||||
if sample.name.endswith(suffix):
|
||||
|
@ -172,7 +152,7 @@ def generate_latest(registry, emit_help=False):
|
|||
)
|
||||
)
|
||||
output.append("# TYPE {0} {1}\n".format(mnewname, mtype))
|
||||
for sample in map(nameify_sample, metric.samples):
|
||||
for sample in metric.samples:
|
||||
# Get rid of the OpenMetrics specific samples
|
||||
for suffix in ["_created", "_gsum", "_gcount"]:
|
||||
if sample.name.endswith(suffix):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue