Class: OpenTrace::PipelineStats

Inherits:
Object
  • Object
show all
Defined in:
lib/opentrace/pipeline.rb

Overview

Thread-safe stats counter for the pipeline

Instance Method Summary collapse

Constructor Details

#initializePipelineStats

Returns a new instance of PipelineStats.



218
219
220
221
# File 'lib/opentrace/pipeline.rb', line 218

def initialize
  @counters = Hash.new(0)
  @mutex = Mutex.new
end

Instance Method Details

#get(key) ⇒ Object



227
228
229
# File 'lib/opentrace/pipeline.rb', line 227

def get(key)
  @mutex.synchronize { @counters[key] }
end

#increment(key, amount = 1) ⇒ Object



223
224
225
# File 'lib/opentrace/pipeline.rb', line 223

def increment(key, amount = 1)
  @mutex.synchronize { @counters[key] += amount }
end

#reset!Object



235
236
237
# File 'lib/opentrace/pipeline.rb', line 235

def reset!
  @mutex.synchronize { @counters.clear }
end

#to_hObject



231
232
233
# File 'lib/opentrace/pipeline.rb', line 231

def to_h
  @mutex.synchronize { @counters.dup }
end