Method: OneApm::Agent::Instrumentation::Sinatra#route_eval_with_oneapm

Defined in:
lib/one_apm/inst/framework/sinatra.rb

#route_eval_with_oneapm(*args, &block) ⇒ Object

If a transaction name is already set, this call will tromple over it. This is intentional, as typically passing to a separate route is like an entirely separate transaction, so we pick up the new name.

If we’re ignored, this remains safe, since set_transaction_name care for the gating on the transaction’s existence for us.



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/one_apm/inst/framework/sinatra.rb', line 124

def route_eval_with_oneapm(*args, &block)
  begin
    txn_name = TransactionNamer.transaction_name_for_route(env, request)
    unless txn_name.nil?
      ::OneApm::Transaction.set_default_transaction_name(
        "#{self.class.name}/#{txn_name}", :sinatra)
    end
  rescue => e
    OneApm::Manager.logger.debug("Failed during route_eval to set transaction name", e)
  end

  route_eval_without_oneapm(*args, &block)
end