datadog 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/ext/datadog_profiling_native_extension/encoded_profile.c +22 -12
- data/ext/datadog_profiling_native_extension/encoded_profile.h +1 -0
- data/ext/datadog_profiling_native_extension/http_transport.c +45 -72
- data/ext/datadog_profiling_native_extension/stack_recorder.c +4 -5
- data/ext/libdatadog_api/crashtracker.c +10 -3
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_extconf_helpers.rb +1 -1
- data/lib/datadog/appsec/api_security/lru_cache.rb +49 -0
- data/lib/datadog/appsec/api_security.rb +9 -0
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +5 -5
- data/lib/datadog/core/configuration/components.rb +29 -20
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/option.rb +18 -18
- data/lib/datadog/core/configuration/option_definition.rb +4 -4
- data/lib/datadog/core/configuration/options.rb +1 -1
- data/lib/datadog/core/configuration/settings.rb +10 -10
- data/lib/datadog/core/configuration.rb +16 -16
- data/lib/datadog/core/crashtracking/component.rb +2 -1
- data/lib/datadog/core/encoding.rb +1 -1
- data/lib/datadog/core/environment/cgroup.rb +10 -12
- data/lib/datadog/core/environment/container.rb +38 -40
- data/lib/datadog/core/environment/ext.rb +6 -6
- data/lib/datadog/core/environment/identity.rb +3 -3
- data/lib/datadog/core/environment/platform.rb +3 -3
- data/lib/datadog/core/error.rb +11 -9
- data/lib/datadog/core/logger.rb +2 -2
- data/lib/datadog/core/metrics/client.rb +12 -14
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client.rb +32 -31
- data/lib/datadog/core/remote/component.rb +3 -3
- data/lib/datadog/core/remote/configuration/digest.rb +7 -7
- data/lib/datadog/core/remote/configuration/path.rb +1 -1
- data/lib/datadog/core/remote/transport/http/client.rb +1 -1
- data/lib/datadog/core/remote/transport/http/config.rb +21 -5
- data/lib/datadog/core/remote/transport/http/negotiation.rb +1 -1
- data/lib/datadog/core/runtime/metrics.rb +3 -3
- data/lib/datadog/core/telemetry/component.rb +39 -24
- data/lib/datadog/core/telemetry/emitter.rb +7 -1
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +65 -0
- data/lib/datadog/core/telemetry/event/app_closing.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_dependencies_loaded.rb +33 -0
- data/lib/datadog/core/telemetry/event/app_heartbeat.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_integrations_change.rb +58 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +179 -0
- data/lib/datadog/core/telemetry/event/base.rb +40 -0
- data/lib/datadog/core/telemetry/event/distributions.rb +18 -0
- data/lib/datadog/core/telemetry/event/generate_metrics.rb +43 -0
- data/lib/datadog/core/telemetry/event/log.rb +76 -0
- data/lib/datadog/core/telemetry/event/message_batch.rb +42 -0
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +43 -0
- data/lib/datadog/core/telemetry/event.rb +17 -475
- data/lib/datadog/core/telemetry/logger.rb +1 -1
- data/lib/datadog/core/telemetry/metric.rb +3 -3
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +2 -2
- data/lib/datadog/core/telemetry/transport/telemetry.rb +0 -1
- data/lib/datadog/core/telemetry/worker.rb +48 -27
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/builder.rb +13 -13
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +6 -6
- data/lib/datadog/core/utils/duration.rb +32 -32
- data/lib/datadog/core/utils/forking.rb +2 -2
- data/lib/datadog/core/utils/network.rb +6 -6
- data/lib/datadog/core/utils/only_once_successful.rb +16 -5
- data/lib/datadog/core/utils/time.rb +10 -2
- data/lib/datadog/core/utils/truncation.rb +21 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +1 -1
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +8 -8
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +7 -7
- data/lib/datadog/core/worker.rb +1 -1
- data/lib/datadog/core/workers/async.rb +9 -10
- data/lib/datadog/error_tracking/component.rb +2 -2
- data/lib/datadog/profiling/collectors/code_provenance.rb +1 -1
- data/lib/datadog/profiling/ext.rb +0 -1
- data/lib/datadog/profiling/flush.rb +1 -1
- data/lib/datadog/profiling/http_transport.rb +1 -6
- data/lib/datadog/profiling/scheduler.rb +8 -1
- data/lib/datadog/profiling/tag_builder.rb +1 -5
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +33 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -4
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +1 -5
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/support.rb +28 -0
- data/lib/datadog/tracing/metadata/errors.rb +4 -4
- data/lib/datadog/version.rb +1 -1
- metadata +23 -6
@@ -6,8 +6,10 @@ require_relative '../utils/sequence'
|
|
6
6
|
module Datadog
|
7
7
|
module Core
|
8
8
|
module Telemetry
|
9
|
-
# Collection of telemetry events
|
10
|
-
|
9
|
+
# Collection of telemetry events.
|
10
|
+
#
|
11
|
+
# @api private
|
12
|
+
module Event
|
11
13
|
extend Core::Utils::Forking
|
12
14
|
|
13
15
|
# returns sequence that increments every time the configuration changes
|
@@ -15,480 +17,20 @@ module Datadog
|
|
15
17
|
after_fork! { @sequence = Datadog::Core::Utils::Sequence.new(1) }
|
16
18
|
@sequence ||= Datadog::Core::Utils::Sequence.new(1)
|
17
19
|
end
|
18
|
-
|
19
|
-
# Base class for all Telemetry V2 events.
|
20
|
-
class Base
|
21
|
-
# The type of the event.
|
22
|
-
# It must be one of the stings defined in the Telemetry V2
|
23
|
-
# specification for event names.
|
24
|
-
def type
|
25
|
-
raise NotImplementedError, 'Must be implemented by subclass'
|
26
|
-
end
|
27
|
-
|
28
|
-
# The JSON payload for the event.
|
29
|
-
def payload
|
30
|
-
{}
|
31
|
-
end
|
32
|
-
|
33
|
-
# Override equality to allow for deduplication
|
34
|
-
# The basic implementation is to check if the other object is an instance of the same class.
|
35
|
-
# This works for events that have no attributes.
|
36
|
-
# For events with attributes, you should override this method to compare the attributes.
|
37
|
-
def ==(other)
|
38
|
-
other.is_a?(self.class)
|
39
|
-
end
|
40
|
-
|
41
|
-
# @see #==
|
42
|
-
alias eql? ==
|
43
|
-
|
44
|
-
# @see #==
|
45
|
-
def hash
|
46
|
-
self.class.hash
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Telemetry class for the 'app-started' event
|
51
|
-
class AppStarted < Base
|
52
|
-
def type
|
53
|
-
'app-started'
|
54
|
-
end
|
55
|
-
|
56
|
-
def payload
|
57
|
-
{
|
58
|
-
products: products,
|
59
|
-
configuration: configuration,
|
60
|
-
install_signature: install_signature,
|
61
|
-
# DEV: Not implemented yet
|
62
|
-
# error: error, # Start-up errors
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def products
|
69
|
-
# @type var products: Hash[Symbol, Hash[Symbol, Object]]
|
70
|
-
products = {
|
71
|
-
appsec: {
|
72
|
-
enabled: Datadog::AppSec.enabled?,
|
73
|
-
},
|
74
|
-
profiler: {
|
75
|
-
enabled: Datadog::Profiling.enabled?,
|
76
|
-
},
|
77
|
-
dynamic_instrumentation: {
|
78
|
-
enabled: defined?(Datadog::DI) && Datadog::DI.respond_to?(:enabled?) && Datadog::DI.enabled?,
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
if (unsupported_reason = Datadog::Profiling.unsupported_reason)
|
83
|
-
products[:profiler][:error] = {
|
84
|
-
code: 1, # Error code. 0 if no error.
|
85
|
-
message: unsupported_reason,
|
86
|
-
}
|
87
|
-
end
|
88
|
-
|
89
|
-
products
|
90
|
-
end
|
91
|
-
|
92
|
-
TARGET_OPTIONS = %w[
|
93
|
-
dynamic_instrumentation.enabled
|
94
|
-
logger.level
|
95
|
-
profiling.advanced.code_provenance_enabled
|
96
|
-
profiling.advanced.endpoint.collection.enabled
|
97
|
-
profiling.enabled
|
98
|
-
runtime_metrics.enabled
|
99
|
-
tracing.analytics.enabled
|
100
|
-
tracing.propagation_style_extract
|
101
|
-
tracing.propagation_style_inject
|
102
|
-
tracing.enabled
|
103
|
-
tracing.log_injection
|
104
|
-
tracing.partial_flush.enabled
|
105
|
-
tracing.partial_flush.min_spans_threshold
|
106
|
-
tracing.report_hostname
|
107
|
-
tracing.sampling.rate_limit
|
108
|
-
].freeze
|
109
|
-
|
110
|
-
# rubocop:disable Metrics/AbcSize
|
111
|
-
# rubocop:disable Metrics/MethodLength
|
112
|
-
def configuration
|
113
|
-
config = Datadog.configuration
|
114
|
-
seq_id = Event.configuration_sequence.next
|
115
|
-
|
116
|
-
list = [
|
117
|
-
conf_value('DD_GIT_REPOSITORY_URL', Core::Environment::Git.git_repository_url, seq_id, 'env_var'),
|
118
|
-
conf_value('DD_GIT_COMMIT_SHA', Core::Environment::Git.git_commit_sha, seq_id, 'env_var'),
|
119
|
-
|
120
|
-
conf_value('DD_AGENT_HOST', config.agent.host, seq_id),
|
121
|
-
conf_value('DD_AGENT_TRANSPORT', agent_transport(config), seq_id),
|
122
|
-
conf_value('DD_TRACE_SAMPLE_RATE', to_value(config.tracing.sampling.default_rate), seq_id),
|
123
|
-
conf_value(
|
124
|
-
'DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED',
|
125
|
-
config.tracing.contrib.global_default_service_name.enabled,
|
126
|
-
seq_id
|
127
|
-
),
|
128
|
-
conf_value(
|
129
|
-
'DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED',
|
130
|
-
config.tracing.contrib.peer_service_defaults,
|
131
|
-
seq_id
|
132
|
-
),
|
133
|
-
]
|
134
|
-
|
135
|
-
peer_service_mapping_str = ''
|
136
|
-
unless config.tracing.contrib.peer_service_mapping.empty?
|
137
|
-
peer_service_mapping = config.tracing.contrib.peer_service_mapping
|
138
|
-
peer_service_mapping_str = peer_service_mapping.map { |key, value| "#{key}:#{value}" }.join(',')
|
139
|
-
end
|
140
|
-
list << conf_value('DD_TRACE_PEER_SERVICE_MAPPING', peer_service_mapping_str, seq_id)
|
141
|
-
|
142
|
-
# Whitelist of configuration options to send in additional payload object
|
143
|
-
TARGET_OPTIONS.each do |option|
|
144
|
-
split_option = option.split('.')
|
145
|
-
list << conf_value(option, to_value(config.dig(*split_option)), seq_id)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Add some more custom additional payload values here
|
149
|
-
list.push(
|
150
|
-
conf_value('tracing.auto_instrument.enabled', !defined?(Datadog::AutoInstrument::LOADED).nil?, seq_id),
|
151
|
-
conf_value(
|
152
|
-
'tracing.writer_options.buffer_size',
|
153
|
-
to_value(config.tracing.writer_options[:buffer_size]),
|
154
|
-
seq_id
|
155
|
-
),
|
156
|
-
conf_value(
|
157
|
-
'tracing.writer_options.flush_interval',
|
158
|
-
to_value(config.tracing.writer_options[:flush_interval]),
|
159
|
-
seq_id
|
160
|
-
),
|
161
|
-
conf_value(
|
162
|
-
'tracing.opentelemetry.enabled',
|
163
|
-
!defined?(Datadog::OpenTelemetry::LOADED).nil?,
|
164
|
-
seq_id
|
165
|
-
),
|
166
|
-
)
|
167
|
-
list << conf_value('logger.instance', config.logger.instance.class.to_s, seq_id) if config.logger.instance
|
168
|
-
if config.respond_to?('appsec')
|
169
|
-
list << conf_value('appsec.enabled', config.dig('appsec', 'enabled'), seq_id)
|
170
|
-
list << conf_value('appsec.sca_enabled', config.dig('appsec', 'sca_enabled'), seq_id)
|
171
|
-
end
|
172
|
-
list << conf_value('ci.enabled', config.dig('ci', 'enabled'), seq_id) if config.respond_to?('ci')
|
173
|
-
|
174
|
-
list.reject! { |entry| entry[:value].nil? }
|
175
|
-
list
|
176
|
-
end
|
177
|
-
# rubocop:enable Metrics/AbcSize
|
178
|
-
# rubocop:enable Metrics/MethodLength
|
179
|
-
|
180
|
-
def agent_transport(config)
|
181
|
-
adapter = Core::Configuration::AgentSettingsResolver.call(config).adapter
|
182
|
-
if adapter == Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
|
183
|
-
'UDS'
|
184
|
-
else
|
185
|
-
'TCP'
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def conf_value(name, value, seq_id, origin = 'code')
|
190
|
-
{
|
191
|
-
name: name,
|
192
|
-
value: value,
|
193
|
-
origin: origin,
|
194
|
-
seq_id: seq_id,
|
195
|
-
}
|
196
|
-
end
|
197
|
-
|
198
|
-
def to_value(value)
|
199
|
-
# TODO: Add float if telemetry starts accepting it
|
200
|
-
case value
|
201
|
-
when Integer, String, true, false, nil
|
202
|
-
value
|
203
|
-
else
|
204
|
-
value.to_s
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def install_signature
|
209
|
-
config = Datadog.configuration
|
210
|
-
{
|
211
|
-
install_id: config.dig('telemetry', 'install_id'),
|
212
|
-
install_type: config.dig('telemetry', 'install_type'),
|
213
|
-
install_time: config.dig('telemetry', 'install_time'),
|
214
|
-
}
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# Telemetry class for the 'app-dependencies-loaded' event
|
219
|
-
class AppDependenciesLoaded < Base
|
220
|
-
def type
|
221
|
-
'app-dependencies-loaded'
|
222
|
-
end
|
223
|
-
|
224
|
-
def payload
|
225
|
-
{ dependencies: dependencies }
|
226
|
-
end
|
227
|
-
|
228
|
-
private
|
229
|
-
|
230
|
-
def dependencies
|
231
|
-
Gem.loaded_specs.collect do |name, gem|
|
232
|
-
{
|
233
|
-
name: name,
|
234
|
-
version: gem.version.to_s,
|
235
|
-
# hash: nil,
|
236
|
-
}
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
# Telemetry class for the 'app-integrations-change' event
|
242
|
-
class AppIntegrationsChange < Base
|
243
|
-
def type
|
244
|
-
'app-integrations-change'
|
245
|
-
end
|
246
|
-
|
247
|
-
def payload
|
248
|
-
{ integrations: integrations }
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
|
253
|
-
def integrations
|
254
|
-
instrumented_integrations = Datadog.configuration.tracing.instrumented_integrations
|
255
|
-
Datadog.registry.map do |integration|
|
256
|
-
is_instrumented = instrumented_integrations.include?(integration.name)
|
257
|
-
|
258
|
-
is_enabled = is_instrumented ? !!integration.klass.patcher.patch_successful : false
|
259
|
-
|
260
|
-
version = integration.klass.class.version ? integration.klass.class.version.to_s : nil
|
261
|
-
|
262
|
-
res = {
|
263
|
-
name: integration.name.to_s,
|
264
|
-
enabled: is_enabled,
|
265
|
-
version: version,
|
266
|
-
compatible: integration.klass.class.compatible?,
|
267
|
-
error: (patch_error(integration) if is_instrumented && !is_enabled),
|
268
|
-
# TODO: Track if integration is instrumented by manual configuration or by auto instrumentation
|
269
|
-
# auto_enabled: is_enabled && ???,
|
270
|
-
}
|
271
|
-
res.reject! { |_, v| v.nil? }
|
272
|
-
res
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
def patch_error(integration)
|
277
|
-
patch_error_result = integration.klass.patcher.patch_error_result
|
278
|
-
return patch_error_result.compact.to_s if patch_error_result
|
279
|
-
|
280
|
-
# If no error occurred during patching, but integration is still not instrumented
|
281
|
-
"Available?: #{integration.klass.class.available?}" \
|
282
|
-
", Loaded? #{integration.klass.class.loaded?}" \
|
283
|
-
", Compatible? #{integration.klass.class.compatible?}" \
|
284
|
-
", Patchable? #{integration.klass.class.patchable?}"
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
# Telemetry class for the 'app-client-configuration-change' event
|
289
|
-
class AppClientConfigurationChange < Base
|
290
|
-
attr_reader :changes, :origin
|
291
|
-
|
292
|
-
def type
|
293
|
-
'app-client-configuration-change'
|
294
|
-
end
|
295
|
-
|
296
|
-
def initialize(changes, origin)
|
297
|
-
super()
|
298
|
-
@changes = changes
|
299
|
-
@origin = origin
|
300
|
-
end
|
301
|
-
|
302
|
-
def payload
|
303
|
-
{ configuration: configuration }
|
304
|
-
end
|
305
|
-
|
306
|
-
def configuration
|
307
|
-
config = Datadog.configuration
|
308
|
-
seq_id = Event.configuration_sequence.next
|
309
|
-
|
310
|
-
res = @changes.map do |name, value|
|
311
|
-
{
|
312
|
-
name: name,
|
313
|
-
value: value,
|
314
|
-
origin: @origin,
|
315
|
-
seq_id: seq_id,
|
316
|
-
}
|
317
|
-
end
|
318
|
-
|
319
|
-
unless config.dig('appsec', 'sca_enabled').nil?
|
320
|
-
res << {
|
321
|
-
name: 'appsec.sca_enabled',
|
322
|
-
value: config.appsec.sca_enabled,
|
323
|
-
origin: 'code',
|
324
|
-
seq_id: seq_id,
|
325
|
-
}
|
326
|
-
end
|
327
|
-
|
328
|
-
res
|
329
|
-
end
|
330
|
-
|
331
|
-
def ==(other)
|
332
|
-
other.is_a?(AppClientConfigurationChange) && other.changes == @changes && other.origin == @origin
|
333
|
-
end
|
334
|
-
|
335
|
-
alias eql? ==
|
336
|
-
|
337
|
-
def hash
|
338
|
-
[self.class, @changes, @origin].hash
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
# Telemetry class for the 'app-heartbeat' event
|
343
|
-
class AppHeartbeat < Base
|
344
|
-
def type
|
345
|
-
'app-heartbeat'
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
# Telemetry class for the 'app-closing' event
|
350
|
-
class AppClosing < Base
|
351
|
-
def type
|
352
|
-
'app-closing'
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
# Telemetry class for the 'generate-metrics' event
|
357
|
-
class GenerateMetrics < Base
|
358
|
-
attr_reader :namespace, :metric_series
|
359
|
-
|
360
|
-
def type
|
361
|
-
'generate-metrics'
|
362
|
-
end
|
363
|
-
|
364
|
-
def initialize(namespace, metric_series)
|
365
|
-
super()
|
366
|
-
@namespace = namespace
|
367
|
-
@metric_series = metric_series
|
368
|
-
end
|
369
|
-
|
370
|
-
def payload
|
371
|
-
{
|
372
|
-
namespace: @namespace,
|
373
|
-
series: @metric_series.map(&:to_h)
|
374
|
-
}
|
375
|
-
end
|
376
|
-
|
377
|
-
def ==(other)
|
378
|
-
other.is_a?(GenerateMetrics) && other.namespace == @namespace && other.metric_series == @metric_series
|
379
|
-
end
|
380
|
-
|
381
|
-
alias eql? ==
|
382
|
-
|
383
|
-
def hash
|
384
|
-
[self.class, @namespace, @metric_series].hash
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
# Telemetry class for the 'logs' event.
|
389
|
-
# Logs with the same content are deduplicated at flush time.
|
390
|
-
class Log < Base
|
391
|
-
LEVELS = {
|
392
|
-
error: 'ERROR',
|
393
|
-
warn: 'WARN',
|
394
|
-
}.freeze
|
395
|
-
|
396
|
-
LEVELS_STRING = LEVELS.values.freeze
|
397
|
-
|
398
|
-
attr_reader :message, :level, :stack_trace, :count
|
399
|
-
|
400
|
-
def type
|
401
|
-
'logs'
|
402
|
-
end
|
403
|
-
|
404
|
-
# @param message [String] the log message
|
405
|
-
# @param level [Symbol, String] the log level. Either :error, :warn, 'ERROR', or 'WARN'.
|
406
|
-
# @param stack_trace [String, nil] the stack trace
|
407
|
-
# @param count [Integer] the number of times the log was emitted. Used for deduplication.
|
408
|
-
def initialize(message:, level:, stack_trace: nil, count: 1)
|
409
|
-
super()
|
410
|
-
@message = message
|
411
|
-
@stack_trace = stack_trace
|
412
|
-
|
413
|
-
if level.is_a?(String) && LEVELS_STRING.include?(level)
|
414
|
-
# String level is used during object copy for deduplication
|
415
|
-
@level = level
|
416
|
-
elsif level.is_a?(Symbol)
|
417
|
-
# Symbol level is used by the regular log emitter user
|
418
|
-
@level = LEVELS.fetch(level) { |k| raise ArgumentError, "Invalid log level :#{k}" }
|
419
|
-
else
|
420
|
-
raise ArgumentError, "Invalid log level #{level}"
|
421
|
-
end
|
422
|
-
|
423
|
-
@count = count
|
424
|
-
end
|
425
|
-
|
426
|
-
def payload
|
427
|
-
{
|
428
|
-
logs: [
|
429
|
-
{
|
430
|
-
message: @message,
|
431
|
-
level: @level,
|
432
|
-
stack_trace: @stack_trace,
|
433
|
-
count: @count,
|
434
|
-
}.compact
|
435
|
-
]
|
436
|
-
}
|
437
|
-
end
|
438
|
-
|
439
|
-
# override equality to allow for deduplication
|
440
|
-
def ==(other)
|
441
|
-
other.is_a?(Log) &&
|
442
|
-
other.message == @message &&
|
443
|
-
other.level == @level && other.stack_trace == @stack_trace && other.count == @count
|
444
|
-
end
|
445
|
-
|
446
|
-
alias eql? ==
|
447
|
-
|
448
|
-
def hash
|
449
|
-
[self.class, @message, @level, @stack_trace, @count].hash
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
|
-
# Telemetry class for the 'distributions' event
|
454
|
-
class Distributions < GenerateMetrics
|
455
|
-
def type
|
456
|
-
'distributions'
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
# Telemetry class for the 'message-batch' event
|
461
|
-
class MessageBatch
|
462
|
-
attr_reader :events
|
463
|
-
|
464
|
-
def type
|
465
|
-
'message-batch'
|
466
|
-
end
|
467
|
-
|
468
|
-
def initialize(events)
|
469
|
-
@events = events
|
470
|
-
end
|
471
|
-
|
472
|
-
def payload
|
473
|
-
@events.map do |event|
|
474
|
-
{
|
475
|
-
request_type: event.type,
|
476
|
-
payload: event.payload,
|
477
|
-
}
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
def ==(other)
|
482
|
-
other.is_a?(MessageBatch) && other.events == @events
|
483
|
-
end
|
484
|
-
|
485
|
-
alias eql? ==
|
486
|
-
|
487
|
-
def hash
|
488
|
-
[self.class, @events].hash
|
489
|
-
end
|
490
|
-
end
|
491
20
|
end
|
492
21
|
end
|
493
22
|
end
|
494
23
|
end
|
24
|
+
|
25
|
+
require_relative 'event/base'
|
26
|
+
require_relative 'event/app_client_configuration_change'
|
27
|
+
require_relative 'event/app_closing'
|
28
|
+
require_relative 'event/app_dependencies_loaded'
|
29
|
+
require_relative 'event/app_heartbeat'
|
30
|
+
require_relative 'event/app_integrations_change'
|
31
|
+
require_relative 'event/app_started'
|
32
|
+
require_relative 'event/synth_app_client_configuration_change'
|
33
|
+
require_relative 'event/generate_metrics'
|
34
|
+
require_relative 'event/distributions'
|
35
|
+
require_relative 'event/log'
|
36
|
+
require_relative 'event/message_batch'
|
@@ -35,7 +35,7 @@ module Datadog
|
|
35
35
|
# The downside is: this leaves us unable to report telemetry during component initialization.
|
36
36
|
components = Datadog.send(:components, allow_initialization: false)
|
37
37
|
|
38
|
-
if components
|
38
|
+
if components&.telemetry
|
39
39
|
components.telemetry
|
40
40
|
else
|
41
41
|
Datadog.logger.warn(
|
@@ -20,7 +20,7 @@ module Datadog
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def id
|
23
|
-
@id ||= "#{type}::#{name}::#{tags.join(
|
23
|
+
@id ||= "#{type}::#{name}::#{tags.join(",")}"
|
24
24
|
end
|
25
25
|
|
26
26
|
def track(value)
|
@@ -47,7 +47,7 @@ module Datadog
|
|
47
47
|
values == other.values && tags == other.tags && common == other.common && type == other.type
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
alias_method :eql?, :==
|
51
51
|
|
52
52
|
def hash
|
53
53
|
[self.class, name, values, tags, common, type].hash
|
@@ -88,7 +88,7 @@ module Datadog
|
|
88
88
|
super && interval == other.interval
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
alias_method :eql?, :==
|
92
92
|
|
93
93
|
def hash
|
94
94
|
[super, interval].hash
|
@@ -64,11 +64,11 @@ module Datadog
|
|
64
64
|
super
|
65
65
|
end
|
66
66
|
|
67
|
-
def headers(request_type:, api_version: 'v2'
|
67
|
+
def headers(request_type:, api_key:, api_version: 'v2')
|
68
68
|
{
|
69
69
|
Core::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST => '1',
|
70
70
|
# Provided by encoder
|
71
|
-
#'Content-Type' => 'application/json',
|
71
|
+
# 'Content-Type' => 'application/json',
|
72
72
|
'DD-Telemetry-API-Version' => api_version,
|
73
73
|
'DD-Telemetry-Request-Type' => request_type,
|
74
74
|
'DD-Client-Library-Language' => Core::Environment::Ext::LANG,
|