Sha256: 3a05bcc97b00c437512687138d16cbd6421c8edf0f6a91ae9d3e7af9edf8c98c

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require_relative '../environment/platform'
require_relative '../utils/hash'

module Datadog
  module Core
    module Telemetry
      # Module defining methods for collecting metadata for telemetry
      module Request
        class << self
          using Core::Utils::Hash::Refinement

          def build_payload(event, seq_id)
            hash = {
              api_version: Http::Ext::API_VERSION,
              application: application,
              debug: false,
              host: host,
              payload: event.payload(seq_id),
              request_type: event.type,
              runtime_id: Core::Environment::Identity.id,
              seq_id: seq_id,
              tracer_time: Time.now.to_i,
            }
            hash.compact!
            hash
          end

          private

          def application
            config = Datadog.configuration
            {
              env: config.env,
              language_name: Core::Environment::Ext::LANG,
              language_version: Core::Environment::Ext::LANG_VERSION,
              runtime_name: Core::Environment::Ext::RUBY_ENGINE,
              runtime_version: Core::Environment::Ext::ENGINE_VERSION,
              service_name: config.service,
              service_version: config.version,
              tracer_version: Core::Environment::Identity.gem_datadog_version_semver2
            }
          end

          def host
            {
              architecture: Core::Environment::Platform.architecture,
              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
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datadog-2.1.0 lib/datadog/core/telemetry/request.rb
datadog-2.0.0 lib/datadog/core/telemetry/request.rb
datadog-2.0.0.beta2 lib/datadog/core/telemetry/request.rb