Module: TingYun::Instrumentation::Support::ControllerInstrumentation

Extended by:
ControllerInstrumentation
Included in:
ControllerInstrumentation
Defined in:
lib/ting_yun/instrumentation/support/controller_instrumentation.rb

Overview

This module can also be used to capture performance information for background tasks and other non-web transactions, including detailed transaction traces and traced errors.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



24
25
26
# File 'lib/ting_yun/instrumentation/support/controller_instrumentation.rb', line 24

def self.extended klass
  klass.extend ClassMethods
end

.included(klass) ⇒ Object



20
21
22
# File 'lib/ting_yun/instrumentation/support/controller_instrumentation.rb', line 20

def self.included klass
  klass.extend ClassMethods
end

Instance Method Details

#perform_action_with_tingyun_trace(*args, &block) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/ting_yun/instrumentation/support/controller_instrumentation.rb', line 212

def perform_action_with_tingyun_trace (*args, &block)

  state = TingYun::Agent::TransactionState.tl_get

  skip_tracing = !state.execution_traced?

  if skip_tracing
    state.current_transaction.ignore! if state.current_transaction
    TingYun::Agent.disable_all_tracing { return yield }
  end
  trace_options = args.last.is_a?(Hash) ? args.last : NR_DEFAULT_OPTIONS
  category = trace_options[:category] || :controller
  txn_options = create_transaction_options(trace_options, category)

  begin
    TingYun::Agent::Transaction.start(state, category, txn_options)
    begin
      yield
    rescue => e
      ::TingYun::Agent.notice_error(e,:type=> :exception)
      raise e
    end
  ensure
    TingYun::Agent::Transaction.stop(state)
  end
end