Module: Tracebin::CustomInstrumentation

Extended by:
Helpers
Defined in:
lib/tracebin/custom_instrumentation.rb

Class Method Summary collapse

Methods included from Helpers

deserialize_time_string, milliseconds_between, time_to_string, timestamp_string, to_milliseconds

Class Method Details

.instrument(identifier) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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