Sha256: 2cf3be50df19988e185706424c3597b9089643306486b5e21a27eef0922c8121

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 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] ISA of host; `uname -m`
        def architecture
          Identity.lang_version >= '2.2' ? Etc.uname[:machine] : Gem::Platform.local.cpu
        end

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

        # System name, normally `Linux` or `Darwin` (but 'Mac OS X' on JRuby);
        # @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

9 entries across 9 versions & 1 rubygems

Version Path
datadog-2.7.0 lib/datadog/core/environment/platform.rb
datadog-2.6.0 lib/datadog/core/environment/platform.rb
datadog-2.5.0 lib/datadog/core/environment/platform.rb
datadog-2.4.0 lib/datadog/core/environment/platform.rb
datadog-2.3.0 lib/datadog/core/environment/platform.rb
datadog-2.2.0 lib/datadog/core/environment/platform.rb
datadog-2.1.0 lib/datadog/core/environment/platform.rb
datadog-2.0.0 lib/datadog/core/environment/platform.rb
datadog-2.0.0.beta2 lib/datadog/core/environment/platform.rb