75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/newrelic_sequel/sequel.rb', line 75
def log_duration_with_newrelic_instrumentation(duration, sql)
return unless NewRelic::Agent.is_execution_traced?
return unless operation = case sql
when /^\s*select/i then
'find'
when /^\s*(update|insert)/i then
'save'
when /^\s*delete/i then
'destroy'
else
nil
end
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, nil, duration)
metrics = ["ActiveRecord/#{operation}", 'ActiveRecord/all']
metrics.each do |metric|
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
end
ensure
log_duration_without_newrelic_instrumentation(duration, sql)
end
|