datadog 2.48.0 → 2.49.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.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -1
  3. data/ext/datadog_profiling_native_extension/collectors_stack.c +1 -1
  4. data/ext/datadog_profiling_native_extension/collectors_stack.h +4 -2
  5. data/ext/datadog_profiling_native_extension/extconf.rb +3 -0
  6. data/ext/datadog_profiling_native_extension/private_vm_api_access.c +13 -21
  7. data/ext/libdatadog_api/extconf.rb +2 -0
  8. data/ext/libdatadog_api/feature_flags.c +137 -0
  9. data/ext/libdatadog_api/process_discovery.c +3 -3
  10. data/ext/libdatadog_extconf_helpers.rb +1 -1
  11. data/lib/datadog/ai_guard/contrib/rack/patcher.rb +3 -5
  12. data/lib/datadog/ai_guard/contrib/rails/patcher.rb +7 -9
  13. data/lib/datadog/ai_guard/contrib/ruby_llm/patcher.rb +3 -5
  14. data/lib/datadog/ai_guard/metrics/telemetry.rb +2 -4
  15. data/lib/datadog/appsec/actions_handler.rb +5 -7
  16. data/lib/datadog/appsec/api_security/endpoint_collection/grape_route_serializer.rb +1 -3
  17. data/lib/datadog/appsec/api_security/endpoint_collection/rails_route_serializer.rb +1 -3
  18. data/lib/datadog/appsec/api_security/endpoint_collection/sinatra_route_serializer.rb +1 -3
  19. data/lib/datadog/appsec/assets.rb +8 -10
  20. data/lib/datadog/appsec/configuration.rb +1 -1
  21. data/lib/datadog/appsec/context.rb +63 -6
  22. data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +1 -3
  23. data/lib/datadog/appsec/contrib/active_record/patcher.rb +21 -24
  24. data/lib/datadog/appsec/contrib/aws_lambda/patcher.rb +3 -5
  25. data/lib/datadog/appsec/contrib/aws_lambda/waf_addresses.rb +9 -11
  26. data/lib/datadog/appsec/contrib/devise/configuration.rb +2 -4
  27. data/lib/datadog/appsec/contrib/devise/patcher.rb +3 -5
  28. data/lib/datadog/appsec/contrib/excon/patcher.rb +3 -5
  29. data/lib/datadog/appsec/contrib/faraday/patcher.rb +4 -6
  30. data/lib/datadog/appsec/contrib/graphql/patcher.rb +3 -5
  31. data/lib/datadog/appsec/contrib/rack/input_peeker.rb +3 -5
  32. data/lib/datadog/appsec/contrib/rack/patcher.rb +3 -5
  33. data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +5 -4
  34. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +6 -7
  35. data/lib/datadog/appsec/contrib/rails/patcher.rb +19 -16
  36. data/lib/datadog/appsec/contrib/rails/patches/live_thread_patch.rb +33 -0
  37. data/lib/datadog/appsec/contrib/rest_client/patcher.rb +3 -5
  38. data/lib/datadog/appsec/contrib/sinatra/patcher.rb +4 -6
  39. data/lib/datadog/appsec/default_header_tags.rb +2 -4
  40. data/lib/datadog/appsec/metrics/exporter.rb +4 -6
  41. data/lib/datadog/appsec/metrics/telemetry.rb +1 -3
  42. data/lib/datadog/appsec/metrics/telemetry_exporter.rb +2 -4
  43. data/lib/datadog/appsec/route_normalizer/route_text.rb +1 -3
  44. data/lib/datadog/appsec/route_normalizer.rb +4 -6
  45. data/lib/datadog/appsec/utils/http/body_reader.rb +3 -5
  46. data/lib/datadog/appsec/utils/http/url_encoded.rb +2 -4
  47. data/lib/datadog/core/borrowing_token_bucket.rb +60 -0
  48. data/lib/datadog/core/chunker.rb +1 -3
  49. data/lib/datadog/core/configuration/components.rb +48 -17
  50. data/lib/datadog/core/configuration/settings.rb +2 -1
  51. data/lib/datadog/core/configuration/supported_configurations.rb +2 -0
  52. data/lib/datadog/core/diagnostics/environment_logger.rb +1 -6
  53. data/lib/datadog/core/encoding.rb +8 -12
  54. data/lib/datadog/core/environment/cgroup.rb +3 -5
  55. data/lib/datadog/core/environment/container.rb +9 -11
  56. data/lib/datadog/core/environment/ext.rb +1 -6
  57. data/lib/datadog/core/environment/gc.rb +2 -4
  58. data/lib/datadog/core/environment/identity.rb +13 -15
  59. data/lib/datadog/core/environment/platform.rb +10 -12
  60. data/lib/datadog/core/environment/socket.rb +3 -5
  61. data/lib/datadog/core/environment/thread_count.rb +2 -4
  62. data/lib/datadog/core/environment/variable_helpers.rb +2 -6
  63. data/lib/datadog/core/environment/vm_cache.rb +5 -7
  64. data/lib/datadog/core/environment/yjit.rb +25 -24
  65. data/lib/datadog/core/logger.rb +5 -2
  66. data/lib/datadog/core/metrics/client.rb +8 -16
  67. data/lib/datadog/core/metrics/helpers.rb +3 -0
  68. data/lib/datadog/core/metrics/metric.rb +3 -1
  69. data/lib/datadog/core/rate_limiter.rb +9 -31
  70. data/lib/datadog/core/refillable_bucket.rb +72 -0
  71. data/lib/datadog/core/remote/client/capabilities.rb +4 -0
  72. data/lib/datadog/core/remote/client.rb +1 -5
  73. data/lib/datadog/core/remote/transport/http.rb +2 -4
  74. data/lib/datadog/core/tag_normalizer.rb +0 -2
  75. data/lib/datadog/core/telemetry/configuration_value.rb +1 -3
  76. data/lib/datadog/core/telemetry/transport/http.rb +2 -4
  77. data/lib/datadog/core/telemetry/worker.rb +30 -24
  78. data/lib/datadog/core/transport/http.rb +2 -4
  79. data/lib/datadog/core/utils/at_fork_monkey_patch.rb +2 -2
  80. data/lib/datadog/core/utils/forking.rb +1 -1
  81. data/lib/datadog/core/utils/lru_cache.rb +2 -2
  82. data/lib/datadog/core/utils/network.rb +1 -1
  83. data/lib/datadog/core/utils/time.rb +2 -2
  84. data/lib/datadog/core/utils/truncation.rb +1 -3
  85. data/lib/datadog/core/workers/async.rb +16 -14
  86. data/lib/datadog/core/workers/runtime_metrics.rb +1 -1
  87. data/lib/datadog/data_streams/transport/http.rb +1 -3
  88. data/lib/datadog/di/component.rb +14 -2
  89. data/lib/datadog/di/context.rb +50 -0
  90. data/lib/datadog/di/contrib.rb +2 -2
  91. data/lib/datadog/di/correlation_sampler/trace_budget.rb +75 -0
  92. data/lib/datadog/di/correlation_sampler/trace_budget_ledger/entry.rb +34 -0
  93. data/lib/datadog/di/correlation_sampler/trace_budget_ledger.rb +104 -0
  94. data/lib/datadog/di/correlation_sampler.rb +224 -0
  95. data/lib/datadog/di/guardrails_telemetry/reason.rb +8 -3
  96. data/lib/datadog/di/instrumenter.rb +294 -109
  97. data/lib/datadog/di/probe.rb +13 -2
  98. data/lib/datadog/di/probe_builder.rb +6 -8
  99. data/lib/datadog/di/probe_file_loader.rb +2 -2
  100. data/lib/datadog/di/probe_manager.rb +7 -30
  101. data/lib/datadog/di/probe_notification_builder.rb +42 -11
  102. data/lib/datadog/di/probe_notifier_worker.rb +11 -0
  103. data/lib/datadog/di/snapshot_pruner/node.rb +190 -0
  104. data/lib/datadog/di/snapshot_pruner/node_queue.rb +104 -0
  105. data/lib/datadog/di/snapshot_pruner/parser.rb +102 -0
  106. data/lib/datadog/di/snapshot_pruner.rb +128 -0
  107. data/lib/datadog/di/transport/input.rb +75 -15
  108. data/lib/datadog/di/utils.rb +3 -3
  109. data/lib/datadog/di.rb +29 -0
  110. data/lib/datadog/error_tracking/filters.rb +6 -8
  111. data/lib/datadog/open_feature/agentless/parser.rb +2 -4
  112. data/lib/datadog/open_feature/component.rb +24 -2
  113. data/lib/datadog/open_feature/configuration.rb +13 -0
  114. data/lib/datadog/open_feature/evaluation_engine.rb +5 -5
  115. data/lib/datadog/open_feature/exposure_hook.rb +146 -0
  116. data/lib/datadog/open_feature/exposures/event.rb +10 -8
  117. data/lib/datadog/open_feature/exposures/reporter.rb +34 -25
  118. data/lib/datadog/open_feature/ext.rb +12 -0
  119. data/lib/datadog/open_feature/flag_evaluation/aggregator.rb +10 -8
  120. data/lib/datadog/open_feature/flag_evaluation/writer.rb +9 -6
  121. data/lib/datadog/open_feature/hooks/exposure_logging_hook.rb +58 -0
  122. data/lib/datadog/open_feature/hooks/flag_eval_evp_hook.rb +4 -2
  123. data/lib/datadog/open_feature/hooks/flag_eval_metrics_hook.rb +3 -5
  124. data/lib/datadog/open_feature/hooks/span_enrichment_hook/codec.rb +3 -5
  125. data/lib/datadog/open_feature/native_evaluator.rb +30 -2
  126. data/lib/datadog/open_feature/noop_evaluator.rb +3 -1
  127. data/lib/datadog/open_feature/provider.rb +54 -4
  128. data/lib/datadog/open_feature/resolution_details.rb +1 -0
  129. data/lib/datadog/open_feature/split_features.rb +76 -0
  130. data/lib/datadog/opentelemetry/sdk/propagator.rb +5 -2
  131. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +28 -31
  132. data/lib/datadog/profiling/component.rb +31 -9
  133. data/lib/datadog/profiling/profiler.rb +6 -0
  134. data/lib/datadog/profiling/remote.rb +381 -0
  135. data/lib/datadog/profiling/worker_state.rb +65 -0
  136. data/lib/datadog/profiling.rb +1 -0
  137. data/lib/datadog/symbol_database/file_hash.rb +1 -3
  138. data/lib/datadog/tracing/component.rb +14 -16
  139. data/lib/datadog/tracing/configuration/settings.rb +2 -2
  140. data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +4 -6
  141. data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +4 -6
  142. data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +4 -6
  143. data/lib/datadog/tracing/contrib/action_cable/events.rb +3 -5
  144. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -4
  145. data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +5 -7
  146. data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +4 -6
  147. data/lib/datadog/tracing/contrib/action_mailer/events.rb +3 -5
  148. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -4
  149. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -4
  150. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -4
  151. data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +2 -4
  152. data/lib/datadog/tracing/contrib/action_pack/action_dispatch/patcher.rb +2 -4
  153. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -4
  154. data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +3 -5
  155. data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +3 -5
  156. data/lib/datadog/tracing/contrib/action_view/events.rb +3 -5
  157. data/lib/datadog/tracing/contrib/action_view/patcher.rb +3 -5
  158. data/lib/datadog/tracing/contrib/action_view/utils.rb +1 -3
  159. data/lib/datadog/tracing/contrib/active_job/events/discard.rb +3 -5
  160. data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +3 -5
  161. data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +3 -5
  162. data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +3 -5
  163. data/lib/datadog/tracing/contrib/active_job/events/perform.rb +3 -5
  164. data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +3 -5
  165. data/lib/datadog/tracing/contrib/active_job/events.rb +3 -5
  166. data/lib/datadog/tracing/contrib/active_job/patcher.rb +4 -6
  167. data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +4 -6
  168. data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +4 -6
  169. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +3 -5
  170. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +3 -5
  171. data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +4 -6
  172. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +3 -5
  173. data/lib/datadog/tracing/contrib/active_record/events.rb +3 -5
  174. data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -4
  175. data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +8 -10
  176. data/lib/datadog/tracing/contrib/active_support/cache/events.rb +3 -5
  177. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +5 -7
  178. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -6
  179. data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -4
  180. data/lib/datadog/tracing/contrib/analytics.rb +4 -6
  181. data/lib/datadog/tracing/contrib/aws/patcher.rb +5 -7
  182. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +5 -7
  183. data/lib/datadog/tracing/contrib/configuration/settings.rb +17 -0
  184. data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -4
  185. data/lib/datadog/tracing/contrib/dalli/quantize.rb +1 -3
  186. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +4 -6
  187. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +3 -5
  188. data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +6 -8
  189. data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -4
  190. data/lib/datadog/tracing/contrib/excon/patcher.rb +3 -5
  191. data/lib/datadog/tracing/contrib/faraday/patcher.rb +4 -6
  192. data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -4
  193. data/lib/datadog/tracing/contrib/graphql/patcher.rb +4 -6
  194. data/lib/datadog/tracing/contrib/graphql/trace_patcher.rb +1 -3
  195. data/lib/datadog/tracing/contrib/graphql/tracing_patcher.rb +1 -3
  196. data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +1 -3
  197. data/lib/datadog/tracing/contrib/grpc/patcher.rb +3 -5
  198. data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -4
  199. data/lib/datadog/tracing/contrib/http/patcher.rb +2 -4
  200. data/lib/datadog/tracing/contrib/httpclient/patcher.rb +2 -4
  201. data/lib/datadog/tracing/contrib/httprb/patcher.rb +2 -4
  202. data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +4 -6
  203. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +3 -5
  204. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +3 -5
  205. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +3 -5
  206. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +2 -4
  207. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +2 -4
  208. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +2 -4
  209. data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +4 -6
  210. data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +4 -6
  211. data/lib/datadog/tracing/contrib/kafka/events.rb +3 -5
  212. data/lib/datadog/tracing/contrib/kafka/patcher.rb +4 -6
  213. data/lib/datadog/tracing/contrib/karafka/patcher.rb +2 -4
  214. data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -4
  215. data/lib/datadog/tracing/contrib/mongodb/parsers.rb +5 -7
  216. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +3 -5
  217. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +3 -5
  218. data/lib/datadog/tracing/contrib/opensearch/patcher.rb +1 -3
  219. data/lib/datadog/tracing/contrib/opensearch/quantize.rb +5 -7
  220. data/lib/datadog/tracing/contrib/pg/patcher.rb +3 -5
  221. data/lib/datadog/tracing/contrib/presto/patcher.rb +1 -3
  222. data/lib/datadog/tracing/contrib/que/patcher.rb +2 -4
  223. data/lib/datadog/tracing/contrib/racecar/events/batch.rb +3 -5
  224. data/lib/datadog/tracing/contrib/racecar/events/consume.rb +3 -5
  225. data/lib/datadog/tracing/contrib/racecar/events/message.rb +3 -5
  226. data/lib/datadog/tracing/contrib/racecar/events.rb +3 -5
  227. data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -4
  228. data/lib/datadog/tracing/contrib/rack/patcher.rb +13 -19
  229. data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -3
  230. data/lib/datadog/tracing/contrib/rack/route_inference.rb +4 -6
  231. data/lib/datadog/tracing/contrib/rack/trace_proxy_middleware.rb +4 -6
  232. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +4 -0
  233. data/lib/datadog/tracing/contrib/rails/ext.rb +2 -0
  234. data/lib/datadog/tracing/contrib/rails/framework.rb +6 -8
  235. data/lib/datadog/tracing/contrib/rails/log_injection.rb +1 -3
  236. data/lib/datadog/tracing/contrib/rails/patcher.rb +9 -11
  237. data/lib/datadog/tracing/contrib/rake/patcher.rb +3 -5
  238. data/lib/datadog/tracing/contrib/redis/patcher.rb +2 -4
  239. data/lib/datadog/tracing/contrib/redis/quantize.rb +7 -9
  240. data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -4
  241. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -4
  242. data/lib/datadog/tracing/contrib/roda/patcher.rb +2 -4
  243. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -4
  244. data/lib/datadog/tracing/contrib/sequel/patcher.rb +4 -6
  245. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -4
  246. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +7 -9
  247. data/lib/datadog/tracing/contrib/sinatra/env.rb +3 -5
  248. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +5 -7
  249. data/lib/datadog/tracing/contrib/sneakers/patcher.rb +2 -4
  250. data/lib/datadog/tracing/contrib/stripe/patcher.rb +2 -4
  251. data/lib/datadog/tracing/contrib/stripe/request.rb +4 -6
  252. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +1 -3
  253. data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +1 -3
  254. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +3 -5
  255. data/lib/datadog/tracing/contrib/support.rb +1 -3
  256. data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +4 -0
  257. data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +2 -1
  258. data/lib/datadog/tracing/contrib/trilogy/patcher.rb +3 -5
  259. data/lib/datadog/tracing/contrib/utils/database.rb +1 -3
  260. data/lib/datadog/tracing/contrib/utils/quantization/hash_formatter.rb +8 -10
  261. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +11 -13
  262. data/lib/datadog/tracing/contrib/waterdrop/patcher.rb +3 -5
  263. data/lib/datadog/tracing/correlation.rb +3 -5
  264. data/lib/datadog/tracing/distributed/propagation.rb +2 -2
  265. data/lib/datadog/tracing/distributed/propagation_policy.rb +1 -3
  266. data/lib/datadog/tracing/distributed/trace_state/datadog.rb +5 -5
  267. data/lib/datadog/tracing/distributed/trace_state/open_telemetry.rb +2 -2
  268. data/lib/datadog/tracing/metadata/ext.rb +3 -9
  269. data/lib/datadog/tracing/remote.rb +1 -1
  270. data/lib/datadog/tracing/trace_operation.rb +11 -3
  271. data/lib/datadog/tracing/tracer.rb +9 -1
  272. data/lib/datadog/tracing/transport/http.rb +1 -3
  273. data/lib/datadog/tracing/transport/io.rb +2 -4
  274. data/lib/datadog/tracing/transport/traces.rb +1 -3
  275. data/lib/datadog/tracing/utils.rb +4 -6
  276. data/lib/datadog/version.rb +1 -1
  277. metadata +22 -6
@@ -0,0 +1,381 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../core/remote/dispatcher"
5
+ require_relative "../core/tag_normalizer"
6
+ require_relative "../core/telemetry/configuration_value"
7
+ require_relative "../core/utils/enumerable_compat"
8
+
9
+ module Datadog
10
+ module Profiling
11
+ # Applies profiling configuration delivered through Remote Configuration, following the APM_PROFILING schema:
12
+ # domains/remote-config/shared/libs/config-validator/schemas/APM_PROFILING/root.json in dd-source.
13
+ # Every omitted field keeps the local value.
14
+ #
15
+ # @api private
16
+ module Remote
17
+ PRODUCTS = ["APM_PROFILING"].freeze
18
+
19
+ BOOLEAN = ->(value) { value == true || value == false }
20
+ INTEGER = ->(value) { value.is_a?(Integer) }
21
+
22
+ # Ruby has no separate CPU and wall time toggles, as the CpuAndWallTimeWorker always collects
23
+ # both, so they only count towards enablement. Other profilers in the schema (locks, exceptions)
24
+ # have no Ruby equivalent and are ignored.
25
+ PROFILER_FIELDS = {
26
+ "cpuTime" => BOOLEAN,
27
+ "wallTime" => BOOLEAN,
28
+ "heapObjects" => BOOLEAN,
29
+ "heapSize" => BOOLEAN,
30
+ "allocations" => BOOLEAN,
31
+ }.freeze
32
+
33
+ SETTING_FIELDS = {
34
+ "maxStackDepth" => INTEGER,
35
+ "rubySignalWorkaround" => BOOLEAN,
36
+ }.freeze
37
+
38
+ # How long the remote-config worker thread waits for the profiler to start. It normally starts within
39
+ # milliseconds, and failing to start ends the wait right away.
40
+ START_TIMEOUT_SECONDS = 1
41
+
42
+ # Target specificity levels, from the least to the most specific: other tags, env, service, then the
43
+ # infrastructure tags the Datadog agent assigns, from deployments to containers.
44
+ OTHER_TAGS_LEVEL = 1
45
+ ENV_LEVEL = 2
46
+ SERVICE_LEVEL = 3
47
+ LEVEL_BY_TAG_NAME = {
48
+ 4 => [
49
+ "kube_deployment", "kube_replica_set", "kube_stateful_set", "kube_daemon_set", "kube_job", "kube_cronjob",
50
+ "kube_argo_rollout", "oshift_deployment", "task_family",
51
+ ],
52
+ 5 => ["kube_container_name", "container_name", "ecs_container_name"],
53
+ 6 => ["pod_name", "task_arn"],
54
+ 7 => ["container_id"],
55
+ }.flat_map { |level, names| names.map { |name| [name, level] } }.to_h.freeze
56
+ # A target's level outranks any number of conditions, which only break ties within a level.
57
+ CONDITIONS_PER_LEVEL = 1000
58
+
59
+ class << self
60
+ def products
61
+ PRODUCTS
62
+ end
63
+
64
+ def receivers(telemetry)
65
+ matcher = Core::Remote::Dispatcher::Matcher::Product.new(products)
66
+ receiver = Core::Remote::Dispatcher::Receiver.new(matcher, initial_reconcile: true) do |repository, _changes|
67
+ apply_configs(repository, telemetry)
68
+ end
69
+ [receiver]
70
+ end
71
+
72
+ # The RC repository prunes deleted configs, so this recomputes the result from all of its
73
+ # current contents on each dispatch.
74
+ #
75
+ # Runs on the remote-config worker thread; never raises.
76
+ def apply_configs(repository, telemetry)
77
+ settings = Datadog.configuration
78
+
79
+ # @type var parsed: Array[[Core::Remote::Configuration::Content, Array[String], config?]]
80
+ parsed = Core::Utils::EnumerableCompat.filter_map(repository.contents) do |content|
81
+ parse_content(content) if PRODUCTS.include?(content.path.product)
82
+ end
83
+ configs = Core::Utils::EnumerableCompat.filter_map(parsed) { |_content, _problems, config| config }
84
+
85
+ profilers, remote_settings = merge(configs, settings)
86
+ values = to_values(profilers, remote_settings, local_profilers(settings))
87
+ apply_values(settings, values, telemetry)
88
+ error = profiler_error(settings) unless parsed.empty?
89
+
90
+ # Only once applied: RC does not dispatch unchanged content again, so acknowledging it
91
+ # earlier would hide a failure to apply it.
92
+ parsed.each do |content, problems, _config|
93
+ if error
94
+ content.errored(error)
95
+ else
96
+ acknowledge(content, problems)
97
+ end
98
+ end
99
+ nil
100
+ rescue => e
101
+ Datadog.logger.debug { "Profiling RC: failed to apply configs: #{e.class}: #{e.message}" }
102
+ telemetry&.report(e, description: "Failed to apply profiling remote configs")
103
+ parsed&.each do |content, _problems, _config|
104
+ content.errored("#{e.class}: #{e.message}: #{Array(e.backtrace).join("\n")}")
105
+ end
106
+ nil
107
+ end
108
+
109
+ private
110
+
111
+ # Returns the content, the problems found in it, and its config, which is nil when it is invalid or all of
112
+ # its targets are.
113
+ def parse_content(content)
114
+ payload = parse_json(content)
115
+ return [content, ["not a JSON object with profilers"], nil] unless payload.is_a?(Hash) && payload.key?("profilers")
116
+
117
+ problems = []
118
+ profilers = parse_fields(payload["profilers"], "profilers", PROFILER_FIELDS, problems, required: true)
119
+ settings = parse_fields(payload["settings"], "settings", SETTING_FIELDS, problems)
120
+ targets = parse_targets(payload["targets"], problems)
121
+
122
+ # @type var config: config?
123
+ config = {id: content.path.config_id, targets: targets, profilers: profilers, settings: settings} if targets
124
+ [content, problems, config]
125
+ end
126
+
127
+ # The profiler builder logs failures instead of raising them, so this checks that it built one. The
128
+ # worker starts on its own thread, so it can also fail later, e.g. when another gem uses SIGPROF.
129
+ def profiler_error(settings)
130
+ return unless settings.profiling.enabled
131
+
132
+ components = Datadog.send(:components, allow_initialization: false)
133
+ profiler = components&.profiler
134
+ return components&.profiler_unavailable_reason unless profiler
135
+
136
+ failure = profiler.wait_for_start_or_failure(timeout_seconds: START_TIMEOUT_SECONDS)
137
+ "Profiling failed to start: #{failure.class}: #{failure.message}" if failure
138
+ end
139
+
140
+ # Invalid fields are reported as an error without preventing the valid ones from applying.
141
+ def acknowledge(content, problems)
142
+ if problems.empty?
143
+ content.applied
144
+ else
145
+ reason = problems.join("; ")
146
+ Datadog.logger.debug { "Profiling RC: invalid configuration #{content.path.config_id}: #{reason}" }
147
+ content.errored(reason)
148
+ end
149
+ end
150
+
151
+ def parse_json(content)
152
+ JSON.parse(content.data)
153
+ rescue JSON::ParserError
154
+ nil
155
+ end
156
+
157
+ def parse_fields(section, section_name, fields, problems, required: false)
158
+ parsed = {}
159
+ unless section.is_a?(Hash)
160
+ problems << "#{section_name} is not an object" if required || !section.nil?
161
+ return parsed
162
+ end
163
+
164
+ fields.each do |name, valid|
165
+ value = section[name]
166
+ next if value.nil?
167
+
168
+ if valid.call(value)
169
+ parsed[name] = value
170
+ else
171
+ problems << "#{section_name}.#{name} has an invalid value"
172
+ end
173
+ end
174
+ parsed
175
+ end
176
+
177
+ # An absent targets list matches every tracer.
178
+ def parse_targets(targets, problems)
179
+ return [] if targets.nil?
180
+
181
+ unless targets.is_a?(Array)
182
+ problems << "targets is not an array"
183
+ return
184
+ end
185
+
186
+ parsed = []
187
+ targets.each_with_index do |target, index|
188
+ if valid_target?(target)
189
+ parsed << {service: target["service"], env: target["env"], tags: target["tags"] || []}
190
+ else
191
+ problems << "targets[#{index}] is invalid"
192
+ end
193
+ end
194
+
195
+ # An all-invalid list must not be treated as matching every tracer.
196
+ if parsed.empty? && !targets.empty?
197
+ problems << "no valid targets"
198
+ return
199
+ end
200
+
201
+ parsed
202
+ end
203
+
204
+ def valid_target?(target)
205
+ return false unless target.is_a?(Hash)
206
+
207
+ service = target["service"]
208
+ env = target["env"]
209
+ tags = target["tags"] || []
210
+
211
+ (service.nil? || service.is_a?(String)) &&
212
+ (env.nil? || env.is_a?(String)) &&
213
+ tags.is_a?(Array) && tags.all?(String)
214
+ end
215
+
216
+ # Merges the configs field by field, with the most specific target winning. Ties are broken by config
217
+ # id, so the result doesn't depend on delivery order. The backend only delivers configs that apply to
218
+ # this tracer, so they are all merged; their targets only rank them.
219
+ def merge(configs, settings)
220
+ # Same service as the RC client registers with, which is what the backend targets.
221
+ service = Core::TagNormalizer.normalize(settings.remote.service || settings.service)
222
+ env = Core::TagNormalizer.normalize(settings.env)
223
+
224
+ # @type var ranked: Array[[Integer, config]]
225
+ ranked = configs.map do |config|
226
+ specificity = specificity(config[:targets], service, env)
227
+ Datadog.logger.debug { "Profiling RC: config #{config[:id]} specificity=#{specificity}" }
228
+ [specificity, config]
229
+ end
230
+
231
+ profilers = {}
232
+ remote_settings = {}
233
+ ranked.sort_by { |specificity, config| [specificity, config[:id]] }.each do |_specificity, config|
234
+ profilers.merge!(config[:profilers])
235
+ remote_settings.merge!(config[:settings])
236
+ end
237
+ [profilers, remote_settings]
238
+ end
239
+
240
+ # Specificity of the most specific target consistent with this tracer's service and env, or 0.
241
+ def specificity(targets, service, env)
242
+ targets.map { |target| target_specificity(target, service, env) }.max || 0
243
+ end
244
+
245
+ # A target ranks by its most specific condition, then by its number of conditions, or 0 if its service
246
+ # or env differs from this tracer's. A service or env counts only when present and not "*".
247
+ #
248
+ # Tag conditions are assumed to hold: the backend matches them against the tags reported by the RC
249
+ # client, the container tags the agent adds and the agent's host tags, which the tracer can't all see.
250
+ # A tracer without an env doesn't know the agent's env it inherits, so env targets rank 0 for it. The
251
+ # agent and the backend compare normalized services and envs, so both sides are normalized here too.
252
+ def target_specificity(target, service, env)
253
+ has_service = !target[:service].nil? && target[:service] != "*"
254
+ has_env = !target[:env].nil? && target[:env] != "*"
255
+ return 0 if has_service && Core::TagNormalizer.normalize(target[:service]) != service
256
+ return 0 if has_env && Core::TagNormalizer.normalize(target[:env]) != env
257
+
258
+ level =
259
+ if has_service
260
+ SERVICE_LEVEL
261
+ elsif has_env
262
+ ENV_LEVEL
263
+ else
264
+ 0
265
+ end
266
+ target[:tags].each do |tag|
267
+ name = tag.split(":", 2).first.to_s.downcase
268
+ level = [level, LEVEL_BY_TAG_NAME.fetch(name, OTHER_TAGS_LEVEL)].max
269
+ end
270
+ conditions = (has_service ? 1 : 0) + (has_env ? 1 : 0) + target[:tags].size
271
+
272
+ level * CONDITIONS_PER_LEVEL + conditions
273
+ end
274
+
275
+ def to_values(profilers, settings, local_profilers)
276
+ enabled =
277
+ if profilers.value?(true)
278
+ true
279
+ # Ruby can't turn off some of the profilers it runs while keeping the others, so profiling is
280
+ # only disabled when all of them are turned off.
281
+ elsif local_profilers.all? { |name| profilers[name] == false }
282
+ false
283
+ end
284
+
285
+ heap_size = profilers["heapSize"]
286
+ # experimental_heap_enabled collects heap live objects, and heap live size needs it too.
287
+ heap_enabled = (heap_size == true) || profilers["heapObjects"]
288
+ # Heap profiling tracks sampled allocations, so it needs allocation profiling, even over an
289
+ # explicit allocations: false.
290
+ allocation_enabled = (heap_enabled == true) || profilers["allocations"]
291
+
292
+ {
293
+ enabled: enabled,
294
+ allocation_enabled: allocation_enabled,
295
+ experimental_heap_enabled: heap_enabled,
296
+ experimental_heap_size_enabled: heap_size,
297
+ max_frames: settings["maxStackDepth"],
298
+ # false keeps the local value, :auto by default, instead of forcing signals even with gems
299
+ # that :auto detects as incompatible with them.
300
+ no_signals_workaround_enabled: (true if settings["rubySignalWorkaround"] == true),
301
+ }
302
+ end
303
+
304
+ def apply_values(settings, values, telemetry)
305
+ options = remote_options(settings)
306
+ before = options.map { |object, name| remote_value(object, name) }
307
+
308
+ # @type var env_vars: Array[[String, Core::Telemetry::Event::telemetry_value]]
309
+ env_vars = options.map do |object, name|
310
+ value = values[name]
311
+ apply_option(object, name, value)
312
+ [option_env_var(object, name), Core::Telemetry::ConfigurationValue.convert(value)]
313
+ end
314
+
315
+ changed = options.map { |object, name| remote_value(object, name) } != before
316
+ return unless changed
317
+
318
+ Datadog.logger.debug { "Profiling RC: applying #{values}" }
319
+ telemetry&.client_configuration_change!(env_vars)
320
+ Core::Configuration::Components.reconfigure_profiler
321
+ end
322
+
323
+ def remote_options(settings)
324
+ profiling = settings.profiling
325
+ advanced = profiling.advanced
326
+ [
327
+ [profiling, :enabled],
328
+ [profiling, :allocation_enabled],
329
+ [advanced, :experimental_heap_enabled],
330
+ [advanced, :experimental_heap_size_enabled],
331
+ [advanced, :max_frames],
332
+ [advanced, :no_signals_workaround_enabled],
333
+ ]
334
+ end
335
+
336
+ # The same name as the app-started telemetry event reports for this option.
337
+ def option_env_var(object, name)
338
+ object.class.options.fetch(name).env.to_s
339
+ end
340
+
341
+ # The profilers the local settings run when profiling is enabled.
342
+ def local_profilers(settings)
343
+ profiling = settings.profiling
344
+ advanced = profiling.advanced
345
+ heap = local_value(advanced, :experimental_heap_enabled)
346
+
347
+ profilers = ["cpuTime", "wallTime"]
348
+ profilers << "allocations" if local_value(profiling, :allocation_enabled)
349
+ profilers << "heapObjects" if heap
350
+ profilers << "heapSize" if heap && local_value(advanced, :experimental_heap_size_enabled)
351
+ profilers
352
+ end
353
+
354
+ # The value without the remote one, which apply_values is about to replace.
355
+ def local_value(object, name)
356
+ object.get_option(name) # Builds the option, like using_default? does
357
+ remote = Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION
358
+ values = object.options.fetch(name).values_per_precedence
359
+ values.reject { |precedence, _| precedence == remote }.max_by(&:first)&.last
360
+ end
361
+
362
+ # The value remote configuration set, which telemetry reports even when it equals the local value.
363
+ def remote_value(object, name)
364
+ object.get_option(name) # Builds the option, like using_default? does
365
+ object.options.fetch(name).values_per_precedence[Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION]
366
+ end
367
+
368
+ # nil unsets the remote value, falling back to whatever the customer configured locally.
369
+ def apply_option(object, name, value)
370
+ precedence = Core::Configuration::Option::Precedence::REMOTE_CONFIGURATION
371
+
372
+ if value.nil?
373
+ object.unset_option(name, precedence: precedence)
374
+ else
375
+ object.set_option(name, value, precedence: precedence)
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Profiling
5
+ # Thread-safe helper, used to watch for success vs failure for a background worker thread.
6
+ class WorkerState
7
+ # @rbs @mutex: Thread::Mutex
8
+ # @rbs @condition: Thread::ConditionVariable
9
+ # @rbs @running: bool
10
+ # @rbs @failure: Exception?
11
+
12
+ #: () -> void
13
+ def initialize
14
+ @mutex = Mutex.new
15
+ @condition = ConditionVariable.new
16
+ @running = false
17
+ @failure = nil
18
+ end
19
+
20
+ #: () -> void
21
+ def running!
22
+ @mutex.synchronize do
23
+ @running = true
24
+ @condition.broadcast
25
+ end
26
+ end
27
+
28
+ # @rbs failure: Exception
29
+ # @rbs return: void
30
+ def failed!(failure)
31
+ @mutex.synchronize do
32
+ @failure = failure
33
+ @condition.broadcast
34
+ end
35
+ end
36
+
37
+ #: () -> void
38
+ def reset!
39
+ @mutex.synchronize do
40
+ @running = false
41
+ @failure = nil
42
+ end
43
+ end
44
+
45
+ #: () -> Exception?
46
+ def failure
47
+ @mutex.synchronize { @failure }
48
+ end
49
+
50
+ # Waits until the worker runs or fails, and returns its failure, :running, or :not_started on timeout.
51
+ # @rbs timeout_seconds: Integer?
52
+ # @rbs return: Exception | :running | :not_started
53
+ def wait(timeout_seconds)
54
+ @mutex.synchronize do
55
+ @condition.wait(@mutex, timeout_seconds) unless @running || @failure
56
+
57
+ failure = @failure
58
+ return failure if failure
59
+
60
+ return @running ? :running : :not_started
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -142,6 +142,7 @@ module Datadog
142
142
  require_relative "profiling/ext/dir_monkey_patches"
143
143
  require_relative "profiling/collectors/info"
144
144
  require_relative "profiling/collectors/code_provenance"
145
+ require_relative "profiling/worker_state"
145
146
  require_relative "profiling/collectors/cpu_and_wall_time_worker"
146
147
  require_relative "profiling/collectors/dynamic_sampling_rate"
147
148
  require_relative "profiling/collectors/idle_sampling_helper"
@@ -17,8 +17,6 @@ module Datadog
17
17
  #
18
18
  # @api private
19
19
  module FileHash
20
- module_function
21
-
22
20
  # Compute Git-style SHA-1 hash of a file.
23
21
  # Uses Git's blob hash algorithm: SHA1("blob <size>\0<content>")
24
22
  # Returns nil on any error (file not found, permission denied, etc.)
@@ -26,7 +24,7 @@ module Datadog
26
24
  # @param file_path [String] Path to the file
27
25
  # @param logger [#debug] Logger for error reporting
28
26
  # @return [String, nil] 40-character hex-encoded SHA-1 hash, or nil if error
29
- def compute(file_path, logger:)
27
+ def self.compute(file_path, logger:)
30
28
  return nil unless file_path
31
29
  return nil unless File.exist?(file_path)
32
30
 
@@ -13,9 +13,7 @@ module Datadog
13
13
  module Tracing
14
14
  # Tracing component
15
15
  module Component
16
- module_function
17
-
18
- def build_tracer(settings, agent_settings, logger:)
16
+ def self.build_tracer(settings, agent_settings, logger:)
19
17
  # If a custom tracer has been provided, use it instead.
20
18
  # Ignore all other options (they should already be configured.)
21
19
  tracer = settings.tracing.instance
@@ -52,7 +50,7 @@ module Datadog
52
50
  )
53
51
  end
54
52
 
55
- def build_trace_flush(settings)
53
+ def self.build_trace_flush(settings)
56
54
  if settings.tracing.partial_flush.enabled
57
55
  Tracing::Flush::Partial.new(
58
56
  min_spans_before_partial_flush: settings.tracing.partial_flush.min_spans_threshold,
@@ -62,7 +60,7 @@ module Datadog
62
60
  end
63
61
  end
64
62
 
65
- def bind_transport_telemetry(tracer, telemetry)
63
+ def self.bind_transport_telemetry(tracer, telemetry)
66
64
  return unless tracer.is_a?(Tracing::Tracer)
67
65
 
68
66
  writer = tracer.writer
@@ -79,7 +77,7 @@ module Datadog
79
77
  # Builds the sampler for the given settings: the sampler that keeps
80
78
  # every trace when test mode is enabled, otherwise the sampler built
81
79
  # from the custom sampler, sampling rules and rates.
82
- def build_sampler(settings)
80
+ def self.build_sampler(settings)
83
81
  return build_test_mode_sampler if settings.tracing.test_mode.enabled
84
82
 
85
83
  # A custom sampler is provided
@@ -120,7 +118,7 @@ module Datadog
120
118
  # process, but can take a variety of options (including
121
119
  # a fully custom instance) that makes the Tracer
122
120
  # initialization process complex.
123
- def build_writer(settings, agent_settings, options = settings.tracing.writer_options)
121
+ def self.build_writer(settings, agent_settings, options = settings.tracing.writer_options)
124
122
  if (writer = settings.tracing.writer)
125
123
  return writer
126
124
  end
@@ -132,7 +130,7 @@ module Datadog
132
130
  Tracing::Writer.new(agent_settings: agent_settings, **options)
133
131
  end
134
132
 
135
- def build_native_transport(agent_settings)
133
+ def self.build_native_transport(agent_settings)
136
134
  require_relative "transport/native"
137
135
 
138
136
  unless Transport::Native.supported?
@@ -149,7 +147,7 @@ module Datadog
149
147
  )
150
148
  end
151
149
 
152
- def subscribe_to_writer_events!(writer, sampler_delegator, test_mode)
150
+ def self.subscribe_to_writer_events!(writer, sampler_delegator, test_mode)
153
151
  return unless writer.respond_to?(:events) # Check if it's a custom, external writer
154
152
 
155
153
  writer.events.after_send.subscribe(&WRITER_RECORD_ENVIRONMENT_INFORMATION_CALLBACK)
@@ -174,7 +172,7 @@ module Datadog
174
172
 
175
173
  # Create new lambda for writer callback,
176
174
  # capture the current sampler in the callback closure.
177
- def writer_update_priority_sampler_rates_callback(sampler)
175
+ def self.writer_update_priority_sampler_rates_callback(sampler)
178
176
  lambda do |_, responses|
179
177
  response = responses.last
180
178
 
@@ -184,7 +182,7 @@ module Datadog
184
182
  end
185
183
  end
186
184
 
187
- def build_span_sampler(settings)
185
+ def self.build_span_sampler(settings)
188
186
  rules = Tracing::Sampling::Span::RuleParser.parse_json(settings.tracing.sampling.span_rules)
189
187
  Tracing::Sampling::Span::Sampler.new(rules || [])
190
188
  end
@@ -222,7 +220,7 @@ module Datadog
222
220
  end
223
221
 
224
222
  # @api private
225
- def build_tracer_tags(settings)
223
+ def self.build_tracer_tags(settings)
226
224
  settings.tags.dup.tap do |tags|
227
225
  tags[Core::Environment::Ext::TAG_ENV] = settings.env unless settings.env.nil?
228
226
  tags[Core::Environment::Ext::TAG_VERSION] = settings.version unless settings.version.nil?
@@ -232,7 +230,7 @@ module Datadog
232
230
  # Build a post-sampler that limits the rate of traces to one per `seconds`.
233
231
  # E.g.: `build_rate_limit_post_sampler(seconds: 60)` will limit the rate to one trace per minute.
234
232
  # @api private
235
- def build_rate_limit_post_sampler(seconds:)
233
+ def self.build_rate_limit_post_sampler(seconds:)
236
234
  Tracing::Sampling::RuleSampler.new(
237
235
  rate_limiter: Datadog::Core::TokenBucket.new(1.0 / seconds, 1.0),
238
236
  default_sample_rate: 1.0,
@@ -240,13 +238,13 @@ module Datadog
240
238
  end
241
239
 
242
240
  # @api private
243
- def build_test_mode_trace_flush(settings)
241
+ def self.build_test_mode_trace_flush(settings)
244
242
  # If context flush behavior is provided, use it instead.
245
243
  settings.tracing.test_mode.trace_flush || build_trace_flush(settings)
246
244
  end
247
245
 
248
246
  # @api private
249
- def build_test_mode_sampler
247
+ def self.build_test_mode_sampler
250
248
  # Do not sample any spans for tests; all must be preserved.
251
249
  # Set priority sampler to ensure the agent doesn't drop any traces.
252
250
  Tracing::Sampling::PrioritySampler.new(
@@ -256,7 +254,7 @@ module Datadog
256
254
  end
257
255
 
258
256
  # @api private
259
- def build_test_mode_writer(settings, agent_settings)
257
+ def self.build_test_mode_writer(settings, agent_settings)
260
258
  writer_options = settings.tracing.test_mode.writer_options || {}
261
259
 
262
260
  return build_writer(settings, agent_settings, writer_options) if settings.tracing.test_mode.async
@@ -276,9 +276,9 @@ module Datadog
276
276
  settings :partial_flush do
277
277
  # Enable partial trace flushing.
278
278
  #
279
- # @default `false`
279
+ # @default `true`
280
280
  # @return [Boolean]
281
- option :enabled, default: false, type: :bool
281
+ option :enabled, default: true, type: :bool
282
282
 
283
283
  # Minimum number of finished spans required in a single unfinished trace before
284
284
  # the tracer will consider that trace for partial flushing.
@@ -19,22 +19,20 @@ module Datadog
19
19
 
20
20
  EVENT_NAME = "broadcast.action_cable"
21
21
 
22
- module_function
23
-
24
- def event_name
22
+ def self.event_name
25
23
  self::EVENT_NAME
26
24
  end
27
25
 
28
- def span_name
26
+ def self.span_name
29
27
  Ext::SPAN_BROADCAST
30
28
  end
31
29
 
32
- def span_type
30
+ def self.span_type
33
31
  # Starts a broadcast of messages over WebSockets
34
32
  Tracing::Metadata::Ext::AppTypes::TYPE_WEB
35
33
  end
36
34
 
37
- def on_start(span, _event, _id, payload)
35
+ def self.on_start(span, _event, _id, payload)
38
36
  channel = payload[:broadcasting] # Channel has high cardinality
39
37
  if configuration[:service_name]
40
38
  span.service = configuration[:service_name]
@@ -18,22 +18,20 @@ module Datadog
18
18
 
19
19
  EVENT_NAME = "perform_action.action_cable"
20
20
 
21
- module_function
22
-
23
- def event_name
21
+ def self.event_name
24
22
  self::EVENT_NAME
25
23
  end
26
24
 
27
- def span_name
25
+ def self.span_name
28
26
  Ext::SPAN_ACTION
29
27
  end
30
28
 
31
- def span_type
29
+ def self.span_type
32
30
  # A request to perform_action comes from a WebSocket connection
33
31
  Tracing::Metadata::Ext::AppTypes::TYPE_WEB
34
32
  end
35
33
 
36
- def on_start(span, _event, _id, payload)
34
+ def self.on_start(span, _event, _id, payload)
37
35
  channel_class = payload[:channel_class]
38
36
  action = payload[:action]
39
37