Module: Datadog::Profiling::TagBuilder

Includes:
Ext::Transport::HTTP
Defined in:
lib/datadog/profiling/tag_builder.rb

Overview

Builds a hash of default plus user tags to be included in a profile

Constant Summary

Constants included from Ext::Transport::HTTP

Ext::Transport::HTTP::CODE_PROVENANCE_FILENAME, Ext::Transport::HTTP::FORM_FIELD_TAG_ENV, Ext::Transport::HTTP::FORM_FIELD_TAG_HOST, Ext::Transport::HTTP::FORM_FIELD_TAG_LANGUAGE, Ext::Transport::HTTP::FORM_FIELD_TAG_PID, Ext::Transport::HTTP::FORM_FIELD_TAG_PROFILER_VERSION, Ext::Transport::HTTP::FORM_FIELD_TAG_RUNTIME, Ext::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_ENGINE, Ext::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_ID, Ext::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_PLATFORM, Ext::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_VERSION, Ext::Transport::HTTP::FORM_FIELD_TAG_SERVICE, Ext::Transport::HTTP::FORM_FIELD_TAG_VERSION, Ext::Transport::HTTP::PPROF_DEFAULT_FILENAME

Class Method Summary collapse

Class Method Details

.call(settings:, env: settings.env, service: settings.service, version: settings.version, host: Core::Environment::Socket.hostname, language: Core::Environment::Identity.lang, pid: Process.pid.to_s, profiler_version: Core::Environment::Identity.tracer_version, runtime_engine: Core::Environment::Identity.lang_engine, runtime_id: Core::Environment::Identity.id, runtime_platform: Core::Environment::Identity.lang_platform, runtime_version: Core::Environment::Identity.lang_version, user_tags: settings.tags) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
# File 'lib/datadog/profiling/tag_builder.rb', line 9

def self.call(
  settings:,
  # Unified service tagging
  env: settings.env,
  service: settings.service,
  version: settings.version,
  # Other metadata
  host: Core::Environment::Socket.hostname,
  language: Core::Environment::Identity.lang,
  pid: Process.pid.to_s,
  profiler_version: Core::Environment::Identity.tracer_version,
  runtime_engine: Core::Environment::Identity.lang_engine,
  runtime_id: Core::Environment::Identity.id,
  runtime_platform: Core::Environment::Identity.lang_platform,
  runtime_version: Core::Environment::Identity.lang_version,
  # User-provided tags
  user_tags: settings.tags
)
  tags = {
    # When changing or adding these, make sure they are kept in sync with
    # https://docs.google.com/spreadsheets/d/1LOGMf4c4Avbtn36uZ2SWvhIGKRPLM1BoWkUP4JYj7hA/ (Datadog internal link)
    FORM_FIELD_TAG_HOST => host,
    FORM_FIELD_TAG_LANGUAGE => language,
    FORM_FIELD_TAG_PID => pid,
    FORM_FIELD_TAG_PROFILER_VERSION => profiler_version,
    FORM_FIELD_TAG_RUNTIME => language, # This is known to be repeated from language, above
    FORM_FIELD_TAG_RUNTIME_ENGINE => runtime_engine,
    FORM_FIELD_TAG_RUNTIME_ID => runtime_id,
    FORM_FIELD_TAG_RUNTIME_PLATFORM => runtime_platform,
    FORM_FIELD_TAG_RUNTIME_VERSION => runtime_version,
  }
  tags[FORM_FIELD_TAG_ENV] = env if env
  tags[FORM_FIELD_TAG_SERVICE] = service if service
  tags[FORM_FIELD_TAG_VERSION] = version if version

  # Make sure everything is an utf-8 string, to avoid encoding issues in native code/libddprof/further downstream
  user_tags.merge(tags).map do |key, value|
    [Datadog::Core::Utils.utf8_encode(key), Datadog::Core::Utils.utf8_encode(value)]
  end.to_h
end