Module: Datadog::Core::Diagnostics::EnvironmentCollector

Defined in:
lib/datadog/core/diagnostics/environment_logger.rb

Overview

Collects environment information for Core diagnostic logging

Class Method Summary collapse

Class Method Details

.collect_config!Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 75

def collect_config!
  {
    date: date,
    os_name: os_name,
    version: version,
    lang: lang,
    lang_version: lang_version,
    env: env,
    service: service,
    dd_version: dd_version,
    debug: debug,
    tags: tags,
    runtime_metrics_enabled: runtime_metrics_enabled,
    vm: vm,
    health_metrics_enabled: health_metrics_enabled
  }
end

.dateString

Returns current time in ISO8601 format.

Returns:

  • (String)

    current time in ISO8601 format



94
95
96
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 94

def date
  Time.now.utc.iso8601
end

.dd_versionString

Returns configured application version.

Returns:

  • (String)

    configured application version



132
133
134
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 132

def dd_version
  Datadog.configuration.version
end

.debugBoolean?

Returns debug mode enabled in configuration.

Returns:

  • (Boolean, nil)

    debug mode enabled in configuration



137
138
139
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 137

def debug
  !!Datadog.configuration.diagnostics.debug
end

.envString

Returns configured application environment.

Returns:

  • (String)

    configured application environment



122
123
124
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 122

def env
  Datadog.configuration.env
end

.health_metrics_enabledBoolean?

Returns health metrics enabled in configuration.

Returns:

  • (Boolean, nil)

    health metrics enabled in configuration



169
170
171
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 169

def health_metrics_enabled
  !!Datadog.configuration.diagnostics.health_metrics.enabled
end

.langString

Returns “ruby”.

Returns:

  • (String)

    “ruby”



110
111
112
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 110

def lang
  Core::Environment::Ext::LANG
end

.lang_versionString

Supported Ruby language version. Will be distinct from VM version for non-MRI environments.

Returns:

  • (String)


117
118
119
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 117

def lang_version
  Core::Environment::Ext::LANG_VERSION
end

.os_nameString

Best portable guess of OS information.

Returns:

  • (String)

    platform string



100
101
102
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 100

def os_name
  RbConfig::CONFIG['host']
end

.runtime_metrics_enabledBoolean?

Returns runtime metrics enabled in configuration.

Returns:

  • (Boolean, nil)

    runtime metrics enabled in configuration



150
151
152
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 150

def runtime_metrics_enabled
  Datadog.configuration.runtime_metrics.enabled
end

.serviceString

Returns configured application service name.

Returns:

  • (String)

    configured application service name



127
128
129
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 127

def service
  Datadog.configuration.service
end

.tagsHash?

Returns concatenated list of global tracer tags configured.

Returns:

  • (Hash, nil)

    concatenated list of global tracer tags configured



142
143
144
145
146
147
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 142

def tags
  tags = Datadog.configuration.tags
  return nil if tags.empty?

  hash_serializer(tags)
end

.versionString

Returns ddtrace version.

Returns:

  • (String)

    ddtrace version



105
106
107
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 105

def version
  DDTrace::VERSION::STRING
end

.vmString?

Ruby VM name and version. Examples: “ruby-2.7.1”, “jruby-9.2.11.1”, “truffleruby-20.1.0”

Returns:

  • (String, nil)


157
158
159
160
161
162
163
164
165
166
# File 'lib/datadog/core/diagnostics/environment_logger.rb', line 157

def vm
  # RUBY_ENGINE_VERSION returns the VM version, which
  # will differ from RUBY_VERSION for non-mri VMs.
  if defined?(RUBY_ENGINE_VERSION)
    "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}"
  else
    # Ruby < 2.3 doesn't support RUBY_ENGINE_VERSION
    "#{RUBY_ENGINE}-#{RUBY_VERSION}"
  end
end