diff --git a/lib/jsonapi/rails/controller.rb b/lib/jsonapi/rails/controller.rb index dc338b7..8f75a33 100644 --- a/lib/jsonapi/rails/controller.rb +++ b/lib/jsonapi/rails/controller.rb @@ -33,11 +33,15 @@ def deserializable_resource(key, options = {}, &block) before_action(options) do |controller| hash = controller.params[:_jsonapi].to_unsafe_hash - JSONAPI::Parser::Resource.parse!(hash) - resource = klass.new(hash[:data]) - controller.request.env[JSONAPI_POINTERS_KEY] = - resource.reverse_mapping - controller.params[key.to_sym] = resource.to_hash + ActiveSupport::Notifications.instrument('parse.jsonapi', + payload: hash, + class: klass) do + JSONAPI::Parser::Resource.parse!(hash) + resource = klass.new(hash[:data]) + controller.request.env[JSONAPI_POINTERS_KEY] = + resource.reverse_mapping + controller.params[key.to_sym] = resource.to_hash + end end end end diff --git a/lib/jsonapi/rails/railtie.rb b/lib/jsonapi/rails/railtie.rb index 4c94094..7b908cf 100644 --- a/lib/jsonapi/rails/railtie.rb +++ b/lib/jsonapi/rails/railtie.rb @@ -38,7 +38,11 @@ class Railtie < ::Rails::Railtie # Renderer proc is evaluated in the controller context. self.content_type ||= Mime[:jsonapi] - renderer.render(resources, options, self).to_json + ActiveSupport::Notifications.instrument('render.jsonapi', + resources: resources, + options: options) do + renderer.render(resources, options, self).to_json + end end end end