class ScoutApm::StoreReportingPeriodTimestamp
A timestamp, normalized to the beginning of a minute. Used as a hash key to bucket metrics into per-minute groups
Attributes
timestamp[R]
Public Class Methods
minutes_ago(min, base_time=Time.now)
click to toggle source
# File lib/scout_apm/store.rb, line 159 def self.minutes_ago(min, base_time=Time.now) adjusted = base_time - (min * 60) new(adjusted) end
new(time=Time.now)
click to toggle source
# File lib/scout_apm/store.rb, line 154 def initialize(time=Time.now) @raw_time = time.utc # The actual time passed in. Store it so we can to_s it without reparsing a timestamp @timestamp = @raw_time.to_i - @raw_time.sec # The normalized time (integer) to compare by end
Public Instance Methods
==(o)
click to toggle source
# File lib/scout_apm/store.rb, line 184 def ==(o) self.eql?(o) end
age_in_seconds()
click to toggle source
# File lib/scout_apm/store.rb, line 192 def age_in_seconds Time.now.to_i - timestamp end
eql?(o)
click to toggle source
# File lib/scout_apm/store.rb, line 180 def eql?(o) self.class == o.class && timestamp.eql?(o.timestamp) end
hash()
click to toggle source
# File lib/scout_apm/store.rb, line 188 def hash timestamp.hash end
strftime(pattern=nil)
click to toggle source
# File lib/scout_apm/store.rb, line 168 def strftime(pattern=nil) if pattern.nil? to_time.iso8601 else to_time.strftime(pattern) end end
to_s()
click to toggle source
# File lib/scout_apm/store.rb, line 164 def to_s strftime end
to_time()
click to toggle source
# File lib/scout_apm/store.rb, line 176 def to_time Time.at(@timestamp) end