mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 04:19:23 -05:00
Set Content-Length for Metrics requests (#7730)
HTTP requires the response to contain a Content-Length header unless chunked encoding is being used. Prometheus metrics endpoint did not set this, causing software such as prometheus-proxy to not be able to scrape synapse for metrics. Signed-off-by: Christian Svensson <blue@cmd.nu>
This commit is contained in:
parent
24110255cd
commit
8bbe87f42d
1
changelog.d/7730.bugfix
Normal file
1
changelog.d/7730.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix missing `Content-Length` on HTTP responses from the metrics handler.
|
@ -208,6 +208,7 @@ class MetricsHandler(BaseHTTPRequestHandler):
|
|||||||
raise
|
raise
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", CONTENT_TYPE_LATEST)
|
self.send_header("Content-Type", CONTENT_TYPE_LATEST)
|
||||||
|
self.send_header("Content-Length", str(len(output)))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(output)
|
self.wfile.write(output)
|
||||||
|
|
||||||
@ -261,4 +262,6 @@ class MetricsResource(Resource):
|
|||||||
|
|
||||||
def render_GET(self, request):
|
def render_GET(self, request):
|
||||||
request.setHeader(b"Content-Type", CONTENT_TYPE_LATEST.encode("ascii"))
|
request.setHeader(b"Content-Type", CONTENT_TYPE_LATEST.encode("ascii"))
|
||||||
return generate_latest(self.registry)
|
response = generate_latest(self.registry)
|
||||||
|
request.setHeader(b"Content-Length", str(len(response)))
|
||||||
|
return response
|
||||||
|
Loading…
Reference in New Issue
Block a user