Module: Datadog::Core::Utils

Defined in:
lib/datadog/core/utils.rb,
lib/datadog/core/utils/hash.rb,
lib/datadog/core/utils/time.rb,
lib/datadog/core/utils/forking.rb,
lib/datadog/core/utils/network.rb,
lib/datadog/core/utils/duration.rb,
lib/datadog/core/utils/safe_dup.rb,
lib/datadog/core/utils/sequence.rb,
lib/datadog/core/utils/only_once.rb,
lib/datadog/core/utils/compression.rb

Overview

Utils contains low-level utilities, typically to provide pseudo-random trace IDs.

Constant Summary collapse

EMPTY_STRING =
''.encode(::Encoding::UTF_8).freeze

Class Method Summary collapse

Class Method Details

.extract_host_port(host_port) ⇒ String, ...

Extracts hostname and port from a string that contains both, separated by ':'.

Returns:

  • (String, Integer)

    hostname and port

  • (nil)

    if format did not match



84
85
86
87
88
89
# File 'lib/datadog/core/utils.rb', line 84

def self.extract_host_port(host_port)
  match = /^([^:]+):(\d+)$/.match(host_port)
  return unless match

  [match[1], match[2].to_i]
end