Module: HeimdallApm::Probe

Defined in:
lib/heimdall_apm/probe.rb

Overview

Provides helpers for custom instrumentation of code

include Probe
instrument('Elastic', 'profiles#search') do ... end

Instance Method Summary collapse

Instance Method Details

#instrument(type, name, opts = {}) ⇒ Object

Insruments block passed to the method into the current transaction.

Parameters:

  • type

    Segment type (i.e ‘ActiveRecord’ or similar)

  • name

    Specific name for the segment


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/heimdall_apm/probe.rb', line 13

def instrument(type, name, opts = {})
  txn     = ::HeimdallApm::TransactionManager.current
  segment = ::HeimdallApm::Segment.new(type, name)
  txn.start_segment(segment)

  # TODO: maybe yield the segment here to have the block pass additional
  # informations
  yield
ensure
  txn.stop_segment
end