ddtrace 1.20.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +115 -1
  3. data/LICENSE-3rdparty.csv +1 -1
  4. data/bin/ddprofrb +15 -0
  5. data/bin/ddtracerb +3 -1
  6. data/ext/{ddtrace_profiling_loader/ddtrace_profiling_loader.c → datadog_profiling_loader/datadog_profiling_loader.c} +2 -2
  7. data/ext/{ddtrace_profiling_loader → datadog_profiling_loader}/extconf.rb +3 -3
  8. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_cpu_and_wall_time_worker.c +238 -61
  9. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_discrete_dynamic_sampler.c +145 -72
  10. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_discrete_dynamic_sampler.h +17 -5
  11. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.c +97 -4
  12. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/extconf.rb +2 -2
  13. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.c +45 -3
  14. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/heap_recorder.h +7 -1
  15. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c +15 -19
  16. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/native_extension_helpers.rb +4 -4
  17. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.c +14 -0
  18. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.h +4 -0
  19. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/profiling.c +1 -1
  20. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.c +10 -0
  21. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.h +2 -0
  22. data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/stack_recorder.c +7 -9
  23. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +43 -13
  24. data/lib/datadog/appsec/event.rb +1 -1
  25. data/lib/datadog/auto_instrument.rb +3 -0
  26. data/lib/datadog/core/configuration/components.rb +7 -6
  27. data/lib/datadog/core/configuration/option.rb +8 -6
  28. data/lib/datadog/core/configuration/settings.rb +130 -63
  29. data/lib/datadog/core/configuration.rb +20 -4
  30. data/lib/datadog/core/diagnostics/environment_logger.rb +4 -3
  31. data/lib/datadog/core/environment/git.rb +25 -0
  32. data/lib/datadog/core/environment/identity.rb +18 -48
  33. data/lib/datadog/core/environment/platform.rb +7 -1
  34. data/lib/datadog/core/git/ext.rb +2 -23
  35. data/lib/datadog/core/remote/client/capabilities.rb +1 -1
  36. data/lib/datadog/core/remote/negotiation.rb +2 -2
  37. data/lib/datadog/core/remote/transport/http/config.rb +1 -1
  38. data/lib/datadog/core/remote/worker.rb +7 -4
  39. data/lib/datadog/core/telemetry/client.rb +18 -10
  40. data/lib/datadog/core/telemetry/emitter.rb +9 -13
  41. data/lib/datadog/core/telemetry/event.rb +247 -57
  42. data/lib/datadog/core/telemetry/ext.rb +1 -0
  43. data/lib/datadog/core/telemetry/heartbeat.rb +1 -3
  44. data/lib/datadog/core/telemetry/http/ext.rb +4 -1
  45. data/lib/datadog/core/telemetry/http/transport.rb +9 -4
  46. data/lib/datadog/core/telemetry/request.rb +59 -0
  47. data/lib/datadog/core/transport/ext.rb +2 -0
  48. data/lib/datadog/core/utils/url.rb +25 -0
  49. data/lib/datadog/profiling/collectors/code_provenance.rb +10 -4
  50. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +31 -0
  51. data/lib/datadog/profiling/collectors/info.rb +101 -0
  52. data/lib/datadog/profiling/component.rb +34 -28
  53. data/lib/datadog/profiling/exporter.rb +19 -5
  54. data/lib/datadog/profiling/ext.rb +2 -0
  55. data/lib/datadog/profiling/flush.rb +6 -3
  56. data/lib/datadog/profiling/http_transport.rb +5 -1
  57. data/lib/datadog/profiling/load_native_extension.rb +19 -6
  58. data/lib/datadog/profiling/native_extension.rb +1 -1
  59. data/lib/datadog/profiling/tag_builder.rb +5 -0
  60. data/lib/datadog/profiling/tasks/exec.rb +3 -3
  61. data/lib/datadog/profiling/tasks/help.rb +3 -3
  62. data/lib/datadog/profiling.rb +13 -2
  63. data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +1 -1
  64. data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +11 -4
  65. data/lib/datadog/tracing/contrib/concurrent_ruby/async_patch.rb +20 -0
  66. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +11 -1
  67. data/lib/datadog/tracing/contrib/configurable.rb +1 -1
  68. data/lib/datadog/tracing/contrib/extensions.rb +6 -2
  69. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +11 -4
  70. data/lib/datadog/tracing/sampling/matcher.rb +23 -3
  71. data/lib/datadog/tracing/sampling/rule.rb +7 -2
  72. data/lib/datadog/tracing/sampling/rule_sampler.rb +2 -0
  73. data/lib/datadog/tracing/trace_operation.rb +1 -2
  74. data/lib/datadog/tracing/transport/http.rb +1 -0
  75. data/lib/datadog/tracing/transport/trace_formatter.rb +31 -0
  76. data/lib/ddtrace/version.rb +1 -1
  77. metadata +55 -62
  78. data/ext/ddtrace_profiling_native_extension/pid_controller.c +0 -57
  79. data/ext/ddtrace_profiling_native_extension/pid_controller.h +0 -45
  80. data/lib/datadog/core/telemetry/collector.rb +0 -250
  81. data/lib/datadog/core/telemetry/v1/app_event.rb +0 -59
  82. data/lib/datadog/core/telemetry/v1/application.rb +0 -92
  83. data/lib/datadog/core/telemetry/v1/configuration.rb +0 -25
  84. data/lib/datadog/core/telemetry/v1/dependency.rb +0 -43
  85. data/lib/datadog/core/telemetry/v1/host.rb +0 -59
  86. data/lib/datadog/core/telemetry/v1/install_signature.rb +0 -38
  87. data/lib/datadog/core/telemetry/v1/integration.rb +0 -64
  88. data/lib/datadog/core/telemetry/v1/product.rb +0 -36
  89. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +0 -106
  90. data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +0 -41
  91. data/lib/datadog/core/telemetry/v2/request.rb +0 -29
  92. data/lib/datadog/profiling/diagnostics/environment_logger.rb +0 -39
  93. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/NativeExtensionDesign.md +0 -0
  94. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id.h +0 -0
  95. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_from_pthread.c +0 -0
  96. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_noop.c +0 -0
  97. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.c +0 -0
  98. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.h +0 -0
  99. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_gc_profiling_helper.c +0 -0
  100. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_gc_profiling_helper.h +0 -0
  101. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.c +0 -0
  102. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.h +0 -0
  103. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.c +0 -0
  104. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.h +0 -0
  105. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.h +0 -0
  106. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/helpers.h +0 -0
  107. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/libdatadog_helpers.c +0 -0
  108. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/libdatadog_helpers.h +0 -0
  109. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.c +0 -0
  110. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.h +0 -0
  111. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/stack_recorder.h +0 -0
  112. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.c +0 -0
  113. /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/time_helpers.h +0 -0
@@ -1,250 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'etc'
4
-
5
- require_relative '../configuration/agent_settings_resolver'
6
- require_relative '../environment/ext'
7
- require_relative '../environment/platform'
8
- require_relative '../utils/hash'
9
- require_relative 'v1/application'
10
- require_relative 'v1/dependency'
11
- require_relative 'v1/host'
12
- require_relative 'v1/install_signature'
13
- require_relative 'v1/integration'
14
- require_relative 'v1/product'
15
- require_relative '../transport/ext'
16
-
17
- module Datadog
18
- module Core
19
- module Telemetry
20
- # Module defining methods for collecting metadata for telemetry
21
- module Collector
22
- include Datadog::Core::Configuration
23
- using Core::Utils::Hash::Refinement
24
-
25
- # Forms a hash of configuration key value pairs to be sent in the additional payload
26
- def additional_payload
27
- additional_payload_variables
28
- end
29
-
30
- # Forms a telemetry application object
31
- def application
32
- Telemetry::V1::Application.new(
33
- env: env,
34
- language_name: Datadog::Core::Environment::Ext::LANG,
35
- language_version: Datadog::Core::Environment::Ext::LANG_VERSION,
36
- products: products,
37
- runtime_name: Datadog::Core::Environment::Ext::RUBY_ENGINE,
38
- runtime_version: Datadog::Core::Environment::Ext::ENGINE_VERSION,
39
- service_name: service_name,
40
- service_version: service_version,
41
- tracer_version: library_version
42
- )
43
- end
44
-
45
- # Forms a hash of standard key value pairs to be sent in the app-started event configuration
46
- def configurations
47
- config = Datadog.configuration
48
- hash = {
49
- DD_AGENT_HOST: config.agent.host,
50
- DD_AGENT_TRANSPORT: agent_transport,
51
- DD_TRACE_SAMPLE_RATE: format_configuration_value(config.tracing.sampling.default_rate),
52
- DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: config.tracing.contrib.global_default_service_name.enabled
53
- }
54
- peer_service_mapping_str = ''
55
- unless config.tracing.contrib.peer_service_mapping.empty?
56
- peer_service_mapping = config.tracing.contrib.peer_service_mapping
57
- peer_service_mapping_str = peer_service_mapping.map { |key, value| "#{key}:#{value}" }.join(',')
58
- end
59
- hash[:DD_TRACE_PEER_SERVICE_MAPPING] = peer_service_mapping_str
60
- hash.compact!
61
- hash
62
- end
63
-
64
- # Forms a telemetry app-started dependencies object
65
- def dependencies
66
- Gem.loaded_specs.collect do |name, loaded_gem|
67
- Datadog::Core::Telemetry::V1::Dependency.new(
68
- # `hash` should be used when `version` is not available
69
- name: name, version: loaded_gem.version.to_s, hash: nil
70
- )
71
- end
72
- end
73
-
74
- # Forms a telemetry host object
75
- def host
76
- Telemetry::V1::Host.new(
77
- container_id: Core::Environment::Container.container_id,
78
- hostname: Core::Environment::Platform.hostname,
79
- kernel_name: Core::Environment::Platform.kernel_name,
80
- kernel_release: Core::Environment::Platform.kernel_release,
81
- kernel_version: Core::Environment::Platform.kernel_version
82
- )
83
- end
84
-
85
- # Forms a telemetry app-started install_signature object
86
- def install_signature
87
- Telemetry::V1::InstallSignature.new(
88
- install_id: Datadog.configuration.dig('telemetry', 'install_id'),
89
- install_type: Datadog.configuration.dig('telemetry', 'install_type'),
90
- install_time: Datadog.configuration.dig('telemetry', 'install_time'),
91
- )
92
- end
93
-
94
- # Forms a telemetry app-started integrations object
95
- def integrations
96
- Datadog.registry.map do |integration|
97
- is_instrumented = instrumented?(integration)
98
- is_enabled = is_instrumented && patched?(integration)
99
- Telemetry::V1::Integration.new(
100
- name: integration.name.to_s,
101
- enabled: is_enabled,
102
- version: integration_version(integration),
103
- compatible: integration_compatible?(integration),
104
- error: (patch_error(integration) if is_instrumented && !is_enabled),
105
- auto_enabled: is_enabled ? integration_auto_instrument?(integration) : nil
106
- )
107
- end
108
- end
109
-
110
- # Returns the runtime ID of the current process
111
- def runtime_id
112
- Datadog::Core::Environment::Identity.id
113
- end
114
-
115
- # Returns the current as a UNIX timestamp in seconds
116
- def tracer_time
117
- Time.now.to_i
118
- end
119
-
120
- private
121
-
122
- TARGET_OPTIONS = [
123
- 'ci.enabled',
124
- 'logger.level',
125
- 'profiling.advanced.code_provenance_enabled',
126
- 'profiling.advanced.endpoint.collection.enabled',
127
- 'profiling.enabled',
128
- 'runtime_metrics.enabled',
129
- 'tracing.analytics.enabled',
130
- 'tracing.distributed_tracing.propagation_inject_style',
131
- 'tracing.distributed_tracing.propagation_extract_style',
132
- 'tracing.enabled',
133
- 'tracing.log_injection',
134
- 'tracing.partial_flush.enabled',
135
- 'tracing.partial_flush.min_spans_threshold',
136
- 'tracing.priority_sampling',
137
- 'tracing.report_hostname',
138
- 'tracing.sampling.default_rate',
139
- 'tracing.sampling.rate_limit'
140
- ].freeze
141
-
142
- def additional_payload_variables
143
- # Whitelist of configuration options to send in additional payload object
144
- configuration = Datadog.configuration
145
- options = TARGET_OPTIONS.each_with_object({}) do |option, hash|
146
- split_option = option.split('.')
147
- hash[option] = format_configuration_value(configuration.dig(*split_option))
148
- end
149
-
150
- # Add some more custom additional payload values here
151
- options['tracing.auto_instrument.enabled'] = !defined?(Datadog::AutoInstrument::LOADED).nil?
152
- options['tracing.writer_options.buffer_size'] =
153
- format_configuration_value(configuration.tracing.writer_options[:buffer_size])
154
- options['tracing.writer_options.flush_interval'] =
155
- format_configuration_value(configuration.tracing.writer_options[:flush_interval])
156
- options['logger.instance'] = configuration.logger.instance.class.to_s
157
- options['appsec.enabled'] = configuration.dig('appsec', 'enabled') if configuration.respond_to?('appsec')
158
- options['tracing.opentelemetry.enabled'] = !defined?(Datadog::OpenTelemetry::LOADED).nil?
159
- options['tracing.opentracing.enabled'] = !defined?(Datadog::OpenTracer::LOADED).nil?
160
- options.compact!
161
- options
162
- end
163
-
164
- def format_configuration_value(value)
165
- # TODO: Add float if telemetry starts accepting it
166
- case value
167
- when Integer, String, true, false, nil
168
- value
169
- else
170
- value.to_s
171
- end
172
- end
173
-
174
- def env
175
- Datadog.configuration.env
176
- end
177
-
178
- def service_name
179
- Datadog.configuration.service
180
- end
181
-
182
- def service_version
183
- Datadog.configuration.version
184
- end
185
-
186
- def library_version
187
- Core::Environment::Identity.tracer_version
188
- end
189
-
190
- def products
191
- Telemetry::V1::Product.new(profiler: profiler, appsec: appsec)
192
- end
193
-
194
- def profiler
195
- { version: library_version }
196
- end
197
-
198
- def appsec
199
- { version: library_version }
200
- end
201
-
202
- def agent_transport
203
- adapter = Core::Configuration::AgentSettingsResolver.call(Datadog.configuration).adapter
204
- if adapter == Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
205
- 'UDS'
206
- else
207
- 'TCP'
208
- end
209
- end
210
-
211
- def instrumented_integrations
212
- Datadog.configuration.tracing.instrumented_integrations
213
- end
214
-
215
- def instrumented?(integration)
216
- instrumented_integrations.include?(integration.name)
217
- end
218
-
219
- def patched?(integration)
220
- !!integration.klass.patcher.patch_successful
221
- end
222
-
223
- def integration_auto_instrument?(integration)
224
- integration.klass.auto_instrument?
225
- end
226
-
227
- def integration_compatible?(integration)
228
- integration.klass.class.compatible?
229
- end
230
-
231
- def integration_version(integration)
232
- integration.klass.class.version ? integration.klass.class.version.to_s : nil
233
- end
234
-
235
- def patch_error(integration)
236
- patch_error_result = integration.klass.patcher.patch_error_result
237
- if patch_error_result.nil? # if no error occurred during patching, but integration is still not instrumented
238
- desc = "Available?: #{integration.klass.class.available?}"
239
- desc += ", Loaded? #{integration.klass.class.loaded?}"
240
- desc += ", Compatible? #{integration.klass.class.compatible?}"
241
- desc += ", Patchable? #{integration.klass.class.patchable?}"
242
- desc
243
- else
244
- patch_error_result.compact.to_s
245
- end
246
- end
247
- end
248
- end
249
- end
250
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes payload for telemetry V1 API app-integrations-change event
8
- class AppEvent
9
- attr_reader \
10
- :additional_payload,
11
- :configuration,
12
- :dependencies,
13
- :install_signature,
14
- :integrations
15
-
16
- # @param additional_payload [Array<Telemetry::V1::Configuration>] List of Additional payload to track (any key
17
- # value not mentioned and doesn't fit under a metric)
18
- # @param configuration [Array<Telemetry::V1::Configuration>] List of Tracer related configuration data
19
- # @param dependencies [Array<Telemetry::V1::Dependency>] List of all loaded modules requested by the app
20
- # @param install_signature [Telemetry::V1::InstallSignature] Install signature data
21
- # @param integrations [Array<Telemetry::V1::Integration>] List of integrations that are available within the app
22
- # and applicable to be traced
23
- def initialize(
24
- additional_payload: nil, configuration: nil, dependencies: nil, install_signature: nil,
25
- integrations: nil
26
- )
27
- @additional_payload = additional_payload
28
- @configuration = configuration
29
- @dependencies = dependencies
30
- @install_signature = install_signature
31
- @integrations = integrations
32
- end
33
-
34
- def to_h
35
- {}.tap do |hash|
36
- hash[:additional_payload] = map_hash(@additional_payload) if @additional_payload
37
- hash[:configuration] = map_hash(@configuration) if @configuration
38
- hash[:dependencies] = map_array(@dependencies) if @dependencies
39
- hash[:install_signature] = @install_signature.to_h if @install_signature
40
- hash[:integrations] = map_array(@integrations) if @integrations
41
- end
42
- end
43
-
44
- private
45
-
46
- def map_hash(hash)
47
- hash.map do |k, v|
48
- { name: k.to_s, value: v }
49
- end
50
- end
51
-
52
- def map_array(arr)
53
- arr.map(&:to_h)
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,92 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for application environment object
8
- class Application
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_LANGUAGE_NAME_MESSAGE = ':language_name must not be nil'.freeze
12
- ERROR_NIL_LANGUAGE_VERSION_MESSAGE = ':language_version must not be nil'.freeze
13
- ERROR_NIL_SERVICE_NAME_MESSAGE = ':service_name must not be nil'.freeze
14
- ERROR_NIL_TRACER_VERSION_MESSAGE = ':tracer_version must not be nil'.freeze
15
-
16
- attr_reader \
17
- :env,
18
- :language_name,
19
- :language_version,
20
- :products,
21
- :runtime_name,
22
- :runtime_patches,
23
- :runtime_version,
24
- :service_name,
25
- :service_version,
26
- :tracer_version
27
-
28
- # @param env [String] Service's environment
29
- # @param language_name [String] 'ruby'
30
- # @param language_version [String] Version of language used
31
- # @param products [Telemetry::V1::Product] Contains information about specific products added to the environment
32
- # @param runtime_name [String] Runtime being used
33
- # @param runtime_patches [String] String of patches applied to the runtime
34
- # @param runtime_version [String] Runtime version; potentially the same as :language_version
35
- # @param service_name [String] Service’s name (DD_SERVICE)
36
- # @param service_version [String] Service’s version (DD_VERSION)
37
- # @param tracer_version [String] Version of the used tracer
38
- def initialize(
39
- language_name:, language_version:, service_name:, tracer_version:, env: nil, products: nil,
40
- runtime_name: nil, runtime_patches: nil, runtime_version: nil, service_version: nil
41
- )
42
- validate(
43
- language_name: language_name,
44
- language_version: language_version,
45
- service_name: service_name,
46
- tracer_version: tracer_version
47
- )
48
- @env = env
49
- @language_name = language_name
50
- @language_version = language_version
51
- @products = products
52
- @runtime_name = runtime_name
53
- @runtime_patches = runtime_patches
54
- @runtime_version = runtime_version
55
- @service_name = service_name
56
- @service_version = service_version
57
- @tracer_version = tracer_version
58
- end
59
-
60
- def to_h
61
- hash = {
62
- env: @env,
63
- language_name: @language_name,
64
- language_version: @language_version,
65
- products: @products.to_h,
66
- runtime_name: @runtime_name,
67
- runtime_patches: @runtime_patches,
68
- runtime_version: @runtime_version,
69
- service_name: @service_name,
70
- service_version: @service_version,
71
- tracer_version: @tracer_version
72
- }
73
- hash.compact!
74
- hash
75
- end
76
-
77
- private
78
-
79
- # Validates required arguments passed to the class on initialization are not nil
80
- #
81
- # @!visibility private
82
- def validate(language_name:, language_version:, service_name:, tracer_version:)
83
- raise ArgumentError, ERROR_NIL_LANGUAGE_NAME_MESSAGE if language_name.nil?
84
- raise ArgumentError, ERROR_NIL_LANGUAGE_VERSION_MESSAGE if language_version.nil?
85
- raise ArgumentError, ERROR_NIL_SERVICE_NAME_MESSAGE if service_name.nil?
86
- raise ArgumentError, ERROR_NIL_TRACER_VERSION_MESSAGE if tracer_version.nil?
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,25 +0,0 @@
1
- module Datadog
2
- module Core
3
- module Telemetry
4
- module V1
5
- # Describes attributes for additional payload or configuration object
6
- class Configuration
7
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
8
-
9
- attr_reader \
10
- :name,
11
- :value
12
-
13
- # @param name [String] Configuration/additional payload attribute name
14
- # @param value [String, Integer, Boolean] Corresponding value
15
- def initialize(name:, value: nil)
16
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
17
-
18
- @name = name
19
- @value = value
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,43 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for dependency object
8
- class Dependency
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
12
-
13
- attr_reader \
14
- :hash,
15
- :name,
16
- :version
17
-
18
- # @param name [String] Module name
19
- # @param version [String] Version of resolved module
20
- # @param hash [String] Dependency hash, in case `version` is not available
21
- def initialize(name:, version: nil, hash: nil)
22
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
23
- raise ArgumentError, 'if both :version and :hash exist, use :version only' if version && hash
24
-
25
- @hash = hash
26
- @name = name
27
- @version = version
28
- end
29
-
30
- def to_h
31
- hash = {
32
- hash: @hash,
33
- name: @name,
34
- version: @version
35
- }
36
- hash.compact!
37
- hash
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../utils/hash'
4
-
5
- module Datadog
6
- module Core
7
- module Telemetry
8
- module V1
9
- # Describes attributes for host object
10
- class Host
11
- using Core::Utils::Hash::Refinement
12
-
13
- attr_reader \
14
- :container_id,
15
- :hostname,
16
- :kernel_name,
17
- :kernel_release,
18
- :kernel_version,
19
- :os_version,
20
- :os
21
-
22
- # @param container_id [String] Docker container ID
23
- # @param hostname [String] uname -n
24
- # @param kernel_name [String] uname -s
25
- # @param kernel_release [String] uname -r
26
- # @param kernel_version [String] uname -v
27
- # @param os [String] uname -o
28
- # @param os_version [String] Version of OS running
29
- def initialize(
30
- container_id: nil, hostname: nil, kernel_name: nil, kernel_release: nil, kernel_version: nil,
31
- os_version: nil, os: nil
32
- )
33
- @container_id = container_id
34
- @hostname = hostname
35
- @kernel_name = kernel_name
36
- @kernel_release = kernel_release
37
- @kernel_version = kernel_version
38
- @os = os
39
- @os_version = os_version
40
- end
41
-
42
- def to_h
43
- hash = {
44
- container_id: @container_id,
45
- hostname: @hostname,
46
- kernel_name: @kernel_name,
47
- kernel_release: @kernel_release,
48
- kernel_version: @kernel_version,
49
- os: @os,
50
- os_version: @os_version,
51
- }
52
- hash.compact!
53
- hash
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for install signature
8
- class InstallSignature
9
- using Core::Utils::Hash::Refinement
10
-
11
- attr_reader \
12
- :install_id,
13
- :install_type,
14
- :install_time
15
-
16
- # @param id [String,nil] Install ID
17
- # @param type [String,nil] Install type
18
- # @param type [String,nil] Install time
19
- def initialize(install_id:, install_type:, install_time:)
20
- @install_id = install_id
21
- @install_type = install_type
22
- @install_time = install_time
23
- end
24
-
25
- def to_h
26
- hash = {
27
- install_id: @install_id,
28
- install_type: @install_type,
29
- install_time: @install_time
30
- }
31
- hash.compact!
32
- hash
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,64 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for integration object
8
- class Integration
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_ENABLED_MESSAGE = ':enabled must not be nil'.freeze
12
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
13
-
14
- attr_reader \
15
- :auto_enabled,
16
- :compatible,
17
- :enabled,
18
- :error,
19
- :name,
20
- :version
21
-
22
- # @param enabled [Boolean] Whether integration is enabled at time of request
23
- # @param name [String] Integration name
24
- # @param auto_enabled [Boolean] If integration is not enabled by default, but by user choice
25
- # @param compatible [Boolean] If integration is available, but incompatible
26
- # @param error [String] Error message if integration fails to load
27
- # @param version [String] Integration version (if specified in app-started, it should be for other events too)
28
- def initialize(enabled:, name:, auto_enabled: nil, compatible: nil, error: nil, version: nil)
29
- validate(enabled: enabled, name: name)
30
- @auto_enabled = auto_enabled
31
- @compatible = compatible
32
- @enabled = enabled
33
- @error = error
34
- @name = name
35
- @version = version
36
- end
37
-
38
- def to_h
39
- hash = {
40
- auto_enabled: @auto_enabled,
41
- compatible: @compatible,
42
- enabled: @enabled,
43
- error: @error,
44
- name: @name,
45
- version: @version
46
- }
47
- hash.compact!
48
- hash
49
- end
50
-
51
- private
52
-
53
- # Validates all required arguments passed to the class on initialization are not nil
54
- #
55
- # @!visibility private
56
- def validate(enabled:, name:)
57
- raise ArgumentError, ERROR_NIL_ENABLED_MESSAGE if enabled.nil?
58
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../utils/hash'
4
-
5
- module Datadog
6
- module Core
7
- module Telemetry
8
- module V1
9
- # Describes attributes for products object
10
- class Product
11
- using Core::Utils::Hash::Refinement
12
-
13
- attr_reader \
14
- :appsec,
15
- :profiler
16
-
17
- # @param appsec [Telemetry::V1::AppSec] Holds custom information about the appsec product
18
- # @param profiler [Telemetry::V1::Profiler] Holds custom information about the profiler product
19
- def initialize(appsec: nil, profiler: nil)
20
- @appsec = appsec
21
- @profiler = profiler
22
- end
23
-
24
- def to_h
25
- hash = {
26
- appsec: @appsec,
27
- profiler: @profiler
28
- }
29
- hash.compact!
30
- hash
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end