Class: ScoutApm::StoreReportingPeriodTimestamp
- Inherits:
-
Object
- Object
- ScoutApm::StoreReportingPeriodTimestamp
- Defined in:
- lib/scout_apm/store.rb
Overview
A timestamp, normalized to the beginning of a minute. Used as a hash key to bucket metrics into per-minute groups
Instance Attribute Summary collapse
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #age_in_seconds ⇒ Object
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(time = Time.now) ⇒ StoreReportingPeriodTimestamp
constructor
A new instance of StoreReportingPeriodTimestamp.
- #to_s ⇒ Object
Constructor Details
#initialize(time = Time.now) ⇒ StoreReportingPeriodTimestamp
Returns a new instance of StoreReportingPeriodTimestamp.
106 107 108 109 |
# File 'lib/scout_apm/store.rb', line 106 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 |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
104 105 106 |
# File 'lib/scout_apm/store.rb', line 104 def @timestamp end |
Instance Method Details
#==(o) ⇒ Object
119 120 121 |
# File 'lib/scout_apm/store.rb', line 119 def ==(o) self.eql?(o) end |
#age_in_seconds ⇒ Object
127 128 129 |
# File 'lib/scout_apm/store.rb', line 127 def age_in_seconds Time.now.to_i - end |
#eql?(o) ⇒ Boolean
115 116 117 |
# File 'lib/scout_apm/store.rb', line 115 def eql?(o) self.class == o.class && .eql?(o.) end |
#hash ⇒ Object
123 124 125 |
# File 'lib/scout_apm/store.rb', line 123 def hash .hash end |
#to_s ⇒ Object
111 112 113 |
# File 'lib/scout_apm/store.rb', line 111 def to_s Time.at(@timestamp).iso8601 end |