Rack middleware for recording request metrics.