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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d6ef41c3e2f14b483d24a4aca9955a2a4b0ddf850d25e5e19932e62299c3905
4
- data.tar.gz: de145f2e113f13e6d5d3360967e5fc3dc0273fb62c47dc6fae5d455e9c5f088c
3
+ metadata.gz: 83276ed5293cf8971f19f7a1fb1198e01f5ff8d48d3dd440deff0ef3518939d6
4
+ data.tar.gz: 12d22b6020e8830c91b2f68aed9ce03a2d201eafc4911c0a95171df6480cf754
5
5
  SHA512:
6
- metadata.gz: a3d6558cd4d7bbc1d8c6cdcb0500dec28eb8d451b9a92086db9cb70fec0ebf6f183c5a0b2b31287c364f9f322b3c9ad303f12b9826c808723684bab713e79563
7
- data.tar.gz: 7ed0b3255a67e3d8016dc0a6a0769cbd95f960f6a6324ec79a27f16026e08dd3b3e9bb8e28d728797a72e6eca8b1ab73646ff815bae32a52358481c0501b864d
6
+ metadata.gz: 4d4f7fb37bd10399053c026ff92545c5a1d600447cb94b3b35439fb37008154687c09f1834115afe4ed5cddc55fe84b458db955fcd4dbd0140444ffdaa01f8a9
7
+ data.tar.gz: 39d5ac62e456654550f70989e18dd3b122d3167aefc4a6b55ed5dc2ffd22c8f2b51c2f8261b2e4c009310acc2001be1a8f6ab6b0651850a45cc49cf0319ba6b1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.11.0.beta1] - 2023-04-14
6
+
7
+ As of ddtrace 1.11.0.beta1, CPU Profiling 2.0 is now GA and enabled by default. For more details, check the release notes.
8
+
9
+ As of ddtrace 1.11.0.beta1, Remote Configuration is now public beta and disabled by default. For more details, check the release notes.
10
+
11
+ ### Added
12
+
13
+ * Add remote configuration beta, disabled by default ([#2674][], [#2678][], [#2686][], [#2687][], [#2688][], [#2689][], [#2696][], [#2705][], [#2731][], [#2732][], [#2733][], [#2739][], [#2756][], [#2769][], [#2771][], [#2773][], [#2789][])
14
+ * AppSec: Add response headers passing to WAF ([#2701][])
15
+ * Tracing: Distributed tracing for Sidekiq ([#2513][])
16
+ * Tracing: Add Roda integration ([#2368][])
17
+ * Profiling: [PROF-6555] Support disabling endpoint names collection in new profiler ([#2698][])
18
+
19
+ ### Changed
20
+
21
+ * Core: Allow `1` as true value in environment variables ([#2710][])
22
+ * Profiling: [PROF-7360] Enable CPU Profiling 2.0 by default ([#2702][])
23
+ * Tracing: Improve controller instrumentation and deprecate option `exception_controller` ([#2726][])
24
+ * Tracing: Implement Span Attribute Schema Environment Variable ([#2727][])
25
+
26
+ ### Fixed
27
+
28
+ * Bug: Tracing: Fix w3c propagation special character handling ([#2720][])
29
+ * Performance: Tracing: Use `+@` instead of `dup` for duplicating strings ([#2704][])
30
+ * Profiling: [PROF-7307] Avoid triggering allocation sampling during sampling ([#2690][])
31
+ * Integrations: Tracing: Fix Rails < 3 conditional check in Utils#railtie_supported? ([#2695][])
32
+ * Profiling: [PROF-7409] Do not auto-enable new profiler when rugged gem is detected ([#2741][])
33
+ * Tracing: Fix using SemanticLogger#log(severity, message, progname) ([#2748][]) ([@rqz13][])
34
+ * Profiling: [PROF-6447] Improve detection of mysql2 gem incompatibilities with profiler ([#2770][])
35
+ * AppSec: Remove check for `::Rack::Request.instance_methods.include?(:each_header)` at load time ([#2778][])
36
+ * Tracing: Fix quadratic backtracking on invalid URI ([#2788][])
37
+
38
+ ## [1.10.1] - 2023-03-10
39
+
40
+ ### Fixed
41
+
42
+ * CI: Update TeamCity environment variable support ([#2668][])
43
+ * Core: Fix spurious dependency on AppSec when loading CI with `require 'datadog/ci'` ([#2679][])
44
+ * Core: Allow multiple headers and multiple IPs per header for client IP ([#2665][])
45
+ * AppSec: prevent side-effect on AppSec login event tracking method arguments ([#2663][]) ([@coneill-enhance][])
46
+
5
47
  ## [1.10.0] - 2023-03-06
6
48
 
7
49
  ### Added
@@ -2314,7 +2356,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
2314
2356
 
2315
2357
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2316
2358
 
2317
- [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.0...master
2359
+ [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.11.0.beta1...master
2360
+ [1.11.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0.beta1
2361
+ [1.10.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.0...v1.10.1
2318
2362
  [1.10.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.9.0...v1.10.0
2319
2363
  [1.9.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.8.0...v1.9.0
2320
2364
  [1.8.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.7.0...v1.8.0
@@ -3251,6 +3295,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3251
3295
  [#2363]: https://github.com/DataDog/dd-trace-rb/issues/2363
3252
3296
  [#2365]: https://github.com/DataDog/dd-trace-rb/issues/2365
3253
3297
  [#2367]: https://github.com/DataDog/dd-trace-rb/issues/2367
3298
+ [#2368]: https://github.com/DataDog/dd-trace-rb/issues/2368
3254
3299
  [#2378]: https://github.com/DataDog/dd-trace-rb/issues/2378
3255
3300
  [#2382]: https://github.com/DataDog/dd-trace-rb/issues/2382
3256
3301
  [#2390]: https://github.com/DataDog/dd-trace-rb/issues/2390
@@ -3283,6 +3328,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3283
3328
  [#2501]: https://github.com/DataDog/dd-trace-rb/issues/2501
3284
3329
  [#2504]: https://github.com/DataDog/dd-trace-rb/issues/2504
3285
3330
  [#2512]: https://github.com/DataDog/dd-trace-rb/issues/2512
3331
+ [#2513]: https://github.com/DataDog/dd-trace-rb/issues/2513
3286
3332
  [#2522]: https://github.com/DataDog/dd-trace-rb/issues/2522
3287
3333
  [#2526]: https://github.com/DataDog/dd-trace-rb/issues/2526
3288
3334
  [#2530]: https://github.com/DataDog/dd-trace-rb/issues/2530
@@ -3321,6 +3367,42 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3321
3367
  [#2657]: https://github.com/DataDog/dd-trace-rb/issues/2657
3322
3368
  [#2659]: https://github.com/DataDog/dd-trace-rb/issues/2659
3323
3369
  [#2662]: https://github.com/DataDog/dd-trace-rb/issues/2662
3370
+ [#2663]: https://github.com/DataDog/dd-trace-rb/issues/2663
3371
+ [#2665]: https://github.com/DataDog/dd-trace-rb/issues/2665
3372
+ [#2668]: https://github.com/DataDog/dd-trace-rb/issues/2668
3373
+ [#2674]: https://github.com/DataDog/dd-trace-rb/issues/2674
3374
+ [#2678]: https://github.com/DataDog/dd-trace-rb/issues/2678
3375
+ [#2679]: https://github.com/DataDog/dd-trace-rb/issues/2679
3376
+ [#2686]: https://github.com/DataDog/dd-trace-rb/issues/2686
3377
+ [#2687]: https://github.com/DataDog/dd-trace-rb/issues/2687
3378
+ [#2688]: https://github.com/DataDog/dd-trace-rb/issues/2688
3379
+ [#2689]: https://github.com/DataDog/dd-trace-rb/issues/2689
3380
+ [#2690]: https://github.com/DataDog/dd-trace-rb/issues/2690
3381
+ [#2695]: https://github.com/DataDog/dd-trace-rb/issues/2695
3382
+ [#2696]: https://github.com/DataDog/dd-trace-rb/issues/2696
3383
+ [#2698]: https://github.com/DataDog/dd-trace-rb/issues/2698
3384
+ [#2701]: https://github.com/DataDog/dd-trace-rb/issues/2701
3385
+ [#2702]: https://github.com/DataDog/dd-trace-rb/issues/2702
3386
+ [#2704]: https://github.com/DataDog/dd-trace-rb/issues/2704
3387
+ [#2705]: https://github.com/DataDog/dd-trace-rb/issues/2705
3388
+ [#2710]: https://github.com/DataDog/dd-trace-rb/issues/2710
3389
+ [#2720]: https://github.com/DataDog/dd-trace-rb/issues/2720
3390
+ [#2726]: https://github.com/DataDog/dd-trace-rb/issues/2726
3391
+ [#2727]: https://github.com/DataDog/dd-trace-rb/issues/2727
3392
+ [#2731]: https://github.com/DataDog/dd-trace-rb/issues/2731
3393
+ [#2732]: https://github.com/DataDog/dd-trace-rb/issues/2732
3394
+ [#2733]: https://github.com/DataDog/dd-trace-rb/issues/2733
3395
+ [#2739]: https://github.com/DataDog/dd-trace-rb/issues/2739
3396
+ [#2741]: https://github.com/DataDog/dd-trace-rb/issues/2741
3397
+ [#2748]: https://github.com/DataDog/dd-trace-rb/issues/2748
3398
+ [#2756]: https://github.com/DataDog/dd-trace-rb/issues/2756
3399
+ [#2769]: https://github.com/DataDog/dd-trace-rb/issues/2769
3400
+ [#2770]: https://github.com/DataDog/dd-trace-rb/issues/2770
3401
+ [#2771]: https://github.com/DataDog/dd-trace-rb/issues/2771
3402
+ [#2773]: https://github.com/DataDog/dd-trace-rb/issues/2773
3403
+ [#2778]: https://github.com/DataDog/dd-trace-rb/issues/2778
3404
+ [#2788]: https://github.com/DataDog/dd-trace-rb/issues/2788
3405
+ [#2789]: https://github.com/DataDog/dd-trace-rb/issues/2789
3324
3406
  [@AdrianLC]: https://github.com/AdrianLC
3325
3407
  [@Azure7111]: https://github.com/Azure7111
3326
3408
  [@BabyGroot]: https://github.com/BabyGroot
@@ -3365,6 +3447,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3365
3447
  [@cjford]: https://github.com/cjford
3366
3448
  [@ck3g]: https://github.com/ck3g
3367
3449
  [@components]: https://github.com/components
3450
+ [@coneill-enhance]: https://github.com/coneill-enhance
3368
3451
  [@cswatt]: https://github.com/cswatt
3369
3452
  [@cwoodcox]: https://github.com/cwoodcox
3370
3453
  [@danhodge]: https://github.com/danhodge
@@ -3441,6 +3524,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3441
3524
  [@renchap]: https://github.com/renchap
3442
3525
  [@ricbartm]: https://github.com/ricbartm
3443
3526
  [@roccoblues]: https://github.com/roccoblues
3527
+ [@rqz13]: https://github.com/rqz13
3444
3528
  [@saturnflyer]: https://github.com/saturnflyer
3445
3529
  [@sco11morgan]: https://github.com/sco11morgan
3446
3530
  [@senny]: https://github.com/senny
@@ -3466,4 +3550,4 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3466
3550
  [@y-yagi]: https://github.com/y-yagi
3467
3551
  [@yujideveloper]: https://github.com/yujideveloper
3468
3552
  [@yukimurasawa]: https://github.com/yukimurasawa
3469
- [@zachmccormick]: https://github.com/zachmccormick
3553
+ [@zachmccormick]: https://github.com/zachmccormick
data/LICENSE-3rdparty.csv CHANGED
@@ -5,3 +5,4 @@ lib/datadog/tracing/contrib/utils/quantization/http.rb,https://github.com/ruby/u
5
5
  ext/ddtrace_profiling_native_extension/private_vm_api_access,https://github.com/ruby/ruby,BSD-2-Clause,"Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved."
6
6
  msgpack,https://rubygems.org/gems/msgpack,Apache-2.0,"Copyright (c) 2008-2015 Sadayuki Furuhashi"
7
7
  debase-ruby_core_source,https://rubygems.org/gems/debase-ruby_core_source,MIT for gem and BSD-2-Clause for Ruby sources,"Copyright (c) 2012 Gabriel Horner. Files from Ruby sources are Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved."
8
+ lib/datadog/core/vendor/ipaddr,https://github.com/ruby/ipaddr/blob/master/lib/ipaddr.rb,BSD 2-Clause "Simplified" License,"Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org> Copyright (c) 2007-2017 Akinori MUSHA <knu@iDaemons.org>"
data/README.md CHANGED
@@ -3,27 +3,26 @@
3
3
  [![Gem](https://img.shields.io/gem/v/ddtrace)](https://rubygems.org/gems/ddtrace/)
4
4
  [![CircleCI](https://circleci.com/gh/DataDog/dd-trace-rb/tree/master.svg?style=svg&circle-token=b0bd5ef866ec7f7b018f48731bb495f2d1372cc1)](https://circleci.com/gh/DataDog/dd-trace-rb/tree/master)
5
5
  [![codecov](https://codecov.io/gh/DataDog/dd-trace-rb/branch/master/graph/badge.svg)](https://app.codecov.io/gh/DataDog/dd-trace-rb/branch/master)
6
- [![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)](https://s3.amazonaws.com/gems.datadoghq.com/trace/docs/index.html)
6
+ [![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)][api docs]
7
7
 
8
8
  ``ddtrace`` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
9
- databases and microservices so that developers have great visiblity into bottlenecks and troublesome requests.
9
+ databases and microservices so that developers have great visibility into bottlenecks and troublesome requests.
10
10
 
11
11
  ## Getting started
12
12
 
13
13
  **If you're upgrading from a 0.x version, check out our [upgrade guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#from-0x-to-10).**
14
14
 
15
- For a basic product overview, check out our [setup documentation][setup docs].
15
+ For a product overview, installation, and configuration check out our [documentation][public docs].
16
16
 
17
- For installation, configuration, and details about using the API, check out our [API documentation][api docs] and [gem documentation][gem docs].
17
+ For the gem API, check out our [API documentation][api docs].
18
18
 
19
- For descriptions of terminology used in APM, take a look at the [official documentation][visualization docs].
19
+ For descriptions of terminology used in APM, take a look at the [APM Terms and Concepts][APM glossary].
20
20
 
21
21
  For contributing, checkout the [contribution guidelines][contribution docs] and [development guide][development docs].
22
22
 
23
- [setup docs]: https://docs.datadoghq.com/tracing/setup/ruby/
24
- [api docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md
25
- [gem docs]: https://s3.amazonaws.com/gems.datadoghq.com/trace/docs/index.html
26
- [visualization docs]: https://docs.datadoghq.com/tracing/visualization/
23
+ [public docs]: https://docs.datadoghq.com/tracing/setup/ruby/
24
+ [api docs]: https://datadog.github.io/dd-trace-rb/
25
+ [APM glossary]: https://docs.datadoghq.com/tracing/glossary/
27
26
  [contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
28
27
  [development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
29
28
 
@@ -77,26 +77,33 @@
77
77
 
78
78
  // Contains state for a single CpuAndWallTimeWorker instance
79
79
  struct cpu_and_wall_time_worker_state {
80
- atomic_bool should_run;
80
+ // These are immutable after initialization
81
81
 
82
82
  bool gc_profiling_enabled;
83
83
  bool allocation_counting_enabled;
84
+ bool dynamic_sampling_rate_enabled;
84
85
  VALUE self_instance;
85
86
  VALUE thread_context_collector_instance;
86
87
  VALUE idle_sampling_helper_instance;
87
88
  VALUE owner_thread;
88
89
  dynamic_sampling_rate_state dynamic_sampling_rate;
90
+ VALUE gc_tracepoint; // Used to get gc start/finish information
91
+ VALUE object_allocation_tracepoint; // Used to get allocation counts and allocation profiling
92
+
93
+ // These are mutable and used to signal things between the worker thread and other threads
89
94
 
95
+ atomic_bool should_run;
90
96
  // When something goes wrong during sampling, we record the Ruby exception here, so that it can be "re-raised" on
91
97
  // the CpuAndWallTimeWorker thread
92
98
  VALUE failure_exception;
93
99
  // Used by `_native_stop` to flag the worker thread to start (see comment on `_native_sampling_loop`)
94
100
  VALUE stop_thread;
95
101
 
96
- // Used to get gc start/finish information
97
- VALUE gc_tracepoint;
102
+ // Others
98
103
 
99
- VALUE object_allocation_tracepoint;
104
+ // Used to detect/avoid nested sampling, e.g. when the object_allocation_tracepoint gets triggered by a memory allocation
105
+ // that happens during another sample.
106
+ bool during_sample;
100
107
 
101
108
  struct stats {
102
109
  // How many times we tried to trigger a sample
@@ -115,6 +122,8 @@ struct cpu_and_wall_time_worker_state {
115
122
  uint64_t sampling_time_ns_min;
116
123
  uint64_t sampling_time_ns_max;
117
124
  uint64_t sampling_time_ns_total;
125
+ // How many times we saw allocations being done inside a sample
126
+ unsigned int allocations_during_sample;
118
127
  } stats;
119
128
  };
120
129
 
@@ -125,7 +134,8 @@ static VALUE _native_initialize(
125
134
  VALUE thread_context_collector_instance,
126
135
  VALUE gc_profiling_enabled,
127
136
  VALUE idle_sampling_helper_instance,
128
- VALUE allocation_counting_enabled
137
+ VALUE allocation_counting_enabled,
138
+ VALUE dynamic_sampling_rate_enabled
129
139
  );
130
140
  static void cpu_and_wall_time_worker_typed_data_mark(void *state_ptr);
131
141
  static VALUE _native_sampling_loop(VALUE self, VALUE instance);
@@ -160,6 +170,7 @@ static void sleep_for(uint64_t time_ns);
160
170
  static VALUE _native_allocation_count(DDTRACE_UNUSED VALUE self);
161
171
  static void on_newobj_event(DDTRACE_UNUSED VALUE tracepoint_data, DDTRACE_UNUSED void *unused);
162
172
  static void disable_tracepoints(struct cpu_and_wall_time_worker_state *state);
173
+ static VALUE _native_with_blocked_sigprof(DDTRACE_UNUSED VALUE self);
163
174
 
164
175
  // Note on sampler global state safety:
165
176
  //
@@ -197,7 +208,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
197
208
  // https://bugs.ruby-lang.org/issues/18007 for a discussion around this.
198
209
  rb_define_alloc_func(collectors_cpu_and_wall_time_worker_class, _native_new);
199
210
 
200
- rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize, 5);
211
+ rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize, 6);
201
212
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_sampling_loop", _native_sampling_loop, 1);
202
213
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_stop", _native_stop, 2);
203
214
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_reset_after_fork", _native_reset_after_fork, 1);
@@ -212,6 +223,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
212
223
  rb_define_singleton_method(testing_module, "_native_simulate_handle_sampling_signal", _native_simulate_handle_sampling_signal, 0);
213
224
  rb_define_singleton_method(testing_module, "_native_simulate_sample_from_postponed_job", _native_simulate_sample_from_postponed_job, 0);
214
225
  rb_define_singleton_method(testing_module, "_native_is_sigprof_blocked_in_current_thread", _native_is_sigprof_blocked_in_current_thread, 0);
226
+ rb_define_singleton_method(testing_module, "_native_with_blocked_sigprof", _native_with_blocked_sigprof, 0);
215
227
  }
216
228
 
217
229
  // This structure is used to define a Ruby object that stores a pointer to a struct cpu_and_wall_time_worker_state
@@ -230,17 +242,22 @@ static const rb_data_type_t cpu_and_wall_time_worker_typed_data = {
230
242
  static VALUE _native_new(VALUE klass) {
231
243
  struct cpu_and_wall_time_worker_state *state = ruby_xcalloc(1, sizeof(struct cpu_and_wall_time_worker_state));
232
244
 
233
- atomic_init(&state->should_run, false);
234
245
  state->gc_profiling_enabled = false;
235
246
  state->allocation_counting_enabled = false;
247
+ state->dynamic_sampling_rate_enabled = true;
236
248
  state->thread_context_collector_instance = Qnil;
237
249
  state->idle_sampling_helper_instance = Qnil;
238
250
  state->owner_thread = Qnil;
239
251
  dynamic_sampling_rate_init(&state->dynamic_sampling_rate);
240
- state->failure_exception = Qnil;
241
- state->stop_thread = Qnil;
242
252
  state->gc_tracepoint = Qnil;
243
253
  state->object_allocation_tracepoint = Qnil;
254
+
255
+ atomic_init(&state->should_run, false);
256
+ state->failure_exception = Qnil;
257
+ state->stop_thread = Qnil;
258
+
259
+ state->during_sample = false;
260
+
244
261
  reset_stats(state);
245
262
 
246
263
  return state->self_instance = TypedData_Wrap_Struct(klass, &cpu_and_wall_time_worker_typed_data, state);
@@ -252,16 +269,19 @@ static VALUE _native_initialize(
252
269
  VALUE thread_context_collector_instance,
253
270
  VALUE gc_profiling_enabled,
254
271
  VALUE idle_sampling_helper_instance,
255
- VALUE allocation_counting_enabled
272
+ VALUE allocation_counting_enabled,
273
+ VALUE dynamic_sampling_rate_enabled
256
274
  ) {
257
275
  ENFORCE_BOOLEAN(gc_profiling_enabled);
258
276
  ENFORCE_BOOLEAN(allocation_counting_enabled);
277
+ ENFORCE_BOOLEAN(dynamic_sampling_rate_enabled);
259
278
 
260
279
  struct cpu_and_wall_time_worker_state *state;
261
280
  TypedData_Get_Struct(self_instance, struct cpu_and_wall_time_worker_state, &cpu_and_wall_time_worker_typed_data, state);
262
281
 
263
282
  state->gc_profiling_enabled = (gc_profiling_enabled == Qtrue);
264
283
  state->allocation_counting_enabled = (allocation_counting_enabled == Qtrue);
284
+ state->dynamic_sampling_rate_enabled = (dynamic_sampling_rate_enabled == Qtrue);
265
285
  state->thread_context_collector_instance = enforce_thread_context_collector_instance(thread_context_collector_instance);
266
286
  state->idle_sampling_helper_instance = idle_sampling_helper_instance;
267
287
  state->gc_tracepoint = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_GC_ENTER | RUBY_INTERNAL_EVENT_GC_EXIT, on_gc_event, NULL /* unused */);
@@ -460,7 +480,7 @@ static void *run_sampling_trigger_loop(void *state_ptr) {
460
480
  // `dynamic_sampling_rate_get_sleep` may have changed while the above sleep was ongoing.
461
481
  uint64_t extra_sleep =
462
482
  dynamic_sampling_rate_get_sleep(&state->dynamic_sampling_rate, monotonic_wall_time_now_ns(DO_NOT_RAISE_ON_FAILURE));
463
- if (extra_sleep > 0) sleep_for(extra_sleep);
483
+ if (state->dynamic_sampling_rate_enabled && extra_sleep > 0) sleep_for(extra_sleep);
464
484
  }
465
485
 
466
486
  return NULL; // Unused
@@ -485,8 +505,12 @@ static void sample_from_postponed_job(DDTRACE_UNUSED void *_unused) {
485
505
  return; // We're not on the main Ractor; we currently don't support profiling non-main Ractors
486
506
  }
487
507
 
508
+ state->during_sample = true;
509
+
488
510
  // Rescue against any exceptions that happen during sampling
489
511
  safely_call(rescued_sample_from_postponed_job, state->self_instance, state->self_instance);
512
+
513
+ state->during_sample = false;
490
514
  }
491
515
 
492
516
  static VALUE rescued_sample_from_postponed_job(VALUE self_instance) {
@@ -672,8 +696,12 @@ static void after_gc_from_postponed_job(DDTRACE_UNUSED void *_unused) {
672
696
  return; // We're not on the main Ractor; we currently don't support profiling non-main Ractors
673
697
  }
674
698
 
699
+ state->during_sample = true;
700
+
675
701
  // Trigger sampling using the Collectors::ThreadState; rescue against any exceptions that happen during sampling
676
702
  safely_call(thread_context_collector_sample_after_gc, state->thread_context_collector_instance, state->self_instance);
703
+
704
+ state->during_sample = false;
677
705
  }
678
706
 
679
707
  // Equivalent to Ruby begin/rescue call, where we call a C function and jump to the exception handler if an
@@ -753,6 +781,7 @@ static VALUE _native_stats(DDTRACE_UNUSED VALUE self, VALUE instance) {
753
781
  ID2SYM(rb_intern("sampling_time_ns_max")), /* => */ pretty_sampling_time_ns_max,
754
782
  ID2SYM(rb_intern("sampling_time_ns_total")), /* => */ pretty_sampling_time_ns_total,
755
783
  ID2SYM(rb_intern("sampling_time_ns_avg")), /* => */ pretty_sampling_time_ns_avg,
784
+ ID2SYM(rb_intern("allocations_during_sample")), /* => */ UINT2NUM(state->stats.allocations_during_sample),
756
785
  };
757
786
  for (long unsigned int i = 0; i < VALUE_COUNT(arguments); i += 2) rb_hash_aset(stats_as_hash, arguments[i], arguments[i+1]);
758
787
  return stats_as_hash;
@@ -813,9 +842,45 @@ static void on_newobj_event(DDTRACE_UNUSED VALUE tracepoint_data, DDTRACE_UNUSED
813
842
  } else {
814
843
  allocation_count++;
815
844
  }
845
+
846
+ struct cpu_and_wall_time_worker_state *state = active_sampler_instance_state; // Read from global variable, see "sampler global state safety" note above
847
+
848
+ // This should not happen in a normal situation because the tracepoint is always enabled after the instance is set
849
+ // and disabled before it is cleared, but just in case...
850
+ if (state == NULL) return;
851
+
852
+ // In a few cases, we may actually be allocating an object as part of profiler sampling. We don't want to recursively
853
+ // sample, so we just return early
854
+ if (state->during_sample) {
855
+ state->stats.allocations_during_sample++;
856
+ return;
857
+ }
858
+
859
+ // @ivoanjo: Strictly speaking, this is not needed because Ruby should not call the same tracepoint while a previous
860
+ // invocation is still pending, (e.g. it wouldn't call `on_newobj_event` while it's already running), but I decided
861
+ // to keep this here for consistency -- every call to the thread context (other than the special gc calls which are
862
+ // defined as not being able to allocate) sets this.
863
+ state->during_sample = true;
864
+
865
+ // TODO: Sampling goes here (calling into `thread_context_collector_sample_allocation`)
866
+
867
+ state->during_sample = false;
816
868
  }
817
869
 
818
870
  static void disable_tracepoints(struct cpu_and_wall_time_worker_state *state) {
819
871
  rb_tracepoint_disable(state->gc_tracepoint);
820
872
  rb_tracepoint_disable(state->object_allocation_tracepoint);
821
873
  }
874
+
875
+ static VALUE _native_with_blocked_sigprof(DDTRACE_UNUSED VALUE self) {
876
+ block_sigprof_signal_handler_from_running_in_current_thread();
877
+ int exception_state;
878
+ VALUE result = rb_protect(rb_yield, Qundef, &exception_state);
879
+ unblock_sigprof_signal_handler_from_running_in_current_thread();
880
+
881
+ if (exception_state) {
882
+ rb_jump_tag(exception_state);
883
+ } else {
884
+ return result;
885
+ }
886
+ }
@@ -97,6 +97,8 @@ struct thread_context_collector_state {
97
97
  unsigned int sample_count;
98
98
  // Reusable array to get list of threads
99
99
  VALUE thread_list_buffer;
100
+ // Used to omit endpoint names (retrieved from tracer) from collected data
101
+ bool endpoint_collection_enabled;
100
102
 
101
103
  struct stats {
102
104
  // Track how many garbage collection samples we've taken.
@@ -140,7 +142,14 @@ static void thread_context_collector_typed_data_free(void *state_ptr);
140
142
  static int hash_map_per_thread_context_mark(st_data_t key_thread, st_data_t _value, st_data_t _argument);
141
143
  static int hash_map_per_thread_context_free_values(st_data_t _thread, st_data_t value_per_thread_context, st_data_t _argument);
142
144
  static VALUE _native_new(VALUE klass);
143
- static VALUE _native_initialize(VALUE self, VALUE collector_instance, VALUE recorder_instance, VALUE max_frames, VALUE tracer_context_key);
145
+ static VALUE _native_initialize(
146
+ VALUE self,
147
+ VALUE collector_instance,
148
+ VALUE recorder_instance,
149
+ VALUE max_frames,
150
+ VALUE tracer_context_key,
151
+ VALUE endpoint_collection_enabled
152
+ );
144
153
  static VALUE _native_sample(VALUE self, VALUE collector_instance, VALUE profiler_overhead_stack_thread);
145
154
  static VALUE _native_on_gc_start(VALUE self, VALUE collector_instance);
146
155
  static VALUE _native_on_gc_finish(VALUE self, VALUE collector_instance);
@@ -198,7 +207,7 @@ void collectors_thread_context_init(VALUE profiling_module) {
198
207
  // https://bugs.ruby-lang.org/issues/18007 for a discussion around this.
199
208
  rb_define_alloc_func(collectors_thread_context_class, _native_new);
200
209
 
201
- rb_define_singleton_method(collectors_thread_context_class, "_native_initialize", _native_initialize, 4);
210
+ rb_define_singleton_method(collectors_thread_context_class, "_native_initialize", _native_initialize, 5);
202
211
  rb_define_singleton_method(collectors_thread_context_class, "_native_inspect", _native_inspect, 1);
203
212
  rb_define_singleton_method(collectors_thread_context_class, "_native_reset_after_fork", _native_reset_after_fork, 1);
204
213
  rb_define_singleton_method(testing_module, "_native_sample", _native_sample, 2);
@@ -284,11 +293,21 @@ static VALUE _native_new(VALUE klass) {
284
293
  state->recorder_instance = Qnil;
285
294
  state->tracer_context_key = MISSING_TRACER_CONTEXT_KEY;
286
295
  state->thread_list_buffer = rb_ary_new();
296
+ state->endpoint_collection_enabled = true;
287
297
 
288
298
  return TypedData_Wrap_Struct(klass, &thread_context_collector_typed_data, state);
289
299
  }
290
300
 
291
- static VALUE _native_initialize(DDTRACE_UNUSED VALUE _self, VALUE collector_instance, VALUE recorder_instance, VALUE max_frames, VALUE tracer_context_key) {
301
+ static VALUE _native_initialize(
302
+ DDTRACE_UNUSED VALUE _self,
303
+ VALUE collector_instance,
304
+ VALUE recorder_instance,
305
+ VALUE max_frames,
306
+ VALUE tracer_context_key,
307
+ VALUE endpoint_collection_enabled
308
+ ) {
309
+ ENFORCE_BOOLEAN(endpoint_collection_enabled);
310
+
292
311
  struct thread_context_collector_state *state;
293
312
  TypedData_Get_Struct(collector_instance, struct thread_context_collector_state, &thread_context_collector_typed_data, state);
294
313
 
@@ -299,6 +318,7 @@ static VALUE _native_initialize(DDTRACE_UNUSED VALUE _self, VALUE collector_inst
299
318
  state->sampling_buffer = sampling_buffer_new(max_frames_requested);
300
319
  // hash_map_per_thread_context is already initialized, nothing to do here
301
320
  state->recorder_instance = enforce_recorder_instance(recorder_instance);
321
+ state->endpoint_collection_enabled = (endpoint_collection_enabled == Qtrue);
302
322
 
303
323
  if (RTEST(tracer_context_key)) {
304
324
  ENFORCE_TYPE(tracer_context_key, T_SYMBOL);
@@ -732,6 +752,7 @@ static VALUE _native_inspect(DDTRACE_UNUSED VALUE _self, VALUE collector_instanc
732
752
  rb_str_concat(result, rb_sprintf(" tracer_context_key=%+"PRIsVALUE, tracer_context_key));
733
753
  rb_str_concat(result, rb_sprintf(" sample_count=%u", state->sample_count));
734
754
  rb_str_concat(result, rb_sprintf(" stats=%"PRIsVALUE, stats_as_ruby_hash(state)));
755
+ rb_str_concat(result, rb_sprintf(" endpoint_collection_enabled=%"PRIsVALUE, state->endpoint_collection_enabled ? Qtrue : Qfalse));
735
756
 
736
757
  return result;
737
758
  }
@@ -911,6 +932,8 @@ static void trace_identifiers_for(struct thread_context_collector_state *state,
911
932
 
912
933
  trace_identifiers_result->valid = true;
913
934
 
935
+ if (!state->endpoint_collection_enabled) return;
936
+
914
937
  VALUE root_span_type = rb_ivar_get(root_span, at_type_id /* @type */);
915
938
  if (root_span_type == Qnil || !is_type_web(root_span_type)) return;
916
939
 
@@ -19,6 +19,8 @@
19
19
  #pragma GCC diagnostic push
20
20
  #pragma GCC diagnostic ignored "-Wunused-parameter"
21
21
  #pragma GCC diagnostic ignored "-Wattributes"
22
+ #pragma GCC diagnostic ignored "-Wpragmas"
23
+ #pragma GCC diagnostic ignored "-Wexpansion-to-defined"
22
24
  #include <vm_core.h>
23
25
  #pragma GCC diagnostic pop
24
26
  #include <iseq.h>
@@ -651,6 +653,7 @@ check_method_entry(VALUE obj, int can_be_svar)
651
653
  if (can_be_svar) {
652
654
  return check_method_entry(((struct vm_svar *)obj)->cref_or_me, FALSE);
653
655
  }
656
+ // fallthrough
654
657
  default:
655
658
  #if VM_CHECK_MODE > 0
656
659
  rb_bug("check_method_entry: svar should not be there:");
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'processor'
4
+ require_relative 'processor/rule_merger'
5
+ require_relative 'processor/rule_loader'
4
6
 
5
7
  module Datadog
6
8
  module AppSec
@@ -8,16 +10,29 @@ module Datadog
8
10
  class Component
9
11
  class << self
10
12
  def build_appsec_component(settings)
11
- return unless settings.enabled
13
+ return unless settings.respond_to?(:appsec) && settings.appsec.enabled
12
14
 
13
- processor = create_processor
15
+ processor = create_processor(settings)
14
16
  new(processor: processor)
15
17
  end
16
18
 
17
19
  private
18
20
 
19
- def create_processor
20
- processor = Processor.new
21
+ def create_processor(settings)
22
+ rules = AppSec::Processor::RuleLoader.load_rules(ruleset: settings.appsec.ruleset)
23
+ return nil unless rules
24
+
25
+ data = AppSec::Processor::RuleLoader.load_data(
26
+ ip_denylist: settings.appsec.ip_denylist,
27
+ user_id_denylist: settings.appsec.user_id_denylist
28
+ )
29
+
30
+ ruleset = AppSec::Processor::RuleMerger.merge(
31
+ rules: [rules],
32
+ data: data,
33
+ )
34
+
35
+ processor = Processor.new(ruleset: ruleset)
21
36
  return nil unless processor.ready?
22
37
 
23
38
  processor
@@ -28,12 +43,31 @@ module Datadog
28
43
 
29
44
  def initialize(processor:)
30
45
  @processor = processor
46
+ @mutex = Mutex.new
47
+ end
48
+
49
+ def reconfigure(ruleset:)
50
+ @mutex.synchronize do
51
+ new = Processor.new(ruleset: ruleset)
52
+
53
+ if new && new.ready?
54
+ old = @processor
55
+ @processor = new
56
+ old.finalize
57
+ end
58
+ end
59
+ end
60
+
61
+ def reconfigure_lock(&block)
62
+ @mutex.synchronize(&block)
31
63
  end
32
64
 
33
65
  def shutdown!
34
- if processor && processor.ready?
35
- processor.finalize
36
- @processor = nil
66
+ @mutex.synchronize do
67
+ if processor && processor.ready?
68
+ processor.finalize
69
+ @processor = nil
70
+ end
37
71
  end
38
72
  end
39
73
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+
1
5
  module Datadog
2
6
  module AppSec
3
7
  module Configuration
@@ -87,8 +91,8 @@ module Datadog
87
91
  end
88
92
 
89
93
  # rubocop:disable Layout/LineLength
90
- DEFAULT_OBFUSCATOR_KEY_REGEX = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?)key)|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization'.freeze
91
- DEFAULT_OBFUSCATOR_VALUE_REGEX = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\s*=[^;]|"\s*:\s*"[^"]+")|bearer\s+[a-z0-9\._\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\w=-]+\.ey[I-L][\w=-]+(?:\.[\w.+\/=-]+)?|[\-]{5}BEGIN[a-z\s]+PRIVATE\sKEY[\-]{5}[^\-]+[\-]{5}END[a-z\s]+PRIVATE\sKEY|ssh-rsa\s*[a-z0-9\/\.+]{100,}'.freeze
94
+ DEFAULT_OBFUSCATOR_KEY_REGEX = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?)key)|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization'
95
+ DEFAULT_OBFUSCATOR_VALUE_REGEX = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\s*=[^;]|"\s*:\s*"[^"]+")|bearer\s+[a-z0-9\._\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\w=-]+\.ey[I-L][\w=-]+(?:\.[\w.+\/=-]+)?|[\-]{5}BEGIN[a-z\s]+PRIVATE\sKEY[\-]{5}[^\-]+[\-]{5}END[a-z\s]+PRIVATE\sKEY|ssh-rsa\s*[a-z0-9\/\.+]{100,}'
92
96
  # rubocop:enable Layout/LineLength
93
97
 
94
98
  DEFAULTS = {
@@ -116,9 +120,14 @@ module Datadog
116
120
 
117
121
  def initialize
118
122
  @integrations = []
123
+ # Stores which options have been configured using Datadog.configure block or ENV variables
124
+ @configured = Set.new
119
125
  @options = DEFAULTS.dup.tap do |options|
120
126
  ENVS.each do |env, (key, conv)|
121
- options[key] = conv.call(ENV[env]) if ENV[env]
127
+ if ENV[env]
128
+ options[key] = conv.call(ENV[env])
129
+ @configured << key
130
+ end
122
131
  end
123
132
  end
124
133
  end
@@ -182,7 +191,10 @@ module Datadog
182
191
 
183
192
  def merge(dsl)
184
193
  dsl.options.each do |k, v|
185
- @options[k] = v unless v.nil?
194
+ unless v.nil?
195
+ @options[k] = v
196
+ @configured << k
197
+ end
186
198
  end
187
199
 
188
200
  return self unless @options[:enabled]
@@ -206,6 +218,10 @@ module Datadog
206
218
 
207
219
  private
208
220
 
221
+ def default?(option)
222
+ !@configured.include?(option)
223
+ end
224
+
209
225
  # Restore to original state, for testing only.
210
226
  def reset!
211
227
  initialize