Module: Datadog::Core::Utils

Extended by:
Forking
Defined in:
lib/datadog/core/utils.rb,
lib/datadog/core/utils/url.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,
lib/datadog/core/utils/only_once_successful.rb

Overview

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

Defined Under Namespace

Modules: Compression, Duration, Forking, Hash, Network, SafeDup, Time, Url Classes: OnlyOnce, OnlyOnceSuccessful, Sequence

Constant Summary collapse

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

Class Method Summary collapse

Methods included from Forking

after_fork!, extended, fork_pid, forked?, included, update_fork_pid!

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