class Honeykiq::LibhoneySpan

Attributes

libhoney[R]

Public Class Methods

new(libhoney) click to toggle source
# File lib/honeykiq/libhoney_span.rb, line 3
def initialize(libhoney)
  @libhoney = libhoney
end

Public Instance Methods

call(*) { |event| ... } click to toggle source
# File lib/honeykiq/libhoney_span.rb, line 7
def call(*)
  libhoney.event.tap do |event|
    duration_ms(event) { yield event }
  ensure
    event.send
  end
end

Private Instance Methods

duration_ms(event) { || ... } click to toggle source
# File lib/honeykiq/libhoney_span.rb, line 19
def duration_ms(event)
  start_time = now
  yield
ensure
  duration = now - start_time
  event.add_field(:duration_ms, duration * 1000)
end
now() click to toggle source
# File lib/honeykiq/libhoney_span.rb, line 28
def now
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end