def after_request(response): try: request_duration.labels(request.endpoint, request.method).observe( time.time() - request._start_time) except AttributeError: logging.exception("Request without _start_time - check app.before_request ordering") request_total.labels(request.endpoint, request.method, response.status_code).inc() return response
def after_request(response): try: request_duration.labels(request.endpoint, request.method).observe( time.time() - request._start_time) except AttributeError: # In some cases this isn't present? logging.exception("Request without _start_time") request_total.labels(request.endpoint, request.method, response.status_code).inc() return response
def after_request(response): try: request_duration.labels( request.endpoint, request.method).observe(time.time() - request._start_time) except AttributeError: logging.exception( "Request without _start_time - check app.before_request ordering" ) request_total.labels(request.endpoint, request.method, response.status_code).inc() return response