Class: OpenTrace::Stats
- Inherits:
-
Object
- Object
- OpenTrace::Stats
- Defined in:
- lib/opentrace/stats.rb
Constant Summary collapse
- COUNTERS =
%i[ enqueued delivered dropped_queue_full dropped_circuit_open dropped_auth_suspended dropped_error retries rate_limited auth_failures payload_splits batches_sent bytes_sent ].freeze
Instance Method Summary collapse
- #get(counter) ⇒ Object
- #increment(counter, amount = 1) ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #reset! ⇒ Object
- #to_h ⇒ Object
Constructor Details
Instance Method Details
#get(counter) ⇒ Object
30 31 32 |
# File 'lib/opentrace/stats.rb', line 30 def get(counter) @mutex.synchronize { @counters[counter] } end |
#increment(counter, amount = 1) ⇒ Object
26 27 28 |
# File 'lib/opentrace/stats.rb', line 26 def increment(counter, amount = 1) @mutex.synchronize { @counters[counter] += amount } end |
#reset! ⇒ Object
40 41 42 43 44 45 |
# File 'lib/opentrace/stats.rb', line 40 def reset! @mutex.synchronize do @counters.transform_values! { 0 } @started_at = Time.now end end |
#to_h ⇒ Object
34 35 36 37 38 |
# File 'lib/opentrace/stats.rb', line 34 def to_h @mutex.synchronize do @counters.merge(uptime_seconds: (Time.now - @started_at).to_i).dup end end |