Module: Railswatch::Gems::CustomExtension
- Defined in:
- lib/railswatch/gems/custom_ext.rb
Class Method Summary collapse
- .execute_with_status ⇒ Object
- .measure(tag_name, namespace_name = nil) ⇒ Object
- .save_custom_record(tag_name, namespace_name, status, now) ⇒ Object
Class Method Details
.execute_with_status ⇒ Object
22 23 24 |
# File 'lib/railswatch/gems/custom_ext.rb', line 22 def execute_with_status yield end |
.measure(tag_name, namespace_name = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/railswatch/gems/custom_ext.rb', line 8 def measure(tag_name, namespace_name = nil, &) return yield unless Railswatch.enabled && Railswatch.include_custom_events now = Railswatch::Utils.time status = 'success' execute_with_status(&) rescue Exception => e # rubocop:disable Lint/RescueException status = 'error' raise(e) ensure save_custom_record(tag_name, namespace_name, status, now) CurrentRequest.cleanup end |
.save_custom_record(tag_name, namespace_name, status, now) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/railswatch/gems/custom_ext.rb', line 26 def save_custom_record(tag_name, namespace_name, status, now) Railswatch::Models::CustomRecord.new( tag_name: tag_name, namespace_name: namespace_name, status: status, duration: (Railswatch::Utils.time - now) * 1000, datetime: now.strftime(Railswatch::FORMAT), datetimei: now.to_i ).save end |