Sha256: 4494af593974680bf26b7e5c91d12472d7f6693c7b08859661dae78353b1aa32

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

class TelemetryRecorder
  def initialize store
    @store = store
    @current_operation = nil
    @embedded = false
  end

  def update message, *payload
    method = "handle_#{message}"
    public_send method, *payload if respond_to? method
  end

  def embedded?
    @embedded
  end

  def handle_operation_entered operation, input
    return if embedded?
    @steps = Hash.new do |hsh, key| hsh[key] = {} end
    @store.update(
      :input => input,
      :movements => @steps,
      :operation_name => operation.name,
      :service_calls => [],
    )
    @embedded = true
  end

  def handle_operation_exited operation, output
    @store[:output] = output
    @embedded = false
  end

  def handle_step_entered step, input
    @steps[step.name][:input] = input
  end

  def handle_step_exited step, output
    @steps[step.name][:output] = output
  end

  def handle_error_raised error
    @store[:error] = error
  end

  def handle_service_accessed service_name, record
    @store[:service_calls].<< record.merge :service => service_name
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.5 test/support/telemetry_recorder.rb
ntl-orchestra-0.9.4 test/support/telemetry_recorder.rb