Module: Datadog::Core::Environment::Process Private

Defined in:
lib/datadog/core/environment/process.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Retrieves process level information such that it can be attached to various payloads

Class Method Summary collapse

Class Method Details

.rails_application_name=(name) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Sets the rails application name from other places in code

Parameters:

  • name (String)

    the rails application name



66
67
68
# File 'lib/datadog/core/environment/process.rb', line 66

def self.rails_application_name=(name)
  @rails_application_name = name
end

.serializedString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a comma-separated string of normalized key:value pairs. Includes svc.user or svc.auto based on whether the service was explicitly configured.

Returns:

  • (String)


16
17
18
# File 'lib/datadog/core/environment/process.rb', line 16

def self.serialized
  tags.join(",").freeze
end

.set_service(name, user_configured:) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Called via after_set on option :service in settings.rb whenever the service value changes.

Parameters:

  • name (String)

    the service name

  • user_configured (Boolean)

    whether the service was explicitly set by the user



58
59
60
61
# File 'lib/datadog/core/environment/process.rb', line 58

def self.set_service(name, user_configured:)
  @service_name = name
  @service_user_configured = user_configured
end

.tagsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns an array of normalized key:value pair strings. Includes svc.user or svc.auto based on whether the service was explicitly configured.

Returns:

  • (Array<String>)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/datadog/core/environment/process.rb', line 23

def self.tags
  tags = []

  workdir = TagNormalizer.normalize_process_value(entrypoint_workdir.to_s)
  tags << "#{Environment::Ext::TAG_ENTRYPOINT_WORKDIR}:#{workdir}" unless workdir.empty?

  entry_name = TagNormalizer.normalize_process_value(entrypoint_name.to_s)
  tags << "#{Environment::Ext::TAG_ENTRYPOINT_NAME}:#{entry_name}" unless entry_name.empty?

  basedir = TagNormalizer.normalize_process_value(entrypoint_basedir.to_s)
  tags << "#{Environment::Ext::TAG_ENTRYPOINT_BASEDIR}:#{basedir}" unless basedir.empty?

  tags << "#{Environment::Ext::TAG_ENTRYPOINT_TYPE}:#{TagNormalizer.normalize(entrypoint_type, remove_digit_start_char: false)}"

  if defined?(@rails_application_name)
    rails_name = TagNormalizer.normalize_process_value(@rails_application_name.to_s)
    tags << "#{Environment::Ext::TAG_RAILS_APPLICATION}:#{rails_name}" unless rails_name.empty?
  end

  if defined?(@service_user_configured)
    if @service_user_configured
      tags << "#{Environment::Ext::TAG_SVC_USER}:true"
    else
      svc = TagNormalizer.normalize_process_value(@service_name.to_s)
      tags << "#{Environment::Ext::TAG_SVC_AUTO}:#{svc}" unless svc.empty?
    end
  end

  tags.freeze
end