Method: NewRelic::Agent::Tracer.in_transaction

Defined in:
lib/new_relic/agent/tracer.rb

.in_transaction(name: nil, partial_name: nil, category: nil, options: {}) ⇒ Object

Runs the given block of code in a transaction.

Parameters:

  • name (String) (defaults to: nil)

    reserved for New Relic internal use

  • partial_name (String) (defaults to: nil)

    a meaningful name for this transaction (e.g., blogs/index); the Ruby agent will add a New-Relic-specific prefix

  • category (Symbol) (defaults to: nil)

    :web for web transactions or :background for background transactions

  • options (Hash) (defaults to: {})

    reserved for New Relic internal use


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/new_relic/agent/tracer.rb', line 88

def in_transaction(name: nil,
                   partial_name: nil,
                   category: nil,
                   options: {})

  finishable = start_transaction_or_segment(
    name: name,
    partial_name: partial_name,
    category: category,
    options: options
  )

  begin
    # We shouldn't raise from Tracer.start_transaction_or_segment, but
    # only wrap the yield to be absolutely sure we don't report agent
    # problems as app errors
    yield
  rescue => exception
    current_transaction.notice_error(exception)
    raise
  ensure
    finishable.finish if finishable
  end
end