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.

API:

  • private

Class Method Summary collapse

Class Method Details

.fixed_environment_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.

API:

  • private



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/datadog/core/tag_builder.rb', line 13

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.

API:

  • private



44
45
46
47
48
49
# File 'lib/datadog/core/tag_builder.rb', line 44

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.

API:

  • private



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/datadog/core/tag_builder.rb', line 26

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