module NewRelic::TelemetrySdk::Util

Constants

HEX_DIGITS

Public Instance Methods

current_time() click to toggle source
# File lib/newrelic/telemetry_sdk/util.rb, line 28
def current_time
  Time.now
end
generate_guid(length = 16) click to toggle source

This method intentionally does not use SecureRandom, because it relies on urandom, which raises an exception in MRI when the interpreter runs out of allocated file descriptors. The guids generated by this method may not be secure, but they are random enough for our purposes.

# File lib/newrelic/telemetry_sdk/util.rb, line 20
def generate_guid length = 16
  guid = String.new
  length.times do |a|
    guid << HEX_DIGITS[rand(16)]
  end
  guid
end
time_to_ms(time = current_time) click to toggle source
# File lib/newrelic/telemetry_sdk/util.rb, line 32
def time_to_ms time = current_time
  (time.to_f * 1000).round
end