Commit b9faed27 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Use the format_response hook for API requests

With endpoint_run, we were missing some Redis / DB calls that are
triggered during the serialization of data.

This happens very frequently because ActiveRecord relations are loaded
lazily and these are most likely going to be triggered during
serialization.
parent 12b3e253
...@@ -24,7 +24,7 @@ Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled? ...@@ -24,7 +24,7 @@ Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled?
# See https://github.com/peek/peek/blob/master/lib/peek/views/view.rb # See https://github.com/peek/peek/blob/master/lib/peek/views/view.rb
Peek.views Peek.views
ActiveSupport::Notifications.subscribe('endpoint_run.grape') do |_name, _start, _finish, _id, payload| ActiveSupport::Notifications.subscribe('format_response.grape') do |_name, _start, _finish, _id, payload|
if request_id = payload[:env]['action_dispatch.request_id'] if request_id = payload[:env]['action_dispatch.request_id']
Peek.adapter.save(request_id) Peek.adapter.save(request_id)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment