New Relic Instrumentation for Grape :: Middleware :: Formatter # in Rails Application

In the Rails New Relic transaction section, I see that this particular method call ( Grape :: Middleware :: Formatter # call ) is the most time-consuming (almost 90% of the time):

Middleware  Grape::Middleware::Formatter#call   89.2 % (Time)   824 ms (Avg Time)

But there is not enough information about what actually causes the performance problem in the New Relic transaction breakdown table. Therefore, I want to add Ruby custom instrumentation for this method so that New Relic can provide me more information about the problem, showing all the events that occur when the Grape :: Middleware :: Formatter # call method is called .

Looking for a new relic of documentation to add custom tools. I created a new file called config / initializers / rpm_instrumentation. rb and the following content:

require 'new_relic/agent/method_tracer'

Grape::Middleware::Formatter.class_eval do
  include ::NewRelic::Agent::MethodTracer

  add_method_tracer :call
end

But in my development mode, New Relic does not show any additional information on this call: Grape :: Middleware :: Formatter / call . Only summary SQL calls that were there before the addition of this custom indicator are displayed, which means that my custom tracer is not working as expected.

, : - ? New Relic , Rails, , Rails? ( Grape:: Middleware:: Formatter # call grape).

+4
1

Relic grape. , , , , . Ruby (Grape::Middleware::Formatter#call, ). , set_transaction_name .

call, add_method_tracer, tracer call , add_method_tracer . , - , set_transaction_name (, ).

+2

All Articles