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/base64.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/at_fork_monkey_patch.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: AtForkMonkeyPatch, Base64, 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



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

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

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