module Tracebin::CustomInstrumentation

Public Class Methods

instrument(identifier) { || ... } click to toggle source
# File lib/tracebin/custom_instrumentation.rb, line 9
def instrument(identifier)
  unless block_given?
    raise ArgumentError, 'Tracebin instrumentation must receive a block'
  end

  start_time = timestamp_string
  yield
  end_time = timestamp_string

  event_data = [
    'custom.tracebin',
    start_time,
    end_time,
    {
      identifier: identifier
    }
  ]

  handle_event event_data
end

Private Class Methods

handle_event(event_data) click to toggle source
# File lib/tracebin/custom_instrumentation.rb, line 32
def handle_event(event_data)
  event = Tracebin::CustomEvent.new event_data
  Tracebin::Recorder << event
end