mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-08 06:32:01 +00:00
Add a DistributionMetric to HTTP request/response processing time in the server
This commit is contained in:
parent
be170b1426
commit
3f7a31d366
@ -46,6 +46,11 @@ outgoing_responses_counter = metrics.register_counter(
|
|||||||
labels=["method", "code"],
|
labels=["method", "code"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
response_timer = metrics.register_distribution(
|
||||||
|
"response_time",
|
||||||
|
labels=["method", "servlet"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HttpServer(object):
|
class HttpServer(object):
|
||||||
""" Interface for registering callbacks on a HTTP server
|
""" Interface for registering callbacks on a HTTP server
|
||||||
@ -169,6 +174,10 @@ class JsonResource(HttpServer, resource.Resource):
|
|||||||
code, response = yield callback(request, *args)
|
code, response = yield callback(request, *args)
|
||||||
|
|
||||||
self._send_response(request, code, response)
|
self._send_response(request, code, response)
|
||||||
|
response_timer.inc_by(
|
||||||
|
self.clock.time_msec() - start, request.method, servlet_classname
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Huh. No one wanted to handle that? Fiiiiiine. Send 400.
|
# Huh. No one wanted to handle that? Fiiiiiine. Send 400.
|
||||||
|
Loading…
Reference in New Issue
Block a user