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 dropped_filtered retries rate_limited auth_failures payload_splits batches_sent bytes_sent sampled_out sql_filtered ].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
Cold path: mutex for consistent snapshot.
Constructor Details
Instance Method Details
#get(counter) ⇒ Object
33 34 35 |
# File 'lib/opentrace/stats.rb', line 33 def get(counter) @counters[counter] end |
#increment(counter, amount = 1) ⇒ Object
29 30 31 |
# File 'lib/opentrace/stats.rb', line 29 def increment(counter, amount = 1) @mutex.synchronize { @counters[counter] += amount } end |
#reset! ⇒ Object
44 45 46 47 48 49 |
# File 'lib/opentrace/stats.rb', line 44 def reset! @mutex.synchronize do @counters = Hash.new(0) @started_at = Time.now end end |
#to_h ⇒ Object
Cold path: mutex for consistent snapshot
38 39 40 41 42 |
# File 'lib/opentrace/stats.rb', line 38 def to_h @mutex.synchronize do @counters.merge(uptime_seconds: (Time.now - @started_at).to_i).dup end end |