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.
Class Method Summary collapse
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.
- #strftime(pattern = nil) ⇒ Object
- #to_s ⇒ Object
- #to_time ⇒ Object
Constructor Details
#initialize(time = Time.now) ⇒ StoreReportingPeriodTimestamp
Returns a new instance of StoreReportingPeriodTimestamp.
126 127 128 129 |
# File 'lib/scout_apm/store.rb', line 126 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.
124 125 126 |
# File 'lib/scout_apm/store.rb', line 124 def @timestamp end |
Class Method Details
.minutes_ago(min, base_time = Time.now) ⇒ Object
131 132 133 134 |
# File 'lib/scout_apm/store.rb', line 131 def self.minutes_ago(min, base_time=Time.now) adjusted = base_time - (min * 60) new(adjusted) end |
Instance Method Details
#==(o) ⇒ Object
156 157 158 |
# File 'lib/scout_apm/store.rb', line 156 def ==(o) self.eql?(o) end |
#age_in_seconds ⇒ Object
164 165 166 |
# File 'lib/scout_apm/store.rb', line 164 def age_in_seconds Time.now.to_i - end |
#eql?(o) ⇒ Boolean
152 153 154 |
# File 'lib/scout_apm/store.rb', line 152 def eql?(o) self.class == o.class && .eql?(o.) end |
#hash ⇒ Object
160 161 162 |
# File 'lib/scout_apm/store.rb', line 160 def hash .hash end |
#strftime(pattern = nil) ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/scout_apm/store.rb', line 140 def strftime(pattern=nil) if pattern.nil? to_time.iso8601 else to_time.strftime(pattern) end end |
#to_s ⇒ Object
136 137 138 |
# File 'lib/scout_apm/store.rb', line 136 def to_s strftime end |
#to_time ⇒ Object
148 149 150 |
# File 'lib/scout_apm/store.rb', line 148 def to_time Time.at(@timestamp) end |