Sha256: 04886658efd1146c6f9f9e9903d6968c11d9892b907c0cd2438533cad711405b

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'etc'

require_relative 'identity'

module Datadog
  module Core
    module Environment
      # For gathering information about the platform
      module Platform
        module_function

        # @return [String] name of host; `uname -n`
        def hostname
          Identity.lang_version >= '2.2' ? Etc.uname[:nodename] : nil
        end

        # @return [String] name of kernel; `uname -s`
        def kernel_name
          Identity.lang_version >= '2.2' ? Etc.uname[:sysname] : Gem::Platform.local.os.capitalize
        end

        # @return [String] kernel release; `uname -r`
        def kernel_release
          if Identity.lang_engine == 'jruby'
            Etc.uname[:version] # Java's `os.version` maps to `uname -r`
          elsif Identity.lang_version >= '2.2'
            Etc.uname[:release]
          end
        end

        # @return [String] kernel version; `uname -v`
        def kernel_version
          Etc.uname[:version] if Identity.lang_engine != 'jruby' && Identity.lang_version >= '2.2'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datadog-2.0.0.beta1 lib/datadog/core/environment/platform.rb