Methods
Constants
SERVER_TIMING_HEADER | = | "Server-Timing" |
Class Public methods
new(app) Link
Instance Public methods
call(env) Link
# File actionpack/lib/action_dispatch/middleware/server_timing.rb, line 13 def call(env) events = [] subscriber = ActiveSupport::Notifications.subscribe(/.*/) do |*args| events << ActiveSupport::Notifications::Event.new(*args) end status, headers, body = begin @app.call(env) ensure ActiveSupport::Notifications.unsubscribe(subscriber) end header_info = events.group_by(&:name).map do |event_name, events_collection| "#{event_name};dur=#{events_collection.sum(&:duration)}" end headers[SERVER_TIMING_HEADER] = header_info.join(", ") [ status, headers, body ] end