class ElasticAPM::Spies::SneakersSpy::Middleware

@api private

def call(deserialized_msg, delivery_info, metadata, handler)

def call(deserialized_msg, delivery_info, metadata, handler)
  transaction =
    ElasticAPM.start_transaction(
      delivery_info.consumer.queue.name,
      'Sneakers'
    )
  ElasticAPM.set_label(:routing_key, delivery_info.routing_key)
  res = @app.call(deserialized_msg, delivery_info, metadata, handler)
  transaction&.done(:success)
  transaction&.outcome = Transaction::Outcome::SUCCESS
  res
rescue ::Exception => e
  ElasticAPM.report(e, handled: false)
  transaction&.done(:error)
  transaction&.outcome = Transaction::Outcome::FAILURE
  raise
ensure
  ElasticAPM.end_transaction
end

def initialize(app, *args)

def initialize(app, *args)
  @app = app
  @args = args
end