Sha256: 8dd6e15d4928db8f84188b8a6dfbd1d79dd9f076dd4f65ad933cb3a34c0e5eec

Contents?: true

Size: 780 Bytes

Versions: 4

Compression:

Stored size: 780 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module GuidGenerator

      HEX_DIGITS = (0..15).map{|i| i.to_s(16)}

      module_function

      # 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.
      def generate_guid length = 16
        guid = ''
        length.times do |a|
          guid << HEX_DIGITS[rand(16)]
        end
        guid
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-6.11.0.365 lib/new_relic/agent/guid_generator.rb
newrelic_rpm-6.10.0.364 lib/new_relic/agent/guid_generator.rb
newrelic_rpm-6.9.0.363 lib/new_relic/agent/guid_generator.rb
newrelic_rpm-6.8.0.360 lib/new_relic/agent/guid_generator.rb