class PRFLR::Client

Public Class Methods

new(opts = {}) click to toggle source
# File lib/prflr.rb, line 8
def initialize(opts = {})
   @host             = opts[:host]
    @port           = opts[:port]
    @source         = opts[:source]
    @apiKey         = opts[:apikey]
    @timers         = {}
    @threadId       = UUID.new.generate
    @socket         = UDPSocket.new
end

Public Instance Methods

begin(timer) click to toggle source
# File lib/prflr.rb, line 18
def begin(timer)
   @timers[timer] = Time.now.to_i
end
finalize(object_id) click to toggle source
# File lib/prflr.rb, line 32
def finalize(object_id)
    @socket.close
    end
finish(timer, info = nil) click to toggle source
# File lib/prflr.rb, line 22
def finish(timer, info = nil)
   time = ((Time.now.to_i - @timers[timer]) * 1000).round(3)
   send(timer, time, info)
end
send(timer, time, info) click to toggle source
# File lib/prflr.rb, line 27
def send(timer, time, info)
   message = "#{@threadId[0..32].sub('|','')}|#{@source[0..32].sub('|','')}|#{timer[0..48].sub('|','')}|#{time}|#{info[0..32]}|#{@apiKey[0..32]}"
   @socket.send(message, 0, @host, @port)
end