Module: Datadog::Core::TagBuilder Private

Defined in:
lib/datadog/core/tag_builder.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.

This module builds a hash of tags.

When changing or adding the tags, make sure they are kept in sync with docs.google.com/spreadsheets/d/1LOGMf4c4Avbtn36uZ2SWvhIGKRPLM1BoWkUP4JYj7hA/ (Datadog internal link).

Class Method Summary collapse

Class Method Details

.fixed_environment_tagsObject

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.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/datadog/core/tag_builder.rb', line 17

def self.fixed_environment_tags
  @fixed_environment_tags ||= {
    'language' => Environment::Identity.lang,
    'runtime' => Environment::Identity.lang, # Known to be duplicated from language above
    'runtime_engine' => Environment::Identity.lang_engine,
    'runtime_platform' => Environment::Identity.lang_platform,
    'runtime_version' => Environment::Identity.lang_version,
    'library_version' => Environment::Identity.gem_datadog_version,
    'git.repository_url' => Environment::Git.git_repository_url,
    'git.commit.sha' => Environment::Git.git_commit_sha,
  }.compact.freeze
end

.serialize_tags(tags) ⇒ Object

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.



48
49
50
51
52
53
# File 'lib/datadog/core/tag_builder.rb', line 48

def self.serialize_tags(tags)
  # DEV: Should there be some sort of escaping done here?
  tags.map do |key, value|
    "#{key}:#{value}"
  end.join(',')
end

.tags(settings) ⇒ Object

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.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/datadog/core/tag_builder.rb', line 30

def self.tags(settings)
  # Note that user tags get overwritten by our tags, and also
  # that user tags do not get compacted (nil values are sent as
  # empty strings).
  settings.tags.merge(fixed_environment_tags).merge({
    # Hostname can possibly change during application runtime.
    'host' => Environment::Socket.hostname,
    # Runtime ID changes upon a fork.
    'runtime-id' => Environment::Identity.id,
    # Process ID changes upon a fork.
    'process_id' => Process.pid.to_s,
    # Unified service tagging.
    'env' => settings.env,
    'service' => settings.service,
    'version' => settings.version,
  }.compact)
end