class HeimdallApm::Vault
Keeps in RAM one or more minute's worth of metrics. When informed to by the background thread, it pushes the in-RAM metrics off to InfluxDB.
Public Class Methods
new(context)
click to toggle source
# File lib/heimdall_apm/vault.rb, line 9 def initialize(context) @context = context @lock = Mutex.new @spans = Hash.new { |h, k| h[k] = Span.new(k, @context) } end
Public Instance Methods
current_span()
click to toggle source
# File lib/heimdall_apm/vault.rb, line 15 def current_span @spans[current_timestamp] end
current_timestamp()
click to toggle source
# File lib/heimdall_apm/vault.rb, line 28 def current_timestamp time = Time.now.utc time.to_i - time.sec end
retrieve_and_delete_previous_span()
click to toggle source
# File lib/heimdall_apm/vault.rb, line 19 def retrieve_and_delete_previous_span timestamp = current_timestamp - 60 @lock.synchronize { @spans.delete(timestamp) } end
store_transaction_metrics(txn, metrics)
click to toggle source
# File lib/heimdall_apm/vault.rb, line 24 def store_transaction_metrics(txn, metrics) @lock.synchronize { current_span.add_point(txn, metrics) } end