mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-18 03:24:19 -05:00
Make RequestMetrics take a raw time rather than a clock
... which is going to make it easier to move around.
This commit is contained in:
parent
8460e48d06
commit
09b29f9c4a
@ -100,12 +100,12 @@ response_size = metrics.register_counter(
|
|||||||
|
|
||||||
|
|
||||||
class RequestMetrics(object):
|
class RequestMetrics(object):
|
||||||
def start(self, clock, name):
|
def start(self, time_msec, name):
|
||||||
self.start = clock.time_msec()
|
self.start = time_msec
|
||||||
self.start_context = LoggingContext.current_context()
|
self.start_context = LoggingContext.current_context()
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def stop(self, clock, request):
|
def stop(self, time_msec, request):
|
||||||
context = LoggingContext.current_context()
|
context = LoggingContext.current_context()
|
||||||
|
|
||||||
tag = ""
|
tag = ""
|
||||||
@ -122,7 +122,7 @@ class RequestMetrics(object):
|
|||||||
response_count.inc(request.method, self.name, tag)
|
response_count.inc(request.method, self.name, tag)
|
||||||
|
|
||||||
response_timer.inc_by(
|
response_timer.inc_by(
|
||||||
clock.time_msec() - self.start, request.method,
|
time_msec - self.start, request.method,
|
||||||
self.name, tag
|
self.name, tag
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ def wrap_request_handler(request_handler, include_metrics=False):
|
|||||||
# JsonResource (or a subclass), and JsonResource._async_render
|
# JsonResource (or a subclass), and JsonResource._async_render
|
||||||
# will update it once it picks a servlet.
|
# will update it once it picks a servlet.
|
||||||
servlet_name = self.__class__.__name__
|
servlet_name = self.__class__.__name__
|
||||||
request_metrics.start(self.clock, name=servlet_name)
|
request_metrics.start(self.clock.time_msec(), name=servlet_name)
|
||||||
|
|
||||||
with request.processing():
|
with request.processing():
|
||||||
try:
|
try:
|
||||||
@ -138,7 +138,7 @@ def wrap_request_handler(request_handler, include_metrics=False):
|
|||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
request_metrics.stop(
|
request_metrics.stop(
|
||||||
self.clock, request
|
self.clock.time_msec(), request
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn("Failed to stop metrics: %r", e)
|
logger.warn("Failed to stop metrics: %r", e)
|
||||||
|
Loading…
Reference in New Issue
Block a user