ddtrace 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +125 -1
  3. data/README.md +8 -10
  4. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +110 -18
  5. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +26 -3
  6. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -0
  7. data/lib/datadog/appsec/component.rb +40 -6
  8. data/lib/datadog/appsec/configuration/settings.rb +20 -4
  9. data/lib/datadog/appsec/configuration.rb +8 -0
  10. data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -0
  11. data/lib/datadog/appsec/contrib/configuration/settings.rb +2 -0
  12. data/lib/datadog/appsec/contrib/integration.rb +2 -0
  13. data/lib/datadog/appsec/contrib/patcher.rb +2 -0
  14. data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -0
  15. data/lib/datadog/appsec/contrib/rack/gateway/request.rb +4 -15
  16. data/lib/datadog/appsec/contrib/rack/gateway/response.rb +1 -1
  17. data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -0
  18. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -0
  19. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +17 -4
  20. data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -0
  21. data/lib/datadog/appsec/contrib/rails/framework.rb +2 -0
  22. data/lib/datadog/appsec/contrib/rails/gateway/request.rb +1 -1
  23. data/lib/datadog/appsec/contrib/rails/request.rb +2 -0
  24. data/lib/datadog/appsec/contrib/rails/request_middleware.rb +2 -0
  25. data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -0
  26. data/lib/datadog/appsec/contrib/sinatra/framework.rb +2 -0
  27. data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +1 -1
  28. data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +2 -0
  29. data/lib/datadog/appsec/extensions.rb +2 -0
  30. data/lib/datadog/appsec/instrumentation/gateway/argument.rb +2 -4
  31. data/lib/datadog/appsec/processor/rule_loader.rb +63 -0
  32. data/lib/datadog/appsec/processor/rule_merger.rb +146 -0
  33. data/lib/datadog/appsec/processor.rb +15 -70
  34. data/lib/datadog/appsec/remote.rb +121 -0
  35. data/lib/datadog/appsec/utils/http.rb +2 -0
  36. data/lib/datadog/appsec/utils.rb +2 -0
  37. data/lib/datadog/appsec.rb +18 -4
  38. data/lib/datadog/ci/configuration/components.rb +2 -0
  39. data/lib/datadog/ci/configuration/settings.rb +2 -0
  40. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -0
  41. data/lib/datadog/ci/contrib/cucumber/formatter.rb +2 -0
  42. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -0
  43. data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -0
  44. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -0
  45. data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -0
  46. data/lib/datadog/ci/extensions.rb +2 -0
  47. data/lib/datadog/ci/flush.rb +2 -0
  48. data/lib/datadog/ci.rb +2 -0
  49. data/lib/datadog/core/buffer/cruby.rb +2 -0
  50. data/lib/datadog/core/buffer/random.rb +2 -0
  51. data/lib/datadog/core/buffer/thread_safe.rb +2 -0
  52. data/lib/datadog/core/chunker.rb +2 -0
  53. data/lib/datadog/core/configuration/agent_settings_resolver.rb +68 -17
  54. data/lib/datadog/core/configuration/components.rb +11 -14
  55. data/lib/datadog/core/configuration/dependency_resolver.rb +2 -0
  56. data/lib/datadog/core/configuration/option.rb +2 -0
  57. data/lib/datadog/core/configuration/option_definition.rb +2 -0
  58. data/lib/datadog/core/configuration/option_definition_set.rb +2 -0
  59. data/lib/datadog/core/configuration/option_set.rb +2 -0
  60. data/lib/datadog/core/configuration/settings.rb +70 -16
  61. data/lib/datadog/core/diagnostics/health.rb +2 -0
  62. data/lib/datadog/core/environment/class_count.rb +2 -0
  63. data/lib/datadog/core/environment/gc.rb +2 -0
  64. data/lib/datadog/core/environment/identity.rb +58 -0
  65. data/lib/datadog/core/environment/socket.rb +2 -0
  66. data/lib/datadog/core/environment/thread_count.rb +2 -0
  67. data/lib/datadog/core/environment/variable_helpers.rb +10 -2
  68. data/lib/datadog/core/environment/vm_cache.rb +2 -0
  69. data/lib/datadog/core/extensions.rb +2 -0
  70. data/lib/datadog/core/header_collection.rb +2 -0
  71. data/lib/datadog/core/metrics/helpers.rb +2 -0
  72. data/lib/datadog/core/metrics/metric.rb +2 -0
  73. data/lib/datadog/core/remote/client/capabilities.rb +57 -0
  74. data/lib/datadog/core/remote/client.rb +225 -0
  75. data/lib/datadog/core/remote/component.rb +158 -0
  76. data/lib/datadog/core/remote/configuration/content.rb +84 -0
  77. data/lib/datadog/core/remote/configuration/digest.rb +62 -0
  78. data/lib/datadog/core/remote/configuration/path.rb +90 -0
  79. data/lib/datadog/core/remote/configuration/repository.rb +292 -0
  80. data/lib/datadog/core/remote/configuration/target.rb +74 -0
  81. data/lib/datadog/core/remote/configuration.rb +18 -0
  82. data/lib/datadog/core/remote/dispatcher.rb +59 -0
  83. data/lib/datadog/core/remote/ext.rb +12 -0
  84. data/lib/datadog/core/remote/negotiation.rb +57 -0
  85. data/lib/datadog/core/remote/worker.rb +96 -0
  86. data/lib/datadog/core/remote.rb +24 -0
  87. data/lib/datadog/core/telemetry/collector.rb +8 -9
  88. data/lib/datadog/core/telemetry/heartbeat.rb +2 -0
  89. data/lib/datadog/core/telemetry/http/env.rb +2 -0
  90. data/lib/datadog/core/telemetry/http/transport.rb +2 -0
  91. data/lib/datadog/core/telemetry/v1/app_event.rb +2 -0
  92. data/lib/datadog/core/telemetry/v1/application.rb +7 -1
  93. data/lib/datadog/core/telemetry/v1/dependency.rb +7 -1
  94. data/lib/datadog/core/telemetry/v1/host.rb +9 -1
  95. data/lib/datadog/core/telemetry/v1/integration.rb +7 -1
  96. data/lib/datadog/core/telemetry/v1/product.rb +9 -1
  97. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +7 -1
  98. data/lib/datadog/core/transport/config.rb +58 -0
  99. data/lib/datadog/core/transport/http/api/instance.rb +37 -0
  100. data/lib/datadog/core/transport/http/api/spec.rb +19 -0
  101. data/lib/datadog/core/transport/http/api.rb +57 -0
  102. data/lib/datadog/core/transport/http/builder.rb +217 -0
  103. data/lib/datadog/core/transport/http/client.rb +45 -0
  104. data/lib/datadog/core/transport/http/config.rb +268 -0
  105. data/lib/datadog/core/transport/http/negotiation.rb +144 -0
  106. data/lib/datadog/core/transport/http.rb +169 -0
  107. data/lib/datadog/core/transport/negotiation.rb +60 -0
  108. data/lib/datadog/core/utils/compression.rb +2 -0
  109. data/lib/datadog/core/utils/hash.rb +32 -0
  110. data/lib/datadog/core/utils/object_set.rb +2 -0
  111. data/lib/datadog/core/utils/safe_dup.rb +20 -2
  112. data/lib/datadog/core/utils/sequence.rb +2 -0
  113. data/lib/datadog/core/utils/time.rb +2 -0
  114. data/lib/datadog/core/worker.rb +2 -0
  115. data/lib/datadog/core/workers/async.rb +6 -2
  116. data/lib/datadog/core/workers/interval_loop.rb +7 -1
  117. data/lib/datadog/core/workers/queue.rb +2 -0
  118. data/lib/datadog/core/workers/runtime_metrics.rb +2 -0
  119. data/lib/datadog/kit.rb +2 -0
  120. data/lib/datadog/opentracer/binary_propagator.rb +2 -0
  121. data/lib/datadog/opentracer/carrier.rb +2 -0
  122. data/lib/datadog/opentracer/global_tracer.rb +2 -0
  123. data/lib/datadog/opentracer/propagator.rb +2 -0
  124. data/lib/datadog/opentracer/scope.rb +2 -0
  125. data/lib/datadog/opentracer/scope_manager.rb +2 -0
  126. data/lib/datadog/opentracer/span_context.rb +2 -0
  127. data/lib/datadog/opentracer/span_context_factory.rb +2 -0
  128. data/lib/datadog/opentracer/thread_local_scope.rb +2 -0
  129. data/lib/datadog/opentracer.rb +2 -0
  130. data/lib/datadog/profiling/backtrace_location.rb +2 -0
  131. data/lib/datadog/profiling/buffer.rb +2 -0
  132. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +19 -3
  133. data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +2 -0
  134. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
  135. data/lib/datadog/profiling/collectors/stack.rb +2 -0
  136. data/lib/datadog/profiling/collectors/thread_context.rb +2 -2
  137. data/lib/datadog/profiling/component.rb +103 -29
  138. data/lib/datadog/profiling/event.rb +2 -0
  139. data/lib/datadog/profiling/events/stack.rb +2 -0
  140. data/lib/datadog/profiling/ext.rb +28 -26
  141. data/lib/datadog/profiling/flush.rb +2 -0
  142. data/lib/datadog/profiling/native_extension.rb +2 -0
  143. data/lib/datadog/profiling/pprof/message_set.rb +2 -0
  144. data/lib/datadog/profiling/pprof/payload.rb +2 -0
  145. data/lib/datadog/profiling/pprof/string_table.rb +2 -0
  146. data/lib/datadog/profiling/preload.rb +2 -0
  147. data/lib/datadog/profiling/scheduler.rb +3 -1
  148. data/lib/datadog/profiling/stack_recorder.rb +0 -18
  149. data/lib/datadog/profiling/tag_builder.rb +2 -0
  150. data/lib/datadog/profiling/tasks/setup.rb +0 -26
  151. data/lib/datadog/profiling.rb +2 -1
  152. data/lib/datadog/tracing/analytics.rb +2 -0
  153. data/lib/datadog/tracing/configuration/ext.rb +7 -0
  154. data/lib/datadog/tracing/configuration/settings.rb +14 -0
  155. data/lib/datadog/tracing/context.rb +2 -0
  156. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -0
  157. data/lib/datadog/tracing/contrib/action_cable/event.rb +2 -0
  158. data/lib/datadog/tracing/contrib/action_cable/events.rb +2 -0
  159. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -0
  160. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -0
  161. data/lib/datadog/tracing/contrib/action_mailer/event.rb +2 -0
  162. data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -0
  163. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -0
  164. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -24
  165. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -0
  166. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +14 -1
  167. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
  168. data/lib/datadog/tracing/contrib/action_view/event.rb +2 -0
  169. data/lib/datadog/tracing/contrib/action_view/events.rb +2 -0
  170. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +2 -0
  171. data/lib/datadog/tracing/contrib/active_job/event.rb +2 -0
  172. data/lib/datadog/tracing/contrib/active_job/events.rb +2 -0
  173. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +2 -0
  174. data/lib/datadog/tracing/contrib/active_job/patcher.rb +2 -0
  175. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -0
  176. data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +2 -0
  177. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -0
  178. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +2 -0
  179. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +8 -1
  180. data/lib/datadog/tracing/contrib/active_record/event.rb +2 -0
  181. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -1
  182. data/lib/datadog/tracing/contrib/active_record/events.rb +2 -0
  183. data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -0
  184. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +6 -2
  185. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -0
  186. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -0
  187. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -0
  188. data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +2 -0
  189. data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -0
  190. data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -0
  191. data/lib/datadog/tracing/contrib/analytics.rb +2 -0
  192. data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -0
  193. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +9 -1
  194. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +8 -1
  195. data/lib/datadog/tracing/contrib/aws/patcher.rb +2 -0
  196. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -0
  197. data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +2 -0
  198. data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +2 -0
  199. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -0
  200. data/lib/datadog/tracing/contrib/configurable.rb +2 -0
  201. data/lib/datadog/tracing/contrib/configuration/resolver.rb +2 -0
  202. data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
  203. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +8 -1
  204. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -1
  205. data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -0
  206. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +2 -0
  207. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +2 -0
  208. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -0
  209. data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +2 -0
  210. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +8 -1
  211. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +4 -1
  212. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +8 -1
  213. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +5 -3
  214. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +6 -2
  215. data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -0
  216. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +8 -1
  217. data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -2
  218. data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -0
  219. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +8 -1
  220. data/lib/datadog/tracing/contrib/faraday/connection.rb +2 -0
  221. data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -2
  222. data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +2 -0
  223. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +2 -0
  224. data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -0
  225. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -0
  226. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +8 -1
  227. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +5 -2
  228. data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +2 -0
  229. data/lib/datadog/tracing/contrib/grpc/patcher.rb +2 -0
  230. data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +2 -0
  231. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +2 -0
  232. data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -0
  233. data/lib/datadog/tracing/contrib/hanami/plugin.rb +2 -0
  234. data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +2 -0
  235. data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +2 -0
  236. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +2 -0
  237. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +8 -1
  238. data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -2
  239. data/lib/datadog/tracing/contrib/http/integration.rb +2 -0
  240. data/lib/datadog/tracing/contrib/http/patcher.rb +2 -0
  241. data/lib/datadog/tracing/contrib/http_annotation_helper.rb +2 -0
  242. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -0
  243. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -0
  244. data/lib/datadog/tracing/contrib/integration.rb +2 -0
  245. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -0
  246. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +2 -0
  247. data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +2 -0
  248. data/lib/datadog/tracing/contrib/kafka/event.rb +2 -0
  249. data/lib/datadog/tracing/contrib/kafka/events.rb +2 -0
  250. data/lib/datadog/tracing/contrib/kafka/patcher.rb +2 -0
  251. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -0
  252. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -0
  253. data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -0
  254. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -0
  255. data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +2 -0
  256. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +2 -0
  257. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -0
  258. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -0
  259. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -0
  260. data/lib/datadog/tracing/contrib/patchable.rb +2 -0
  261. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -0
  262. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +2 -0
  263. data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -0
  264. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -0
  265. data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +2 -0
  266. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -0
  267. data/lib/datadog/tracing/contrib/qless/patcher.rb +2 -0
  268. data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +2 -0
  269. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -0
  270. data/lib/datadog/tracing/contrib/racecar/event.rb +2 -0
  271. data/lib/datadog/tracing/contrib/racecar/events.rb +2 -0
  272. data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -0
  273. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +9 -2
  274. data/lib/datadog/tracing/contrib/rails/framework.rb +2 -0
  275. data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -0
  276. data/lib/datadog/tracing/contrib/rails/utils.rb +3 -1
  277. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +2 -0
  278. data/lib/datadog/tracing/contrib/rake/patcher.rb +2 -0
  279. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -0
  280. data/lib/datadog/tracing/contrib/redis/tags.rb +2 -0
  281. data/lib/datadog/tracing/contrib/registerable.rb +2 -0
  282. data/lib/datadog/tracing/contrib/registry.rb +2 -0
  283. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +2 -0
  284. data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -0
  285. data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
  286. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -0
  287. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -0
  288. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
  289. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +34 -0
  290. data/lib/datadog/tracing/contrib/roda/ext.rb +18 -0
  291. data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
  292. data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
  293. data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
  294. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -0
  295. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -0
  296. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -0
  297. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -0
  298. data/lib/datadog/tracing/contrib/sequel/dataset.rb +2 -0
  299. data/lib/datadog/tracing/contrib/sequel/patcher.rb +2 -0
  300. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +2 -0
  301. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -0
  302. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
  303. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +12 -3
  304. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -0
  305. data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +38 -0
  306. data/lib/datadog/tracing/contrib/sidekiq/integration.rb +8 -0
  307. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +16 -2
  308. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +11 -4
  309. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +2 -0
  310. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +2 -0
  311. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +2 -0
  312. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/stop.rb +34 -0
  313. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +18 -2
  314. data/lib/datadog/tracing/contrib/sidekiq/{tracing.rb → utils.rb} +3 -1
  315. data/lib/datadog/tracing/contrib/sinatra/headers.rb +2 -0
  316. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -0
  317. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +2 -0
  318. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +28 -0
  319. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -0
  320. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +2 -0
  321. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +2 -0
  322. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
  323. data/lib/datadog/tracing/contrib.rb +3 -0
  324. data/lib/datadog/tracing/correlation.rb +10 -10
  325. data/lib/datadog/tracing/diagnostics/health.rb +2 -0
  326. data/lib/datadog/tracing/distributed/trace_context.rb +22 -15
  327. data/lib/datadog/tracing/flush.rb +2 -0
  328. data/lib/datadog/tracing/metadata/analytics.rb +2 -0
  329. data/lib/datadog/tracing/metadata/errors.rb +2 -0
  330. data/lib/datadog/tracing/metadata/ext.rb +6 -0
  331. data/lib/datadog/tracing/metadata.rb +2 -0
  332. data/lib/datadog/tracing/pipeline/span_filter.rb +2 -0
  333. data/lib/datadog/tracing/pipeline/span_processor.rb +2 -0
  334. data/lib/datadog/tracing/propagation/http.rb +2 -0
  335. data/lib/datadog/tracing/runtime/metrics.rb +2 -0
  336. data/lib/datadog/tracing/sampling/all_sampler.rb +2 -0
  337. data/lib/datadog/tracing/sampling/matcher.rb +2 -0
  338. data/lib/datadog/tracing/sampling/priority_sampler.rb +2 -0
  339. data/lib/datadog/tracing/sampling/span/sampler.rb +2 -0
  340. data/lib/datadog/tracing/sync_writer.rb +2 -0
  341. data/lib/datadog/tracing/trace_digest.rb +2 -0
  342. data/lib/datadog/tracing/utils.rb +2 -0
  343. data/lib/datadog/tracing.rb +2 -0
  344. data/lib/ddtrace/auto_instrument.rb +2 -0
  345. data/lib/ddtrace/auto_instrument_base.rb +2 -0
  346. data/lib/ddtrace/transport/http/adapters/net.rb +12 -0
  347. data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
  348. data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
  349. data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
  350. data/lib/ddtrace/transport/http/api/instance.rb +2 -0
  351. data/lib/ddtrace/transport/http/api/map.rb +2 -0
  352. data/lib/ddtrace/transport/http/api/spec.rb +2 -0
  353. data/lib/ddtrace/transport/http/env.rb +2 -0
  354. data/lib/ddtrace/transport/http/response.rb +2 -0
  355. data/lib/ddtrace/transport/io/response.rb +2 -0
  356. data/lib/ddtrace/transport/io/traces.rb +2 -0
  357. data/lib/ddtrace/transport/io.rb +2 -0
  358. data/lib/ddtrace/transport/parcel.rb +2 -0
  359. data/lib/ddtrace/transport/request.rb +3 -1
  360. data/lib/ddtrace/transport/statistics.rb +2 -0
  361. data/lib/ddtrace/transport/trace_formatter.rb +2 -0
  362. data/lib/ddtrace/version.rb +9 -5
  363. data/lib/ddtrace.rb +2 -0
  364. metadata +43 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 005fcbaaa9553287f8652a9f437abd144c2ba2ca0f26c83f67de171646f5aae3
4
- data.tar.gz: 032c0d3f09ea01779b17ba45a95086ab890b3869208c84b82b548b3cbd41a977
3
+ metadata.gz: bf1177aae94a3724758e48ce461638de0a4b75956c8c1318251f2b568de28c5d
4
+ data.tar.gz: f42454cd32ff7eaf91c7beda1e6ff8a99726efddc8e01fdb4797b4f115c29df4
5
5
  SHA512:
6
- metadata.gz: bc868d2e56e5282771cbc7e9447f1fa7504212d31b5bc94db4db9e5f029a00b0a9f988bcab7111f1889eb1f203fffcd81b73700c69f433be4bdaa2045dbfba72
7
- data.tar.gz: d2679f725e7991bfa2e34dc6de650e928a59aa02124239d340a396ea40f331ff0a4a2159067df5ade22c1c36daab8e7cbe25db3ddaf55b8c8cb14137e7b2d220
6
+ metadata.gz: 5d5787eb9f073043151922af478a75affcfe8f2a9723fbe6c8e0561be6c7f95c700c91e1f4ca10401e018f1587f0289b1720d5c38e2cccdb80f7fcffd7eba0ba
7
+ data.tar.gz: 5f9d0adcfc38de9d60c51a46360ce60351228db21cabd07dc176a99f4bf77f80b0cc8f12dbe844ea3ae88f2384174158415a28de3e6adc1b6b54e56be1186665
data/CHANGELOG.md CHANGED
@@ -2,6 +2,85 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.11.0] - 2023-04-27
6
+
7
+ ### Highlights
8
+
9
+ As of ddtrace 1.11.0, these features are GA and emabled by default:
10
+
11
+ - CPU Profiling 2.0
12
+ - Remote Configuration
13
+ - Telemetry
14
+
15
+ For more details, check the release notes.
16
+
17
+ ### Added
18
+
19
+ * Add remote configuration, enabled by default ([#2674][], [#2678][], [#2686][], [#2687][], [#2688][], [#2689][], [#2696][], [#2705][], [#2731][], [#2732][], [#2733][], [#2739][], [#2756][], [#2769][], [#2771][], [#2773][], [#2789][], [#2805][], [#2794][])
20
+ * AppSec: Add response headers passing to WAF ([#2701][])
21
+ * Tracing: Distributed tracing for Sidekiq ([#2513][])
22
+ * Tracing: Add Roda integration ([#2368][])
23
+ * Profiling: Support disabling endpoint names collection in new profiler ([#2698][])
24
+ * Tracing: Support Sidekiq 7 ([#2810][])
25
+ * Core: Add support for Unix Domain Socket (UDS) configuration via `DD_TRACE_AGENT_URL` ([#2806][])
26
+ * Core: Enable Telemetry by default ([#2762][])
27
+
28
+ ### Changed
29
+
30
+ * Core: Allow `1` as true value in environment variables ([#2710][])
31
+ * Profiling: Enable CPU Profiling 2.0 by default ([#2702][])
32
+ * Tracing: Improve controller instrumentation and deprecate option `exception_controller` ([#2726][])
33
+ * Tracing: Implement Span Attribute Schema Environment Variable ([#2727][])
34
+ * Tracing: Change default `service_name` values (gated by feature flag) ([#2760][])
35
+
36
+ ### Fixed
37
+
38
+ * Bug: Tracing: Fix w3c propagation special character handling ([#2720][])
39
+ * Performance: Tracing: Use `+@` instead of `dup` for duplicating strings ([#2704][])
40
+ * Profiling: Avoid triggering allocation sampling during sampling ([#2690][])
41
+ * Integrations: Tracing: Fix Rails < 3 conditional check in Utils#railtie_supported? ([#2695][])
42
+ * Profiling: Do not auto-enable new profiler when rugged gem is detected ([#2741][])
43
+ * Tracing: Fix using SemanticLogger#log(severity, message, progname) ([#2748][]) ([@rqz13][])
44
+ * Profiling: Improve detection of mysql2 gem incompatibilities with profiler ([#2770][])
45
+ * AppSec: Remove check for `::Rack::Request.instance_methods.include?(:each_header)` at load time ([#2778][])
46
+ * Tracing: Fix quadratic backtracking on invalid URI ([#2788][])
47
+ * Community: Correctly set mutex ([#2757][]) ([@ixti][])
48
+
49
+ Read the [full changeset](https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0.beta1) and the release [milestone](https://github.com/DataDog/dd-trace-rb/milestone/121?closed=1).
50
+
51
+ ## [1.11.0.beta1] - 2023-04-14
52
+
53
+ 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.
54
+
55
+ As of ddtrace 1.11.0.beta1, Remote Configuration is now public beta and disabled by default. For more details, check the release notes.
56
+
57
+ ### Added
58
+
59
+ * Add remote configuration beta, disabled by default ([#2674][], [#2678][], [#2686][], [#2687][], [#2688][], [#2689][], [#2696][], [#2705][], [#2731][], [#2732][], [#2733][], [#2739][], [#2756][], [#2769][], [#2771][], [#2773][], [#2789][])
60
+ * AppSec: Add response headers passing to WAF ([#2701][])
61
+ * Tracing: Distributed tracing for Sidekiq ([#2513][])
62
+ * Tracing: Add Roda integration ([#2368][])
63
+ * Profiling: [PROF-6555] Support disabling endpoint names collection in new profiler ([#2698][])
64
+
65
+ ### Changed
66
+
67
+ * Core: Allow `1` as true value in environment variables ([#2710][])
68
+ * Profiling: [PROF-7360] Enable CPU Profiling 2.0 by default ([#2702][])
69
+ * Tracing: Improve controller instrumentation and deprecate option `exception_controller` ([#2726][])
70
+ * Tracing: Implement Span Attribute Schema Environment Variable ([#2727][])
71
+
72
+ ### Fixed
73
+
74
+ * Bug: Tracing: Fix w3c propagation special character handling ([#2720][])
75
+ * Performance: Tracing: Use `+@` instead of `dup` for duplicating strings ([#2704][])
76
+ * Profiling: [PROF-7307] Avoid triggering allocation sampling during sampling ([#2690][])
77
+ * Integrations: Tracing: Fix Rails < 3 conditional check in Utils#railtie_supported? ([#2695][])
78
+ * Profiling: [PROF-7409] Do not auto-enable new profiler when rugged gem is detected ([#2741][])
79
+ * Tracing: Fix using SemanticLogger#log(severity, message, progname) ([#2748][]) ([@rqz13][])
80
+ * Profiling: [PROF-6447] Improve detection of mysql2 gem incompatibilities with profiler ([#2770][])
81
+ * AppSec: Remove check for `::Rack::Request.instance_methods.include?(:each_header)` at load time ([#2778][])
82
+ * Tracing: Fix quadratic backtracking on invalid URI ([#2788][])
83
+
5
84
  ## [1.10.1] - 2023-03-10
6
85
 
7
86
  ### Fixed
@@ -2323,7 +2402,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
2323
2402
 
2324
2403
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2325
2404
 
2326
- [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...master
2405
+ [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.11.0...master
2406
+ [1.11.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0
2407
+ [1.11.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0.beta1
2327
2408
  [1.10.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.0...v1.10.1
2328
2409
  [1.10.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.9.0...v1.10.0
2329
2410
  [1.9.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.8.0...v1.9.0
@@ -3261,6 +3342,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3261
3342
  [#2363]: https://github.com/DataDog/dd-trace-rb/issues/2363
3262
3343
  [#2365]: https://github.com/DataDog/dd-trace-rb/issues/2365
3263
3344
  [#2367]: https://github.com/DataDog/dd-trace-rb/issues/2367
3345
+ [#2368]: https://github.com/DataDog/dd-trace-rb/issues/2368
3264
3346
  [#2378]: https://github.com/DataDog/dd-trace-rb/issues/2378
3265
3347
  [#2382]: https://github.com/DataDog/dd-trace-rb/issues/2382
3266
3348
  [#2390]: https://github.com/DataDog/dd-trace-rb/issues/2390
@@ -3293,6 +3375,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3293
3375
  [#2501]: https://github.com/DataDog/dd-trace-rb/issues/2501
3294
3376
  [#2504]: https://github.com/DataDog/dd-trace-rb/issues/2504
3295
3377
  [#2512]: https://github.com/DataDog/dd-trace-rb/issues/2512
3378
+ [#2513]: https://github.com/DataDog/dd-trace-rb/issues/2513
3296
3379
  [#2522]: https://github.com/DataDog/dd-trace-rb/issues/2522
3297
3380
  [#2526]: https://github.com/DataDog/dd-trace-rb/issues/2526
3298
3381
  [#2530]: https://github.com/DataDog/dd-trace-rb/issues/2530
@@ -3334,7 +3417,46 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3334
3417
  [#2663]: https://github.com/DataDog/dd-trace-rb/issues/2663
3335
3418
  [#2665]: https://github.com/DataDog/dd-trace-rb/issues/2665
3336
3419
  [#2668]: https://github.com/DataDog/dd-trace-rb/issues/2668
3420
+ [#2674]: https://github.com/DataDog/dd-trace-rb/issues/2674
3421
+ [#2678]: https://github.com/DataDog/dd-trace-rb/issues/2678
3337
3422
  [#2679]: https://github.com/DataDog/dd-trace-rb/issues/2679
3423
+ [#2686]: https://github.com/DataDog/dd-trace-rb/issues/2686
3424
+ [#2687]: https://github.com/DataDog/dd-trace-rb/issues/2687
3425
+ [#2688]: https://github.com/DataDog/dd-trace-rb/issues/2688
3426
+ [#2689]: https://github.com/DataDog/dd-trace-rb/issues/2689
3427
+ [#2690]: https://github.com/DataDog/dd-trace-rb/issues/2690
3428
+ [#2695]: https://github.com/DataDog/dd-trace-rb/issues/2695
3429
+ [#2696]: https://github.com/DataDog/dd-trace-rb/issues/2696
3430
+ [#2698]: https://github.com/DataDog/dd-trace-rb/issues/2698
3431
+ [#2701]: https://github.com/DataDog/dd-trace-rb/issues/2701
3432
+ [#2702]: https://github.com/DataDog/dd-trace-rb/issues/2702
3433
+ [#2704]: https://github.com/DataDog/dd-trace-rb/issues/2704
3434
+ [#2705]: https://github.com/DataDog/dd-trace-rb/issues/2705
3435
+ [#2710]: https://github.com/DataDog/dd-trace-rb/issues/2710
3436
+ [#2720]: https://github.com/DataDog/dd-trace-rb/issues/2720
3437
+ [#2726]: https://github.com/DataDog/dd-trace-rb/issues/2726
3438
+ [#2727]: https://github.com/DataDog/dd-trace-rb/issues/2727
3439
+ [#2731]: https://github.com/DataDog/dd-trace-rb/issues/2731
3440
+ [#2732]: https://github.com/DataDog/dd-trace-rb/issues/2732
3441
+ [#2733]: https://github.com/DataDog/dd-trace-rb/issues/2733
3442
+ [#2739]: https://github.com/DataDog/dd-trace-rb/issues/2739
3443
+ [#2741]: https://github.com/DataDog/dd-trace-rb/issues/2741
3444
+ [#2748]: https://github.com/DataDog/dd-trace-rb/issues/2748
3445
+ [#2756]: https://github.com/DataDog/dd-trace-rb/issues/2756
3446
+ [#2757]: https://github.com/DataDog/dd-trace-rb/issues/2757
3447
+ [#2760]: https://github.com/DataDog/dd-trace-rb/issues/2760
3448
+ [#2762]: https://github.com/DataDog/dd-trace-rb/issues/2762
3449
+ [#2769]: https://github.com/DataDog/dd-trace-rb/issues/2769
3450
+ [#2770]: https://github.com/DataDog/dd-trace-rb/issues/2770
3451
+ [#2771]: https://github.com/DataDog/dd-trace-rb/issues/2771
3452
+ [#2773]: https://github.com/DataDog/dd-trace-rb/issues/2773
3453
+ [#2778]: https://github.com/DataDog/dd-trace-rb/issues/2778
3454
+ [#2788]: https://github.com/DataDog/dd-trace-rb/issues/2788
3455
+ [#2789]: https://github.com/DataDog/dd-trace-rb/issues/2789
3456
+ [#2794]: https://github.com/DataDog/dd-trace-rb/issues/2794
3457
+ [#2805]: https://github.com/DataDog/dd-trace-rb/issues/2805
3458
+ [#2806]: https://github.com/DataDog/dd-trace-rb/issues/2806
3459
+ [#2810]: https://github.com/DataDog/dd-trace-rb/issues/2810
3338
3460
  [@AdrianLC]: https://github.com/AdrianLC
3339
3461
  [@Azure7111]: https://github.com/Azure7111
3340
3462
  [@BabyGroot]: https://github.com/BabyGroot
@@ -3413,6 +3535,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3413
3535
  [@hs-bguven]: https://github.com/hs-bguven
3414
3536
  [@illdelph]: https://github.com/illdelph
3415
3537
  [@ioquatix]: https://github.com/ioquatix
3538
+ [@ixti]: https://github.com/ixti
3416
3539
  [@jamiehodge]: https://github.com/jamiehodge
3417
3540
  [@janz93]: https://github.com/janz93
3418
3541
  [@jeffjo]: https://github.com/jeffjo
@@ -3456,6 +3579,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3456
3579
  [@renchap]: https://github.com/renchap
3457
3580
  [@ricbartm]: https://github.com/ricbartm
3458
3581
  [@roccoblues]: https://github.com/roccoblues
3582
+ [@rqz13]: https://github.com/rqz13
3459
3583
  [@saturnflyer]: https://github.com/saturnflyer
3460
3584
  [@sco11morgan]: https://github.com/sco11morgan
3461
3585
  [@senny]: https://github.com/senny
data/README.md CHANGED
@@ -1,29 +1,27 @@
1
1
  # Datadog Trace Client
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/ddtrace)](https://rubygems.org/gems/ddtrace/)
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
4
  [![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)
5
+ [![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)][api docs]
7
6
 
8
7
  ``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.
8
+ databases and microservices so that developers have great visibility into bottlenecks and troublesome requests.
10
9
 
11
10
  ## Getting started
12
11
 
13
12
  **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
13
 
15
- For a basic product overview, check out our [setup documentation][setup docs].
14
+ For a product overview, installation, and configuration check out our [documentation][public docs].
16
15
 
17
- For installation, configuration, and details about using the API, check out our [API documentation][api docs] and [gem documentation][gem docs].
16
+ For the gem API, check out our [API documentation][api docs].
18
17
 
19
- For descriptions of terminology used in APM, take a look at the [official documentation][visualization docs].
18
+ For descriptions of terminology used in APM, take a look at the [APM Terms and Concepts][APM glossary].
20
19
 
21
20
  For contributing, checkout the [contribution guidelines][contribution docs] and [development guide][development docs].
22
21
 
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/
22
+ [public docs]: https://docs.datadoghq.com/tracing/setup/ruby/
23
+ [api docs]: https://datadog.github.io/dd-trace-rb/
24
+ [APM glossary]: https://docs.datadoghq.com/tracing/glossary/
27
25
  [contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
28
26
  [development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
29
27
 
@@ -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
@@ -111,10 +118,25 @@ struct cpu_and_wall_time_worker_state {
111
118
  unsigned int signal_handler_wrong_thread;
112
119
  // How many times we actually sampled (except GC samples)
113
120
  unsigned int sampled;
121
+ // How many times we skipped a sample because of the dynamic sampling rate mechanism
122
+ unsigned int skipped_sample_because_of_dynamic_sampling_rate;
123
+
124
+ // Stats for the results of calling rb_postponed_job_register_one
125
+ // The same function was already waiting to be executed
126
+ unsigned int postponed_job_skipped_already_existed;
127
+ // The function was added to the queue successfully
128
+ unsigned int postponed_job_success;
129
+ // The queue was full
130
+ unsigned int postponed_job_full;
131
+ // The function returned an unknown result code
132
+ unsigned int postponed_job_unknown_result;
133
+
114
134
  // Min/max/total wall-time spent sampling (except GC samples)
115
135
  uint64_t sampling_time_ns_min;
116
136
  uint64_t sampling_time_ns_max;
117
137
  uint64_t sampling_time_ns_total;
138
+ // How many times we saw allocations being done inside a sample
139
+ unsigned int allocations_during_sample;
118
140
  } stats;
119
141
  };
120
142
 
@@ -125,7 +147,8 @@ static VALUE _native_initialize(
125
147
  VALUE thread_context_collector_instance,
126
148
  VALUE gc_profiling_enabled,
127
149
  VALUE idle_sampling_helper_instance,
128
- VALUE allocation_counting_enabled
150
+ VALUE allocation_counting_enabled,
151
+ VALUE dynamic_sampling_rate_enabled
129
152
  );
130
153
  static void cpu_and_wall_time_worker_typed_data_mark(void *state_ptr);
131
154
  static VALUE _native_sampling_loop(VALUE self, VALUE instance);
@@ -160,6 +183,7 @@ static void sleep_for(uint64_t time_ns);
160
183
  static VALUE _native_allocation_count(DDTRACE_UNUSED VALUE self);
161
184
  static void on_newobj_event(DDTRACE_UNUSED VALUE tracepoint_data, DDTRACE_UNUSED void *unused);
162
185
  static void disable_tracepoints(struct cpu_and_wall_time_worker_state *state);
186
+ static VALUE _native_with_blocked_sigprof(DDTRACE_UNUSED VALUE self);
163
187
 
164
188
  // Note on sampler global state safety:
165
189
  //
@@ -197,7 +221,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
197
221
  // https://bugs.ruby-lang.org/issues/18007 for a discussion around this.
198
222
  rb_define_alloc_func(collectors_cpu_and_wall_time_worker_class, _native_new);
199
223
 
200
- rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize, 5);
224
+ rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize, 6);
201
225
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_sampling_loop", _native_sampling_loop, 1);
202
226
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_stop", _native_stop, 2);
203
227
  rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_reset_after_fork", _native_reset_after_fork, 1);
@@ -212,6 +236,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
212
236
  rb_define_singleton_method(testing_module, "_native_simulate_handle_sampling_signal", _native_simulate_handle_sampling_signal, 0);
213
237
  rb_define_singleton_method(testing_module, "_native_simulate_sample_from_postponed_job", _native_simulate_sample_from_postponed_job, 0);
214
238
  rb_define_singleton_method(testing_module, "_native_is_sigprof_blocked_in_current_thread", _native_is_sigprof_blocked_in_current_thread, 0);
239
+ rb_define_singleton_method(testing_module, "_native_with_blocked_sigprof", _native_with_blocked_sigprof, 0);
215
240
  }
216
241
 
217
242
  // This structure is used to define a Ruby object that stores a pointer to a struct cpu_and_wall_time_worker_state
@@ -230,17 +255,22 @@ static const rb_data_type_t cpu_and_wall_time_worker_typed_data = {
230
255
  static VALUE _native_new(VALUE klass) {
231
256
  struct cpu_and_wall_time_worker_state *state = ruby_xcalloc(1, sizeof(struct cpu_and_wall_time_worker_state));
232
257
 
233
- atomic_init(&state->should_run, false);
234
258
  state->gc_profiling_enabled = false;
235
259
  state->allocation_counting_enabled = false;
260
+ state->dynamic_sampling_rate_enabled = true;
236
261
  state->thread_context_collector_instance = Qnil;
237
262
  state->idle_sampling_helper_instance = Qnil;
238
263
  state->owner_thread = Qnil;
239
264
  dynamic_sampling_rate_init(&state->dynamic_sampling_rate);
240
- state->failure_exception = Qnil;
241
- state->stop_thread = Qnil;
242
265
  state->gc_tracepoint = Qnil;
243
266
  state->object_allocation_tracepoint = Qnil;
267
+
268
+ atomic_init(&state->should_run, false);
269
+ state->failure_exception = Qnil;
270
+ state->stop_thread = Qnil;
271
+
272
+ state->during_sample = false;
273
+
244
274
  reset_stats(state);
245
275
 
246
276
  return state->self_instance = TypedData_Wrap_Struct(klass, &cpu_and_wall_time_worker_typed_data, state);
@@ -252,16 +282,19 @@ static VALUE _native_initialize(
252
282
  VALUE thread_context_collector_instance,
253
283
  VALUE gc_profiling_enabled,
254
284
  VALUE idle_sampling_helper_instance,
255
- VALUE allocation_counting_enabled
285
+ VALUE allocation_counting_enabled,
286
+ VALUE dynamic_sampling_rate_enabled
256
287
  ) {
257
288
  ENFORCE_BOOLEAN(gc_profiling_enabled);
258
289
  ENFORCE_BOOLEAN(allocation_counting_enabled);
290
+ ENFORCE_BOOLEAN(dynamic_sampling_rate_enabled);
259
291
 
260
292
  struct cpu_and_wall_time_worker_state *state;
261
293
  TypedData_Get_Struct(self_instance, struct cpu_and_wall_time_worker_state, &cpu_and_wall_time_worker_typed_data, state);
262
294
 
263
295
  state->gc_profiling_enabled = (gc_profiling_enabled == Qtrue);
264
296
  state->allocation_counting_enabled = (allocation_counting_enabled == Qtrue);
297
+ state->dynamic_sampling_rate_enabled = (dynamic_sampling_rate_enabled == Qtrue);
265
298
  state->thread_context_collector_instance = enforce_thread_context_collector_instance(thread_context_collector_instance);
266
299
  state->idle_sampling_helper_instance = idle_sampling_helper_instance;
267
300
  state->gc_tracepoint = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_GC_ENTER | RUBY_INTERNAL_EVENT_GC_EXIT, on_gc_event, NULL /* unused */);
@@ -418,8 +451,20 @@ static void handle_sampling_signal(DDTRACE_UNUSED int _signal, DDTRACE_UNUSED si
418
451
 
419
452
  // Note: If we ever want to get rid of rb_postponed_job_register_one, remember not to clobber Ruby exceptions, as
420
453
  // this function does this helpful job for us now -- https://github.com/ruby/ruby/commit/a98e343d39c4d7bf1e2190b076720f32d9f298b3.
421
- /*int result =*/ rb_postponed_job_register_one(0, sample_from_postponed_job, NULL);
422
- // TODO: Do something with result (potentially update tracking counters?)
454
+ int result = rb_postponed_job_register_one(0, sample_from_postponed_job, NULL);
455
+
456
+ // Officially, the result of rb_postponed_job_register_one is documented as being opaque, but in practice it does not
457
+ // seem to have changed between Ruby 2.3 and 3.2, and so we track it as a debugging mechanism
458
+ switch (result) {
459
+ case 0:
460
+ state->stats.postponed_job_full++; break;
461
+ case 1:
462
+ state->stats.postponed_job_success++; break;
463
+ case 2:
464
+ state->stats.postponed_job_skipped_already_existed++; break;
465
+ default:
466
+ state->stats.postponed_job_unknown_result++;
467
+ }
423
468
  }
424
469
 
425
470
  // The actual sampling trigger loop always runs **without** the global vm lock.
@@ -431,9 +476,6 @@ static void *run_sampling_trigger_loop(void *state_ptr) {
431
476
  while (atomic_load(&state->should_run)) {
432
477
  state->stats.trigger_sample_attempts++;
433
478
 
434
- // TODO: This is still a placeholder for a more complex mechanism. In particular:
435
- // * We want to do more than having a fixed sampling rate
436
-
437
479
  current_gvl_owner owner = gvl_owner();
438
480
  if (owner.valid) {
439
481
  // Note that reading the GVL owner and sending them a signal is a race -- the Ruby VM keeps on executing while
@@ -460,7 +502,7 @@ static void *run_sampling_trigger_loop(void *state_ptr) {
460
502
  // `dynamic_sampling_rate_get_sleep` may have changed while the above sleep was ongoing.
461
503
  uint64_t extra_sleep =
462
504
  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);
505
+ if (state->dynamic_sampling_rate_enabled && extra_sleep > 0) sleep_for(extra_sleep);
464
506
  }
465
507
 
466
508
  return NULL; // Unused
@@ -485,8 +527,12 @@ static void sample_from_postponed_job(DDTRACE_UNUSED void *_unused) {
485
527
  return; // We're not on the main Ractor; we currently don't support profiling non-main Ractors
486
528
  }
487
529
 
530
+ state->during_sample = true;
531
+
488
532
  // Rescue against any exceptions that happen during sampling
489
533
  safely_call(rescued_sample_from_postponed_job, state->self_instance, state->self_instance);
534
+
535
+ state->during_sample = false;
490
536
  }
491
537
 
492
538
  static VALUE rescued_sample_from_postponed_job(VALUE self_instance) {
@@ -495,8 +541,8 @@ static VALUE rescued_sample_from_postponed_job(VALUE self_instance) {
495
541
 
496
542
  long wall_time_ns_before_sample = monotonic_wall_time_now_ns(RAISE_ON_FAILURE);
497
543
 
498
- if (!dynamic_sampling_rate_should_sample(&state->dynamic_sampling_rate, wall_time_ns_before_sample)) {
499
- // TODO: Add a counter for this
544
+ if (state->dynamic_sampling_rate_enabled && !dynamic_sampling_rate_should_sample(&state->dynamic_sampling_rate, wall_time_ns_before_sample)) {
545
+ state->stats.skipped_sample_because_of_dynamic_sampling_rate++;
500
546
  return Qnil;
501
547
  }
502
548
 
@@ -672,8 +718,12 @@ static void after_gc_from_postponed_job(DDTRACE_UNUSED void *_unused) {
672
718
  return; // We're not on the main Ractor; we currently don't support profiling non-main Ractors
673
719
  }
674
720
 
721
+ state->during_sample = true;
722
+
675
723
  // Trigger sampling using the Collectors::ThreadState; rescue against any exceptions that happen during sampling
676
724
  safely_call(thread_context_collector_sample_after_gc, state->thread_context_collector_instance, state->self_instance);
725
+
726
+ state->during_sample = false;
677
727
  }
678
728
 
679
729
  // Equivalent to Ruby begin/rescue call, where we call a C function and jump to the exception handler if an
@@ -749,10 +799,16 @@ static VALUE _native_stats(DDTRACE_UNUSED VALUE self, VALUE instance) {
749
799
  ID2SYM(rb_intern("signal_handler_enqueued_sample")), /* => */ UINT2NUM(state->stats.signal_handler_enqueued_sample),
750
800
  ID2SYM(rb_intern("signal_handler_wrong_thread")), /* => */ UINT2NUM(state->stats.signal_handler_wrong_thread),
751
801
  ID2SYM(rb_intern("sampled")), /* => */ UINT2NUM(state->stats.sampled),
802
+ ID2SYM(rb_intern("skipped_sample_because_of_dynamic_sampling_rate")), /* => */ UINT2NUM(state->stats.skipped_sample_because_of_dynamic_sampling_rate),
803
+ ID2SYM(rb_intern("postponed_job_skipped_already_existed")), /* => */ UINT2NUM(state->stats.postponed_job_skipped_already_existed),
804
+ ID2SYM(rb_intern("postponed_job_success")), /* => */ UINT2NUM(state->stats.postponed_job_success),
805
+ ID2SYM(rb_intern("postponed_job_full")), /* => */ UINT2NUM(state->stats.postponed_job_full),
806
+ ID2SYM(rb_intern("postponed_job_unknown_result")), /* => */ UINT2NUM(state->stats.postponed_job_unknown_result),
752
807
  ID2SYM(rb_intern("sampling_time_ns_min")), /* => */ pretty_sampling_time_ns_min,
753
808
  ID2SYM(rb_intern("sampling_time_ns_max")), /* => */ pretty_sampling_time_ns_max,
754
809
  ID2SYM(rb_intern("sampling_time_ns_total")), /* => */ pretty_sampling_time_ns_total,
755
810
  ID2SYM(rb_intern("sampling_time_ns_avg")), /* => */ pretty_sampling_time_ns_avg,
811
+ ID2SYM(rb_intern("allocations_during_sample")), /* => */ UINT2NUM(state->stats.allocations_during_sample),
756
812
  };
757
813
  for (long unsigned int i = 0; i < VALUE_COUNT(arguments); i += 2) rb_hash_aset(stats_as_hash, arguments[i], arguments[i+1]);
758
814
  return stats_as_hash;
@@ -813,9 +869,45 @@ static void on_newobj_event(DDTRACE_UNUSED VALUE tracepoint_data, DDTRACE_UNUSED
813
869
  } else {
814
870
  allocation_count++;
815
871
  }
872
+
873
+ struct cpu_and_wall_time_worker_state *state = active_sampler_instance_state; // Read from global variable, see "sampler global state safety" note above
874
+
875
+ // This should not happen in a normal situation because the tracepoint is always enabled after the instance is set
876
+ // and disabled before it is cleared, but just in case...
877
+ if (state == NULL) return;
878
+
879
+ // In a few cases, we may actually be allocating an object as part of profiler sampling. We don't want to recursively
880
+ // sample, so we just return early
881
+ if (state->during_sample) {
882
+ state->stats.allocations_during_sample++;
883
+ return;
884
+ }
885
+
886
+ // @ivoanjo: Strictly speaking, this is not needed because Ruby should not call the same tracepoint while a previous
887
+ // invocation is still pending, (e.g. it wouldn't call `on_newobj_event` while it's already running), but I decided
888
+ // to keep this here for consistency -- every call to the thread context (other than the special gc calls which are
889
+ // defined as not being able to allocate) sets this.
890
+ state->during_sample = true;
891
+
892
+ // TODO: Sampling goes here (calling into `thread_context_collector_sample_allocation`)
893
+
894
+ state->during_sample = false;
816
895
  }
817
896
 
818
897
  static void disable_tracepoints(struct cpu_and_wall_time_worker_state *state) {
819
898
  rb_tracepoint_disable(state->gc_tracepoint);
820
899
  rb_tracepoint_disable(state->object_allocation_tracepoint);
821
900
  }
901
+
902
+ static VALUE _native_with_blocked_sigprof(DDTRACE_UNUSED VALUE self) {
903
+ block_sigprof_signal_handler_from_running_in_current_thread();
904
+ int exception_state;
905
+ VALUE result = rb_protect(rb_yield, Qundef, &exception_state);
906
+ unblock_sigprof_signal_handler_from_running_in_current_thread();
907
+
908
+ if (exception_state) {
909
+ rb_jump_tag(exception_state);
910
+ } else {
911
+ return result;
912
+ }
913
+ }
@@ -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:");