Sha256: 42506fc50e2a017afb77d1eb68f2e0c1ff64f3baaa19f45b6d97010fe0c5a744

Contents?: true

Size: 724 Bytes

Versions: 4

Compression:

Stored size: 724 Bytes

Contents

module HeimdallApm
  # Provides helpers for custom instrumentation of code
  #
  #   include Probe
  #   instrument('Elastic', 'profiles#search') do ... end
  #
  module Probe
    # Insruments block passed to the method into the current transaction.
    #
    # @param type Segment type (i.e 'ActiveRecord' or similar)
    # @param name Specific name for the segment
    #
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
heimdall_apm-0.1.3 lib/heimdall_apm/probe.rb
heimdall_apm-0.1.2 lib/heimdall_apm/probe.rb
heimdall_apm-0.1.1 lib/heimdall_apm/probe.rb
heimdall_apm-0.1.0 lib/heimdall_apm/probe.rb