Class: ElasticAPM::Spies::SneakersSpy::Middleware Private

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_apm/spies/sneakers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(app, *args) ⇒ Middleware

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Middleware.



44
45
46
47
# File 'lib/elastic_apm/spies/sneakers.rb', line 44

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

Instance Method Details

#call(deserialized_msg, delivery_info, metadata, handler) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/elastic_apm/spies/sneakers.rb', line 49

def call(deserialized_msg, delivery_info, , 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, , 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