8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rails_vitals/instrumentation/callback_instrumentation.rb', line 8
def run_callbacks(kind, *args, &block)
collector = RailsVitals::Collector.current
unless collector && RailsVitals.config.enabled &&
TRACKED_CALLBACKS.include?(kind)
return super
end
start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
result = super
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond) - start
collector.add_callback(
model: self.class.name,
kind: kind,
duration_ms: duration.round(2)
)
result
end
|