call method

Future<Response> call(
  1. Request req
)

Implementation

Future<Response> call(Request req) async {
  if (_unmeasured.contains(req.url.path) ||
      req.url.path.startsWith('/_dartvel/')) {
    return _dispatch(req);
  }

  final Stopwatch clock = Stopwatch()..start();
  try {
    final Response response = await _dispatch(req);
    clock.stop();
    _record(req, response.status, clock, response.headers.get('traceparent'));
    return response;
  } on Object catch (error, stack) {
    clock.stop();
    // The server layer turns this into a 500 inside a bare `catch (_)`, so
    // if it is not recorded here the exception is gone: no line, no count,
    // and a client holding a 500 nobody can explain.
    _record(req, 500, clock, null, error: error, stackTrace: stack);
    rethrow;
  }
}