6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rails_performance/gems/custom_ext.rb', line 6
def measure(tag_name, namespace_name = nil)
return yield unless RailsPerformance.enabled
return yield unless RailsPerformance.include_custom_events
begin
now = Time.current
status = 'success'
result = yield
result
rescue Exception => ex
status = 'error'
raise(ex)
ensure
RailsPerformance::Models::CustomRecord.new(
tag_name: tag_name,
namespace_name: namespace_name,
status: status,
duration: (Time.current - now) * 1000,
datetime: now.strftime(RailsPerformance::FORMAT),
datetimei: now.to_i,
).save
result
end
end
|