ddtrace 1.10.0 → 1.11.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (360) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -2
  3. data/LICENSE-3rdparty.csv +1 -0
  4. data/README.md +8 -9
  5. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +76 -11
  6. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +26 -3
  7. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -0
  8. data/lib/datadog/appsec/component.rb +41 -7
  9. data/lib/datadog/appsec/configuration/settings.rb +20 -4
  10. data/lib/datadog/appsec/configuration.rb +8 -0
  11. data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -0
  12. data/lib/datadog/appsec/contrib/configuration/settings.rb +2 -0
  13. data/lib/datadog/appsec/contrib/integration.rb +2 -0
  14. data/lib/datadog/appsec/contrib/patcher.rb +2 -0
  15. data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -0
  16. data/lib/datadog/appsec/contrib/rack/gateway/request.rb +7 -25
  17. data/lib/datadog/appsec/contrib/rack/gateway/response.rb +1 -1
  18. data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -0
  19. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -0
  20. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +17 -3
  21. data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -0
  22. data/lib/datadog/appsec/contrib/rails/framework.rb +2 -0
  23. data/lib/datadog/appsec/contrib/rails/gateway/request.rb +1 -1
  24. data/lib/datadog/appsec/contrib/rails/request.rb +2 -0
  25. data/lib/datadog/appsec/contrib/rails/request_middleware.rb +2 -0
  26. data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -0
  27. data/lib/datadog/appsec/contrib/sinatra/framework.rb +2 -0
  28. data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +1 -1
  29. data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +2 -0
  30. data/lib/datadog/appsec/extensions.rb +2 -0
  31. data/lib/datadog/appsec/instrumentation/gateway/argument.rb +2 -4
  32. data/lib/datadog/appsec/processor/rule_loader.rb +63 -0
  33. data/lib/datadog/appsec/processor/rule_merger.rb +146 -0
  34. data/lib/datadog/appsec/processor.rb +15 -70
  35. data/lib/datadog/appsec/remote.rb +121 -0
  36. data/lib/datadog/appsec/utils/http.rb +2 -0
  37. data/lib/datadog/appsec/utils.rb +2 -0
  38. data/lib/datadog/appsec.rb +18 -4
  39. data/lib/datadog/ci/configuration/components.rb +2 -0
  40. data/lib/datadog/ci/configuration/settings.rb +2 -0
  41. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -0
  42. data/lib/datadog/ci/contrib/cucumber/formatter.rb +2 -0
  43. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -0
  44. data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -0
  45. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -0
  46. data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -0
  47. data/lib/datadog/ci/ext/environment.rb +2 -20
  48. data/lib/datadog/ci/extensions.rb +2 -0
  49. data/lib/datadog/ci/flush.rb +2 -0
  50. data/lib/datadog/ci.rb +2 -0
  51. data/lib/datadog/core/buffer/cruby.rb +2 -0
  52. data/lib/datadog/core/buffer/random.rb +2 -0
  53. data/lib/datadog/core/buffer/thread_safe.rb +2 -0
  54. data/lib/datadog/core/chunker.rb +2 -0
  55. data/lib/datadog/core/configuration/agent_settings_resolver.rb +6 -6
  56. data/lib/datadog/core/configuration/components.rb +12 -15
  57. data/lib/datadog/core/configuration/dependency_resolver.rb +2 -0
  58. data/lib/datadog/core/configuration/option.rb +2 -0
  59. data/lib/datadog/core/configuration/option_definition.rb +2 -0
  60. data/lib/datadog/core/configuration/option_definition_set.rb +2 -0
  61. data/lib/datadog/core/configuration/option_set.rb +2 -0
  62. data/lib/datadog/core/configuration/settings.rb +68 -13
  63. data/lib/datadog/core/diagnostics/health.rb +2 -0
  64. data/lib/datadog/core/environment/class_count.rb +2 -0
  65. data/lib/datadog/core/environment/gc.rb +2 -0
  66. data/lib/datadog/core/environment/identity.rb +2 -0
  67. data/lib/datadog/core/environment/socket.rb +2 -0
  68. data/lib/datadog/core/environment/thread_count.rb +2 -0
  69. data/lib/datadog/core/environment/variable_helpers.rb +10 -2
  70. data/lib/datadog/core/environment/vm_cache.rb +2 -0
  71. data/lib/datadog/core/extensions.rb +2 -0
  72. data/lib/datadog/core/header_collection.rb +2 -0
  73. data/lib/datadog/core/metrics/helpers.rb +2 -0
  74. data/lib/datadog/core/metrics/metric.rb +2 -0
  75. data/lib/datadog/core/remote/client/capabilities.rb +57 -0
  76. data/lib/datadog/core/remote/client.rb +146 -0
  77. data/lib/datadog/core/remote/component.rb +150 -0
  78. data/lib/datadog/core/remote/configuration/content.rb +82 -0
  79. data/lib/datadog/core/remote/configuration/digest.rb +62 -0
  80. data/lib/datadog/core/remote/configuration/path.rb +90 -0
  81. data/lib/datadog/core/remote/configuration/repository.rb +278 -0
  82. data/lib/datadog/core/remote/configuration/target.rb +72 -0
  83. data/lib/datadog/core/remote/configuration.rb +18 -0
  84. data/lib/datadog/core/remote/dispatcher.rb +59 -0
  85. data/lib/datadog/core/remote/ext.rb +12 -0
  86. data/lib/datadog/core/remote/worker.rb +96 -0
  87. data/lib/datadog/core/remote.rb +24 -0
  88. data/lib/datadog/core/telemetry/collector.rb +8 -9
  89. data/lib/datadog/core/telemetry/heartbeat.rb +2 -0
  90. data/lib/datadog/core/telemetry/http/env.rb +2 -0
  91. data/lib/datadog/core/telemetry/http/transport.rb +2 -0
  92. data/lib/datadog/core/telemetry/v1/app_event.rb +2 -0
  93. data/lib/datadog/core/telemetry/v1/application.rb +7 -1
  94. data/lib/datadog/core/telemetry/v1/dependency.rb +7 -1
  95. data/lib/datadog/core/telemetry/v1/host.rb +9 -1
  96. data/lib/datadog/core/telemetry/v1/integration.rb +7 -1
  97. data/lib/datadog/core/telemetry/v1/product.rb +9 -1
  98. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +7 -1
  99. data/lib/datadog/core/transport/config.rb +58 -0
  100. data/lib/datadog/core/transport/http/api/instance.rb +37 -0
  101. data/lib/datadog/core/transport/http/api/spec.rb +19 -0
  102. data/lib/datadog/core/transport/http/api.rb +57 -0
  103. data/lib/datadog/core/transport/http/builder.rb +217 -0
  104. data/lib/datadog/core/transport/http/client.rb +45 -0
  105. data/lib/datadog/core/transport/http/config.rb +268 -0
  106. data/lib/datadog/core/transport/http/negotiation.rb +144 -0
  107. data/lib/datadog/core/transport/http.rb +169 -0
  108. data/lib/datadog/core/transport/negotiation.rb +60 -0
  109. data/lib/datadog/core/utils/compression.rb +2 -0
  110. data/lib/datadog/core/utils/hash.rb +32 -0
  111. data/lib/datadog/core/utils/network.rb +140 -0
  112. data/lib/datadog/core/utils/object_set.rb +2 -0
  113. data/lib/datadog/core/utils/safe_dup.rb +20 -2
  114. data/lib/datadog/core/utils/sequence.rb +2 -0
  115. data/lib/datadog/core/utils/time.rb +2 -0
  116. data/lib/datadog/core/vendor/ipaddr.rb +78 -0
  117. data/lib/datadog/core/worker.rb +2 -0
  118. data/lib/datadog/core/workers/interval_loop.rb +2 -0
  119. data/lib/datadog/core/workers/queue.rb +2 -0
  120. data/lib/datadog/core/workers/runtime_metrics.rb +2 -0
  121. data/lib/datadog/kit/appsec/events.rb +1 -1
  122. data/lib/datadog/kit.rb +2 -0
  123. data/lib/datadog/opentracer/binary_propagator.rb +2 -0
  124. data/lib/datadog/opentracer/carrier.rb +2 -0
  125. data/lib/datadog/opentracer/global_tracer.rb +2 -0
  126. data/lib/datadog/opentracer/propagator.rb +2 -0
  127. data/lib/datadog/opentracer/scope.rb +2 -0
  128. data/lib/datadog/opentracer/scope_manager.rb +2 -0
  129. data/lib/datadog/opentracer/span_context.rb +2 -0
  130. data/lib/datadog/opentracer/span_context_factory.rb +2 -0
  131. data/lib/datadog/opentracer/thread_local_scope.rb +2 -0
  132. data/lib/datadog/opentracer.rb +2 -0
  133. data/lib/datadog/profiling/backtrace_location.rb +2 -0
  134. data/lib/datadog/profiling/buffer.rb +2 -0
  135. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +19 -3
  136. data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +2 -0
  137. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
  138. data/lib/datadog/profiling/collectors/stack.rb +2 -0
  139. data/lib/datadog/profiling/collectors/thread_context.rb +2 -2
  140. data/lib/datadog/profiling/component.rb +103 -29
  141. data/lib/datadog/profiling/event.rb +2 -0
  142. data/lib/datadog/profiling/events/stack.rb +2 -0
  143. data/lib/datadog/profiling/ext.rb +28 -26
  144. data/lib/datadog/profiling/flush.rb +2 -0
  145. data/lib/datadog/profiling/native_extension.rb +2 -0
  146. data/lib/datadog/profiling/pprof/message_set.rb +2 -0
  147. data/lib/datadog/profiling/pprof/payload.rb +2 -0
  148. data/lib/datadog/profiling/pprof/string_table.rb +2 -0
  149. data/lib/datadog/profiling/preload.rb +2 -0
  150. data/lib/datadog/profiling/scheduler.rb +3 -1
  151. data/lib/datadog/profiling/stack_recorder.rb +0 -18
  152. data/lib/datadog/profiling/tag_builder.rb +2 -0
  153. data/lib/datadog/profiling/tasks/setup.rb +0 -26
  154. data/lib/datadog/profiling.rb +2 -1
  155. data/lib/datadog/tracing/analytics.rb +2 -0
  156. data/lib/datadog/tracing/client_ip.rb +39 -140
  157. data/lib/datadog/tracing/configuration/ext.rb +7 -0
  158. data/lib/datadog/tracing/configuration/settings.rb +14 -0
  159. data/lib/datadog/tracing/context.rb +2 -0
  160. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -0
  161. data/lib/datadog/tracing/contrib/action_cable/event.rb +2 -0
  162. data/lib/datadog/tracing/contrib/action_cable/events.rb +2 -0
  163. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -0
  164. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -0
  165. data/lib/datadog/tracing/contrib/action_mailer/event.rb +2 -0
  166. data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -0
  167. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -0
  168. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -24
  169. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -0
  170. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +14 -1
  171. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
  172. data/lib/datadog/tracing/contrib/action_view/event.rb +2 -0
  173. data/lib/datadog/tracing/contrib/action_view/events.rb +2 -0
  174. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +2 -0
  175. data/lib/datadog/tracing/contrib/active_job/event.rb +2 -0
  176. data/lib/datadog/tracing/contrib/active_job/events.rb +2 -0
  177. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +2 -0
  178. data/lib/datadog/tracing/contrib/active_job/patcher.rb +2 -0
  179. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -0
  180. data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +2 -0
  181. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -0
  182. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +2 -0
  183. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +2 -0
  184. data/lib/datadog/tracing/contrib/active_record/event.rb +2 -0
  185. data/lib/datadog/tracing/contrib/active_record/events.rb +2 -0
  186. data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -0
  187. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +2 -0
  188. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -0
  189. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -0
  190. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -0
  191. data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +2 -0
  192. data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -0
  193. data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -0
  194. data/lib/datadog/tracing/contrib/analytics.rb +2 -0
  195. data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -0
  196. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +9 -1
  197. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +8 -2
  198. data/lib/datadog/tracing/contrib/aws/patcher.rb +2 -0
  199. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -0
  200. data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +2 -0
  201. data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +2 -0
  202. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -0
  203. data/lib/datadog/tracing/contrib/configurable.rb +2 -0
  204. data/lib/datadog/tracing/contrib/configuration/resolver.rb +2 -0
  205. data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
  206. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +2 -0
  207. data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -0
  208. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +2 -0
  209. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +2 -0
  210. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -0
  211. data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +2 -0
  212. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +2 -0
  213. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +2 -0
  214. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +2 -0
  215. data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -0
  216. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +2 -0
  217. data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -0
  218. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +2 -0
  219. data/lib/datadog/tracing/contrib/faraday/connection.rb +2 -0
  220. data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +2 -0
  221. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +2 -0
  222. data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -0
  223. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -0
  224. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +2 -0
  225. data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +2 -0
  226. data/lib/datadog/tracing/contrib/grpc/patcher.rb +2 -0
  227. data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +2 -0
  228. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +2 -0
  229. data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -0
  230. data/lib/datadog/tracing/contrib/hanami/plugin.rb +2 -0
  231. data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +2 -0
  232. data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +2 -0
  233. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +2 -0
  234. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +2 -0
  235. data/lib/datadog/tracing/contrib/http/integration.rb +2 -0
  236. data/lib/datadog/tracing/contrib/http/patcher.rb +2 -0
  237. data/lib/datadog/tracing/contrib/http_annotation_helper.rb +2 -0
  238. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -0
  239. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -0
  240. data/lib/datadog/tracing/contrib/integration.rb +2 -0
  241. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -0
  242. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +2 -0
  243. data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +2 -0
  244. data/lib/datadog/tracing/contrib/kafka/event.rb +2 -0
  245. data/lib/datadog/tracing/contrib/kafka/events.rb +2 -0
  246. data/lib/datadog/tracing/contrib/kafka/patcher.rb +2 -0
  247. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -0
  248. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -0
  249. data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -0
  250. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -0
  251. data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +2 -0
  252. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +2 -0
  253. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -0
  254. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -0
  255. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -0
  256. data/lib/datadog/tracing/contrib/patchable.rb +2 -0
  257. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -0
  258. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +2 -0
  259. data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -0
  260. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -0
  261. data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +2 -0
  262. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -0
  263. data/lib/datadog/tracing/contrib/qless/patcher.rb +2 -0
  264. data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +2 -0
  265. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -0
  266. data/lib/datadog/tracing/contrib/racecar/event.rb +2 -0
  267. data/lib/datadog/tracing/contrib/racecar/events.rb +2 -0
  268. data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -0
  269. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +9 -2
  270. data/lib/datadog/tracing/contrib/rails/framework.rb +2 -0
  271. data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -0
  272. data/lib/datadog/tracing/contrib/rails/utils.rb +3 -1
  273. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +2 -0
  274. data/lib/datadog/tracing/contrib/rake/patcher.rb +2 -0
  275. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -0
  276. data/lib/datadog/tracing/contrib/redis/tags.rb +2 -0
  277. data/lib/datadog/tracing/contrib/registerable.rb +2 -0
  278. data/lib/datadog/tracing/contrib/registry.rb +2 -0
  279. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +2 -0
  280. data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -0
  281. data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
  282. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -0
  283. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -0
  284. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
  285. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +34 -0
  286. data/lib/datadog/tracing/contrib/roda/ext.rb +18 -0
  287. data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
  288. data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
  289. data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
  290. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -0
  291. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -0
  292. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -0
  293. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -0
  294. data/lib/datadog/tracing/contrib/sequel/dataset.rb +2 -0
  295. data/lib/datadog/tracing/contrib/sequel/patcher.rb +2 -0
  296. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +2 -0
  297. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -0
  298. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
  299. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +12 -3
  300. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -0
  301. data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +38 -0
  302. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +2 -0
  303. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +2 -0
  304. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +2 -0
  305. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +2 -0
  306. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +2 -0
  307. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +18 -2
  308. data/lib/datadog/tracing/contrib/sidekiq/{tracing.rb → utils.rb} +3 -1
  309. data/lib/datadog/tracing/contrib/sinatra/headers.rb +2 -0
  310. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -0
  311. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +2 -0
  312. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +28 -0
  313. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -0
  314. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +2 -0
  315. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +2 -0
  316. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
  317. data/lib/datadog/tracing/contrib.rb +3 -0
  318. data/lib/datadog/tracing/correlation.rb +10 -10
  319. data/lib/datadog/tracing/diagnostics/health.rb +2 -0
  320. data/lib/datadog/tracing/distributed/trace_context.rb +22 -15
  321. data/lib/datadog/tracing/flush.rb +2 -0
  322. data/lib/datadog/tracing/metadata/analytics.rb +2 -0
  323. data/lib/datadog/tracing/metadata/errors.rb +2 -0
  324. data/lib/datadog/tracing/metadata/ext.rb +6 -0
  325. data/lib/datadog/tracing/metadata.rb +2 -0
  326. data/lib/datadog/tracing/pipeline/span_filter.rb +2 -0
  327. data/lib/datadog/tracing/pipeline/span_processor.rb +2 -0
  328. data/lib/datadog/tracing/propagation/http.rb +2 -0
  329. data/lib/datadog/tracing/runtime/metrics.rb +2 -0
  330. data/lib/datadog/tracing/sampling/all_sampler.rb +2 -0
  331. data/lib/datadog/tracing/sampling/matcher.rb +2 -0
  332. data/lib/datadog/tracing/sampling/priority_sampler.rb +2 -0
  333. data/lib/datadog/tracing/sampling/span/sampler.rb +2 -0
  334. data/lib/datadog/tracing/sync_writer.rb +2 -0
  335. data/lib/datadog/tracing/trace_digest.rb +2 -0
  336. data/lib/datadog/tracing/utils.rb +2 -0
  337. data/lib/datadog/tracing.rb +2 -0
  338. data/lib/ddtrace/auto_instrument.rb +2 -0
  339. data/lib/ddtrace/auto_instrument_base.rb +2 -0
  340. data/lib/ddtrace/transport/http/adapters/net.rb +12 -0
  341. data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
  342. data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
  343. data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
  344. data/lib/ddtrace/transport/http/api/instance.rb +2 -0
  345. data/lib/ddtrace/transport/http/api/map.rb +2 -0
  346. data/lib/ddtrace/transport/http/api/spec.rb +2 -0
  347. data/lib/ddtrace/transport/http/env.rb +2 -0
  348. data/lib/ddtrace/transport/http/response.rb +2 -0
  349. data/lib/ddtrace/transport/http/traces.rb +1 -1
  350. data/lib/ddtrace/transport/io/response.rb +2 -0
  351. data/lib/ddtrace/transport/io/traces.rb +2 -0
  352. data/lib/ddtrace/transport/io.rb +2 -0
  353. data/lib/ddtrace/transport/parcel.rb +2 -0
  354. data/lib/ddtrace/transport/request.rb +3 -1
  355. data/lib/ddtrace/transport/statistics.rb +2 -0
  356. data/lib/ddtrace/transport/trace_formatter.rb +2 -0
  357. data/lib/ddtrace/transport/traces.rb +1 -1
  358. data/lib/ddtrace/version.rb +6 -4
  359. data/lib/ddtrace.rb +2 -0
  360. metadata +45 -9
@@ -0,0 +1,278 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'content'
4
+
5
+ module Datadog
6
+ module Core
7
+ module Remote
8
+ class Configuration
9
+ # Repository
10
+ class Repository
11
+ attr_reader \
12
+ :contents,
13
+ :opaque_backend_state,
14
+ :root_version,
15
+ :targets_version
16
+
17
+ UNVERIFIED_ROOT_VERSION = 1
18
+
19
+ INITIAL_TARGETS_VERSION = 0
20
+
21
+ def initialize
22
+ @contents = ContentList.new
23
+ @opaque_backend_state = nil
24
+ @root_version = UNVERIFIED_ROOT_VERSION
25
+ @targets_version = INITIAL_TARGETS_VERSION
26
+ end
27
+
28
+ def paths
29
+ @contents.paths
30
+ end
31
+
32
+ def [](path)
33
+ @contents[path]
34
+ end
35
+
36
+ def transaction
37
+ transaction = Transaction.new
38
+
39
+ yield(self, transaction)
40
+
41
+ commit(transaction)
42
+ end
43
+
44
+ def commit(transaction)
45
+ previous = contents.dup
46
+
47
+ touched = transaction.operations.each_with_object([]) do |op, acc|
48
+ acc << op.apply(self)
49
+ end
50
+
51
+ changes = ChangeSet.new
52
+
53
+ touched.uniq.each do |path|
54
+ next if path.nil?
55
+
56
+ changes.add(path, previous[path], @contents[path])
57
+ end
58
+
59
+ changes.freeze
60
+ end
61
+
62
+ def state
63
+ State.new(self)
64
+ end
65
+
66
+ # State store the repository state
67
+ class State
68
+ attr_reader \
69
+ :root_version,
70
+ :targets_version,
71
+ :config_states,
72
+ :has_error,
73
+ :error,
74
+ :opaque_backend_state,
75
+ :cached_target_files
76
+
77
+ def initialize(repository)
78
+ @repository = repository
79
+ @root_version = repository.root_version
80
+ @targets_version = repository.targets_version
81
+ @config_states = []
82
+ @has_error = false
83
+ @error = ''
84
+ @opaque_backend_state = repository.opaque_backend_state
85
+ @cached_target_files = contents_to_cached_target_files(repository.contents)
86
+ end
87
+
88
+ private
89
+
90
+ def contents_to_cached_target_files(contents)
91
+ return [] if contents.empty?
92
+
93
+ contents.map do |content|
94
+ {
95
+ path: content.path.to_s,
96
+ length: content.length,
97
+ hashes: content.hashes.map do |algorithm, hexdigest|
98
+ {
99
+ algorithm: algorithm,
100
+ hash: hexdigest
101
+ }
102
+ end
103
+ }
104
+ end
105
+ end
106
+ end
107
+
108
+ # Encapsulates transaction operations
109
+ class Transaction
110
+ attr_reader :operations
111
+
112
+ def initialize
113
+ @operations = []
114
+ end
115
+
116
+ def delete(path)
117
+ @operations << Operation::Delete.new(path)
118
+ end
119
+
120
+ def insert(path, target, content)
121
+ @operations << Operation::Insert.new(path, target, content)
122
+ end
123
+
124
+ def update(path, target, content)
125
+ @operations << Operation::Update.new(path, target, content)
126
+ end
127
+
128
+ def set(**options)
129
+ @operations << Operation::Set.new(**options)
130
+ end
131
+ end
132
+
133
+ # Operation
134
+ module Operation
135
+ # Delete contents base on path
136
+ class Delete
137
+ attr_reader :path
138
+
139
+ def initialize(path)
140
+ super()
141
+ @path = path
142
+ end
143
+
144
+ def apply(repository)
145
+ return if repository[@path].nil?
146
+
147
+ repository.contents.delete(@path)
148
+
149
+ @path
150
+ end
151
+ end
152
+
153
+ # Insert content into the reporistory contents
154
+ class Insert
155
+ attr_reader :path, :target, :content
156
+
157
+ def initialize(path, target, content)
158
+ super()
159
+ @path = path
160
+ @target = target
161
+ @content = content
162
+ end
163
+
164
+ def apply(repository)
165
+ return unless repository[@path].nil?
166
+
167
+ repository.contents << @content
168
+
169
+ @path
170
+ end
171
+ end
172
+
173
+ # Update existimng repository's contents
174
+ class Update
175
+ attr_reader :path, :target, :content
176
+
177
+ def initialize(path, target, content)
178
+ super()
179
+ @path = path
180
+ @target = target
181
+ @content = content
182
+ end
183
+
184
+ def apply(repository)
185
+ return if repository[@path].nil?
186
+
187
+ repository.contents[@path] = @content
188
+
189
+ @path
190
+ end
191
+ end
192
+
193
+ # Set repository metadata
194
+ class Set
195
+ attr_reader :opaque_backend_state, :targets_version
196
+
197
+ def initialize(**options)
198
+ super()
199
+ @opaque_backend_state = options[:opaque_backend_state]
200
+ @targets_version = options[:targets_version]
201
+ end
202
+
203
+ def apply(repository)
204
+ repository.instance_variable_set(:@opaque_backend_state, @opaque_backend_state) if @opaque_backend_state
205
+
206
+ repository.instance_variable_set(:@targets_version, @targets_version) if @targets_version
207
+
208
+ nil
209
+ end
210
+ end
211
+ end
212
+
213
+ private_constant :Operation
214
+
215
+ module Change
216
+ # Delete change
217
+ class Deleted
218
+ attr_reader :path, :previous
219
+
220
+ def initialize(path, previous)
221
+ @path = path
222
+ @previous = previous
223
+ end
224
+ end
225
+
226
+ # Insert change
227
+ class Inserted
228
+ attr_reader :path, :content
229
+
230
+ def initialize(path, content)
231
+ @path = path
232
+ @content = content
233
+ end
234
+ end
235
+
236
+ # Update change
237
+ class Updated
238
+ attr_reader :path, :content, :previous
239
+
240
+ def initialize(path, content, previous)
241
+ @path = path
242
+ @content = content
243
+ @previous = previous
244
+ end
245
+ end
246
+ end
247
+
248
+ # Store list of Changes
249
+ class ChangeSet < Array
250
+ def paths
251
+ map(&:path)
252
+ end
253
+
254
+ def add(path, previous, content)
255
+ return if previous.nil? && content.nil?
256
+
257
+ return deleted(path, previous) if previous && content.nil?
258
+ return inserted(path, content) if content && previous.nil?
259
+ return updated(path, content, previous) if content && previous
260
+ end
261
+
262
+ def deleted(path, previous)
263
+ self << Change::Deleted.new(path, previous).freeze
264
+ end
265
+
266
+ def inserted(path, content)
267
+ self << Change::Inserted.new(path, content).freeze
268
+ end
269
+
270
+ def updated(path, content, previous)
271
+ self << Change::Updated.new(path, content, previous).freeze
272
+ end
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
278
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'path'
4
+ require_relative 'digest'
5
+
6
+ module Datadog
7
+ module Core
8
+ module Remote
9
+ class Configuration
10
+ # TargetMap stores information regarding Configuration::Path and Configuration::Target
11
+ class TargetMap < Hash
12
+ class << self
13
+ def parse(hash)
14
+ opaque_backend_state = hash['signed']['custom']['opaque_backend_state']
15
+ version = hash['signed']['version']
16
+
17
+ map = new
18
+
19
+ map.instance_eval do
20
+ @opaque_backend_state = opaque_backend_state
21
+ @version = version
22
+ end
23
+
24
+ hash['signed']['targets'].each_with_object(map) do |(p, t), m|
25
+ path = Configuration::Path.parse(p)
26
+ target = Configuration::Target.parse(t)
27
+
28
+ m[path] = target
29
+ end
30
+ end
31
+ end
32
+
33
+ attr_reader :opaque_backend_state, :version
34
+
35
+ def initialize
36
+ super
37
+
38
+ @opaque_backend_state = nil
39
+ @version = nil
40
+ end
41
+
42
+ private_class_method :new
43
+ end
44
+
45
+ # Target stores digest information
46
+ class Target
47
+ class << self
48
+ def parse(hash)
49
+ length = Integer(hash['length'])
50
+ digests = Configuration::DigestList.parse(hash['hashes'])
51
+
52
+ new(digests: digests, length: length)
53
+ end
54
+ end
55
+
56
+ attr_reader :length, :digests
57
+
58
+ def initialize(digests:, length:)
59
+ @digests = digests
60
+ @length = length
61
+ end
62
+
63
+ private_class_method :new
64
+
65
+ def check(content)
66
+ digests.check(content)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'configuration/path'
4
+ require_relative 'configuration/content'
5
+ require_relative 'configuration/target'
6
+ require_relative 'configuration/repository'
7
+
8
+ module Datadog
9
+ module Core
10
+ module Remote
11
+ # Configuration
12
+ # rubocop:disable Lint/EmptyClass
13
+ class Configuration
14
+ end
15
+ # rubocop:enable Lint/EmptyClass
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Core
5
+ module Remote
6
+ # Repository update dispatcher
7
+ class Dispatcher
8
+ attr_reader :receivers
9
+
10
+ def initialize
11
+ @receivers = []
12
+ end
13
+
14
+ def dispatch(changes, repository)
15
+ receivers.each do |receiver|
16
+ matching_changes = changes.select { |c| receiver.match?(c.path) }
17
+
18
+ receiver.call(repository, matching_changes) if matching_changes.any?
19
+ end
20
+ end
21
+
22
+ # Store Matcher and block to be executed on a match
23
+ class Receiver
24
+ def initialize(matcher, &block)
25
+ @block = block
26
+ @matcher = matcher
27
+ end
28
+
29
+ def match?(path)
30
+ @matcher.match?(path)
31
+ end
32
+
33
+ def call(repository, changes)
34
+ @block.call(repository, changes)
35
+ end
36
+ end
37
+
38
+ # Matcher checks if the path matches
39
+ class Matcher
40
+ def initialize(&block)
41
+ @block = block
42
+ end
43
+
44
+ def match?(path)
45
+ @block.call(path)
46
+ end
47
+
48
+ # Matches on the produc's path
49
+ class Product < Matcher
50
+ def initialize(products)
51
+ block = ->(path) { products.include?(path.product) }
52
+ super(&block)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Core
5
+ module Remote
6
+ module Ext
7
+ ENV_ENABLED = 'DD_REMOTE_CONFIGURATION_ENABLED'
8
+ ENV_POLL_INTERVAL_SECONDS = 'DD_REMOTE_CONFIGURATION_POLL_INTERVAL_SECONDS'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Core
5
+ module Remote
6
+ # Worker executes a block every interval on a separate Thread
7
+ class Worker
8
+ def initialize(interval:, &block)
9
+ @mutex = Mutex.new
10
+ @thr = nil
11
+
12
+ @starting = false
13
+ @stopping = false
14
+ @started = false
15
+
16
+ @interval = interval
17
+ raise ArgumentError, 'can not initialize a worker without a block' unless block
18
+
19
+ @block = block
20
+ end
21
+
22
+ def start
23
+ Datadog.logger.debug { 'remote worker starting' }
24
+
25
+ acquire_lock
26
+
27
+ return if @starting || @started
28
+
29
+ @starting = true
30
+
31
+ @thr = Thread.new { poll(@interval) }
32
+
33
+ @started = true
34
+ @starting = false
35
+
36
+ Datadog.logger.debug { 'remote worker started' }
37
+ ensure
38
+ release_lock
39
+ end
40
+
41
+ def stop
42
+ Datadog.logger.debug { 'remote worker stopping' }
43
+
44
+ acquire_lock
45
+
46
+ @stopping = true
47
+
48
+ thread = @thr
49
+
50
+ if thread
51
+ thread.kill
52
+ thread.join
53
+ end
54
+
55
+ @started = false
56
+ @stopping = false
57
+ @thr = nil
58
+
59
+ Datadog.logger.debug { 'remote worker stopped' }
60
+ ensure
61
+ release_lock
62
+ end
63
+
64
+ def started?
65
+ @started
66
+ end
67
+
68
+ private
69
+
70
+ def acquire_lock
71
+ @mutex.lock
72
+ end
73
+
74
+ def release_lock
75
+ @mutex.unlock
76
+ end
77
+
78
+ def poll(interval)
79
+ loop do
80
+ break unless @mutex.synchronize { @starting || @started }
81
+
82
+ call
83
+
84
+ sleep(interval)
85
+ end
86
+ end
87
+
88
+ def call
89
+ Datadog.logger.debug { 'remote worker perform' }
90
+
91
+ @block.call
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Core
5
+ # Module to interact with core remote component
6
+ module Remote
7
+ class << self
8
+ def active_remote
9
+ remote
10
+ end
11
+
12
+ private
13
+
14
+ def components
15
+ Datadog.send(:components)
16
+ end
17
+
18
+ def remote
19
+ components.remote
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,6 +5,7 @@ require 'etc'
5
5
  require_relative '../configuration/agent_settings_resolver'
6
6
  require_relative '../environment/ext'
7
7
  require_relative '../environment/platform'
8
+ require_relative '../utils/hash'
8
9
  require_relative 'v1/application'
9
10
  require_relative 'v1/dependency'
10
11
  require_relative 'v1/host'
@@ -18,6 +19,7 @@ module Datadog
18
19
  # Module defining methods for collecting metadata for telemetry
19
20
  module Collector
20
21
  include Datadog::Core::Configuration
22
+ using Core::Utils::Hash::Refinement
21
23
 
22
24
  # Forms a hash of configuration key value pairs to be sent in the additional payload
23
25
  def additional_payload
@@ -41,12 +43,13 @@ module Datadog
41
43
 
42
44
  # Forms a hash of standard key value pairs to be sent in the app-started event configuration
43
45
  def configurations
44
- configurations = {
46
+ hash = {
45
47
  DD_AGENT_HOST: Datadog.configuration.agent.host,
46
48
  DD_AGENT_TRANSPORT: agent_transport,
47
49
  DD_TRACE_SAMPLE_RATE: format_configuration_value(Datadog.configuration.tracing.sampling.default_rate),
48
50
  }
49
- compact_hash(configurations)
51
+ hash.compact!
52
+ hash
50
53
  end
51
54
 
52
55
  # Forms a telemetry app-started dependencies object
@@ -134,7 +137,8 @@ module Datadog
134
137
  options['logger.instance'] = configuration.logger.instance.class.to_s
135
138
  options['appsec.enabled'] = configuration.dig('appsec', 'enabled') if configuration.respond_to?('appsec')
136
139
  options['tracing.opentelemetry.enabled'] = !defined?(Datadog::OpenTelemetry::LOADED).nil?
137
- compact_hash(options)
140
+ options.compact!
141
+ options
138
142
  end
139
143
 
140
144
  def format_configuration_value(value)
@@ -147,11 +151,6 @@ module Datadog
147
151
  end
148
152
  end
149
153
 
150
- # Manual implementation of hash.compact used because it is unsupported by older Ruby versions (<2.4)
151
- def compact_hash(hash)
152
- hash.delete_if { |_k, v| v.nil? }
153
- end
154
-
155
154
  def env
156
155
  Datadog.configuration.env
157
156
  end
@@ -222,7 +221,7 @@ module Datadog
222
221
  desc += ", Patchable? #{integration.klass.class.patchable?}"
223
222
  desc
224
223
  else
225
- patch_error_result.to_s
224
+ patch_error_result.compact.to_s
226
225
  end
227
226
  end
228
227
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../worker'
2
4
  require_relative '../workers/polling'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Telemetry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../configuration/settings'
2
4
  require_relative 'env'
3
5
  require_relative 'ext'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Telemetry
@@ -1,9 +1,13 @@
1
+ require_relative '../../utils/hash'
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Telemetry
4
6
  module V1
5
7
  # Describes attributes for application environment object
6
8
  class Application
9
+ using Core::Utils::Hash::Refinement
10
+
7
11
  ERROR_NIL_LANGUAGE_NAME_MESSAGE = ':language_name must not be nil'.freeze
8
12
  ERROR_NIL_LANGUAGE_VERSION_MESSAGE = ':language_version must not be nil'.freeze
9
13
  ERROR_NIL_SERVICE_NAME_MESSAGE = ':service_name must not be nil'.freeze
@@ -54,7 +58,7 @@ module Datadog
54
58
  end
55
59
 
56
60
  def to_h
57
- {
61
+ hash = {
58
62
  env: @env,
59
63
  language_name: @language_name,
60
64
  language_version: @language_version,
@@ -66,6 +70,8 @@ module Datadog
66
70
  service_version: @service_version,
67
71
  tracer_version: @tracer_version
68
72
  }
73
+ hash.compact!
74
+ hash
69
75
  end
70
76
 
71
77
  private