-
Notifications
You must be signed in to change notification settings - Fork 381
/
Copy pathrequest.rb
59 lines (53 loc) · 1.81 KB
/
request.rb
1
2
3
4
5
6
7
8
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
49
50
51
52
53
54
55
56
57
58
59
# 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.tracer_version
}
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