Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1fa2e587
Unverified
Commit
1fa2e587
authored
2 years ago
by
David Robertson
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Catch BrokenPipeError from metrics server, and log as a warning (#14072)
parent
d6ae14e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/14072.misc
+1
-0
1 addition, 0 deletions
changelog.d/14072.misc
synapse/metrics/_legacy_exposition.py
+12
-6
12 additions, 6 deletions
synapse/metrics/_legacy_exposition.py
with
13 additions
and
6 deletions
changelog.d/14072.misc
0 → 100644
+
1
−
0
View file @
1fa2e587
Don't create noisy Sentry events when a requester drops connection to the metrics server mid-request.
This diff is collapsed.
Click to expand it.
synapse/metrics/_legacy_exposition.py
+
12
−
6
View file @
1fa2e587
...
@@ -20,7 +20,7 @@ Due to the renaming of metrics in prometheus_client 0.4.0, this customised
...
@@ -20,7 +20,7 @@ Due to the renaming of metrics in prometheus_client 0.4.0, this customised
vendoring of the code will emit both the old versions that Synapse dashboards
vendoring of the code will emit both the old versions that Synapse dashboards
expect, and the newer
"
best practice
"
version of the up-to-date official client.
expect, and the newer
"
best practice
"
version of the up-to-date official client.
"""
"""
import
logging
import
math
import
math
import
threading
import
threading
from
http.server
import
BaseHTTPRequestHandler
,
HTTPServer
from
http.server
import
BaseHTTPRequestHandler
,
HTTPServer
...
@@ -34,6 +34,7 @@ from prometheus_client.core import Sample
...
@@ -34,6 +34,7 @@ from prometheus_client.core import Sample
from
twisted.web.resource
import
Resource
from
twisted.web.resource
import
Resource
from
twisted.web.server
import
Request
from
twisted.web.server
import
Request
logger
=
logging
.
getLogger
(
__name__
)
CONTENT_TYPE_LATEST
=
"
text/plain; version=0.0.4; charset=utf-8
"
CONTENT_TYPE_LATEST
=
"
text/plain; version=0.0.4; charset=utf-8
"
...
@@ -219,11 +220,16 @@ class MetricsHandler(BaseHTTPRequestHandler):
...
@@ -219,11 +220,16 @@ class MetricsHandler(BaseHTTPRequestHandler):
except
Exception
:
except
Exception
:
self
.
send_error
(
500
,
"
error generating metric output
"
)
self
.
send_error
(
500
,
"
error generating metric output
"
)
raise
raise
self
.
send_response
(
200
)
try
:
self
.
send_header
(
"
Content-Type
"
,
CONTENT_TYPE_LATEST
)
self
.
send_response
(
200
)
self
.
send_header
(
"
Content-Length
"
,
str
(
len
(
output
)))
self
.
send_header
(
"
Content-Type
"
,
CONTENT_TYPE_LATEST
)
self
.
end_headers
()
self
.
send_header
(
"
Content-Length
"
,
str
(
len
(
output
)))
self
.
wfile
.
write
(
output
)
self
.
end_headers
()
self
.
wfile
.
write
(
output
)
except
BrokenPipeError
as
e
:
logger
.
warning
(
"
BrokenPipeError when serving metrics (%s). Did Prometheus restart?
"
,
e
)
def
log_message
(
self
,
format
:
str
,
*
args
:
Any
)
->
None
:
def
log_message
(
self
,
format
:
str
,
*
args
:
Any
)
->
None
:
"""
Log nothing.
"""
"""
Log nothing.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment