Class: Salemove::ProcessHandler::PivotProcess::Benchmarker

Inherits:
Object
  • Object
show all
Defined in:
lib/salemove/process_handler/pivot_process.rb

Instance Method Summary collapse

Constructor Details

#initialize(statsd:, application:, execution_time_key:) ⇒ Benchmarker

Returns a new instance of Benchmarker.



242
243
244
245
246
# File 'lib/salemove/process_handler/pivot_process.rb', line 242

def initialize(statsd:, application:, execution_time_key:)
  @statsd = statsd
  @application = application
  @execution_time_key = execution_time_key
end

Instance Method Details

#call(input, &block) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/salemove/process_handler/pivot_process.rb', line 248

def call(input, &block)
  type = input[:type] if input.is_a?(Hash)
  result = nil

  bm = Benchmark.measure { result = block.call }

  @statsd.histogram(@execution_time_key, bm.real, tags: [
    "application:#{@application}",
    "type:#{type || 'unknown'}"
  ])

  result
end