mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Remove include_metrics param
The metrics are now available via the request, so this is redundant and can go away at last.
This commit is contained in:
parent
49e5a613f1
commit
9589a1925e
@ -45,12 +45,12 @@ import simplejson
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def request_handler(include_metrics=False):
|
def request_handler():
|
||||||
"""Decorator for ``wrap_request_handler``"""
|
"""Decorator for ``wrap_request_handler``"""
|
||||||
return lambda request_handler: wrap_request_handler(request_handler, include_metrics)
|
return wrap_request_handler
|
||||||
|
|
||||||
|
|
||||||
def wrap_request_handler(request_handler, include_metrics=False):
|
def wrap_request_handler(request_handler):
|
||||||
"""Wraps a request handler method with the necessary logging and exception
|
"""Wraps a request handler method with the necessary logging and exception
|
||||||
handling.
|
handling.
|
||||||
|
|
||||||
@ -88,12 +88,7 @@ def wrap_request_handler(request_handler, include_metrics=False):
|
|||||||
with request.processing(servlet_name):
|
with request.processing(servlet_name):
|
||||||
try:
|
try:
|
||||||
with PreserveLoggingContext(request_context):
|
with PreserveLoggingContext(request_context):
|
||||||
if include_metrics:
|
d = request_handler(self, request)
|
||||||
d = request_handler(
|
|
||||||
self, request, request.request_metrics,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
d = request_handler(self, request)
|
|
||||||
|
|
||||||
# record the arrival of the request *after*
|
# record the arrival of the request *after*
|
||||||
# dispatching to the handler, so that the handler
|
# dispatching to the handler, so that the handler
|
||||||
@ -206,13 +201,9 @@ class JsonResource(HttpServer, resource.Resource):
|
|||||||
self._async_render(request)
|
self._async_render(request)
|
||||||
return server.NOT_DONE_YET
|
return server.NOT_DONE_YET
|
||||||
|
|
||||||
# Disable metric reporting because _async_render does its own metrics.
|
@request_handler()
|
||||||
# It does its own metric reporting because _async_render dispatches to
|
|
||||||
# a callback and it's the class name of that callback we want to report
|
|
||||||
# against rather than the JsonResource itself.
|
|
||||||
@request_handler(include_metrics=True)
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _async_render(self, request, request_metrics):
|
def _async_render(self, request):
|
||||||
""" This gets called from render() every time someone sends us a request.
|
""" This gets called from render() every time someone sends us a request.
|
||||||
This checks if anyone has registered a callback for that method and
|
This checks if anyone has registered a callback for that method and
|
||||||
path.
|
path.
|
||||||
@ -224,8 +215,7 @@ class JsonResource(HttpServer, resource.Resource):
|
|||||||
servlet_classname = servlet_instance.__class__.__name__
|
servlet_classname = servlet_instance.__class__.__name__
|
||||||
else:
|
else:
|
||||||
servlet_classname = "%r" % callback
|
servlet_classname = "%r" % callback
|
||||||
|
request.request_metrics.name = servlet_classname
|
||||||
request_metrics.name = servlet_classname
|
|
||||||
|
|
||||||
# Now trigger the callback. If it returns a response, we send it
|
# Now trigger the callback. If it returns a response, we send it
|
||||||
# here. If it throws an exception, that is handled by the wrapper
|
# here. If it throws an exception, that is handled by the wrapper
|
||||||
|
Loading…
Reference in New Issue
Block a user