Module: Logtail::Timer

Defined in:
lib/logtail/timer.rb

Overview

This is an ultra-simple abstraction for timing code. This provides a little more control around how Logtail automatically processes “timers”.

Examples:

timer = Logtail::Timer.start
# ... code to time
logger.info("My log message", my_event: {time_ms: timer})

Class Method Summary collapse

Class Method Details

.duration_ms(timer) ⇒ Object

Get the duration in milliseconds from the object returned in #start



16
17
18
19
# File 'lib/logtail/timer.rb', line 16

def self.duration_ms(timer)
  now = Time.now
  (now - timer) * 1000.0
end

.startObject

Abstract for starting a logtail. Currently this is simply calling ‘Time.now`.



11
12
13
# File 'lib/logtail/timer.rb', line 11

def self.start
  Time.now
end