Sha256: b097376a1114a816fbb71d45fb2aaa7647a6e81560d9eed703894d2cb801fa5b

Contents?: true

Size: 1.03 KB

Versions: 3

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_name, input
    return if embedded?
    @nodes = Hash.new do |hsh, key| hsh[key] = {} end
    @store.update(
      :input => input,
      :movements => @nodes,
      :performance_name => operation_name,
      :service_calls => [],
    )
    @embedded = true
  end

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

  def handle_node_entered name, input
    @nodes[name][:input] = input
  end

  def handle_node_exited name, output
    @nodes[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

3 entries across 3 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.2 test/support/telemetry_recorder.rb
ntl-orchestra-0.9.1 test/support/telemetry_recorder.rb
ntl-orchestra-0.9.0 test/support/telemetry_recorder.rb