Module: Datadog::Core::Telemetry::Collector

Includes:
Configuration
Included in:
Event
Defined in:
lib/datadog/core/telemetry/collector.rb

Overview

Module defining methods for collecting metadata for telemetry

Instance Attribute Summary

Attributes included from Configuration

#configuration

Instance Method Summary collapse

Methods included from Configuration

#configuration_for, #configure, #configure_onto, #health_metrics, #logger, #shutdown!

Instance Method Details

#additional_payloadObject

Forms a hash of configuration key value pairs to be sent in the additional payload



23
24
25
# File 'lib/datadog/core/telemetry/collector.rb', line 23

def additional_payload
  additional_payload_variables
end

#applicationObject

Forms a telemetry application object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datadog/core/telemetry/collector.rb', line 28

def application
  Telemetry::V1::Application.new(
    env: env,
    language_name: Datadog::Core::Environment::Ext::LANG,
    language_version: Datadog::Core::Environment::Ext::LANG_VERSION,
    products: products,
    runtime_name: Datadog::Core::Environment::Ext::RUBY_ENGINE,
    runtime_version: Datadog::Core::Environment::Ext::ENGINE_VERSION,
    service_name: service_name,
    service_version: service_version,
    tracer_version: library_version
  )
end

#configurationsObject

Forms a hash of standard key value pairs to be sent in the app-started event configuration



43
44
45
46
47
48
49
50
# File 'lib/datadog/core/telemetry/collector.rb', line 43

def configurations
  configurations = {
    DD_AGENT_HOST: Datadog.configuration.agent.host,
    DD_AGENT_TRANSPORT: agent_transport,
    DD_TRACE_SAMPLE_RATE: format_configuration_value(Datadog.configuration.tracing.sampling.default_rate),
  }
  compact_hash(configurations)
end

#dependenciesObject

Forms a telemetry app-started dependencies object



53
54
55
56
57
58
59
# File 'lib/datadog/core/telemetry/collector.rb', line 53

def dependencies
  Gem.loaded_specs.collect do |name, loaded_gem|
    Datadog::Core::Telemetry::V1::Dependency.new(
      name: name, version: loaded_gem.version.to_s, hash: loaded_gem.hash.to_s
    )
  end
end

#hostObject

Forms a telemetry host object



62
63
64
65
66
67
68
69
70
# File 'lib/datadog/core/telemetry/collector.rb', line 62

def host
  Telemetry::V1::Host.new(
    container_id: Core::Environment::Container.container_id,
    hostname: Core::Environment::Platform.hostname,
    kernel_name: Core::Environment::Platform.kernel_name,
    kernel_release: Core::Environment::Platform.kernel_release,
    kernel_version: Core::Environment::Platform.kernel_version
  )
end

#integrationsObject

Forms a telemetry app-started integrations object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/datadog/core/telemetry/collector.rb', line 73

def integrations
  Datadog.registry.map do |integration|
    is_instrumented = instrumented?(integration)
    is_enabled = is_instrumented && patched?(integration)
    Telemetry::V1::Integration.new(
      name: integration.name.to_s,
      enabled: is_enabled,
      version: integration_version(integration),
      compatible: integration_compatible?(integration),
      error: (patch_error(integration) if is_instrumented && !is_enabled),
      auto_enabled: is_enabled ? integration_auto_instrument?(integration) : nil
    )
  end
end

#runtime_idObject

Returns the runtime ID of the current process



89
90
91
# File 'lib/datadog/core/telemetry/collector.rb', line 89

def runtime_id
  Datadog::Core::Environment::Identity.id
end

#tracer_timeObject

Returns the current as a UNIX timestamp in seconds



94
95
96
# File 'lib/datadog/core/telemetry/collector.rb', line 94

def tracer_time
  Time.now.to_i
end