ddtrace 0.48.0 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (421) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +209 -2
  3. data/.dockerignore +0 -1
  4. data/.gitignore +2 -1
  5. data/.rubocop.yml +13 -1
  6. data/Appraisals +10 -0
  7. data/CHANGELOG.md +32 -0
  8. data/Rakefile +10 -0
  9. data/benchmarks/profiler_sample_loop.rb +69 -0
  10. data/ddtrace.gemspec +1 -1
  11. data/docker-compose.yml +0 -24
  12. data/docs/GettingStarted.md +1 -1
  13. data/gemfiles/jruby_9.2.0.0_contrib.gemfile +79 -0
  14. data/gemfiles/jruby_9.2.0.0_contrib.gemfile.lock +1518 -0
  15. data/gemfiles/jruby_9.2.0.0_contrib_old.gemfile +35 -0
  16. data/gemfiles/jruby_9.2.0.0_contrib_old.gemfile.lock +157 -0
  17. data/gemfiles/jruby_9.2.0.0_core_old.gemfile +34 -0
  18. data/gemfiles/jruby_9.2.0.0_core_old.gemfile.lock +153 -0
  19. data/gemfiles/jruby_9.2.0.0_cucumber3.gemfile +35 -0
  20. data/gemfiles/jruby_9.2.0.0_cucumber3.gemfile.lock +174 -0
  21. data/gemfiles/jruby_9.2.0.0_cucumber4.gemfile +35 -0
  22. data/gemfiles/jruby_9.2.0.0_cucumber4.gemfile.lock +206 -0
  23. data/gemfiles/jruby_9.2.0.0_cucumber5.gemfile +35 -0
  24. data/gemfiles/jruby_9.2.0.0_cucumber5.gemfile.lock +206 -0
  25. data/gemfiles/jruby_9.2.0.0_rails5_mysql2.gemfile +40 -0
  26. data/gemfiles/jruby_9.2.0.0_rails5_mysql2.gemfile.lock +271 -0
  27. data/gemfiles/jruby_9.2.0.0_rails5_postgres.gemfile +40 -0
  28. data/gemfiles/jruby_9.2.0.0_rails5_postgres.gemfile.lock +271 -0
  29. data/gemfiles/jruby_9.2.0.0_rails5_postgres_redis.gemfile +41 -0
  30. data/gemfiles/jruby_9.2.0.0_rails5_postgres_redis.gemfile.lock +273 -0
  31. data/gemfiles/jruby_9.2.0.0_rails5_postgres_redis_activesupport.gemfile +41 -0
  32. data/gemfiles/jruby_9.2.0.0_rails5_postgres_redis_activesupport.gemfile.lock +273 -0
  33. data/gemfiles/jruby_9.2.0.0_rails5_postgres_sidekiq.gemfile +42 -0
  34. data/gemfiles/jruby_9.2.0.0_rails5_postgres_sidekiq.gemfile.lock +279 -0
  35. data/gemfiles/jruby_9.2.0.0_rails61_mysql2.gemfile +40 -0
  36. data/gemfiles/jruby_9.2.0.0_rails61_mysql2.gemfile.lock +290 -0
  37. data/gemfiles/jruby_9.2.0.0_rails61_postgres.gemfile +40 -0
  38. data/gemfiles/jruby_9.2.0.0_rails61_postgres.gemfile.lock +290 -0
  39. data/gemfiles/jruby_9.2.0.0_rails61_postgres_redis.gemfile +41 -0
  40. data/gemfiles/jruby_9.2.0.0_rails61_postgres_redis.gemfile.lock +292 -0
  41. data/gemfiles/jruby_9.2.0.0_rails61_postgres_sidekiq.gemfile +41 -0
  42. data/gemfiles/jruby_9.2.0.0_rails61_postgres_sidekiq.gemfile.lock +297 -0
  43. data/gemfiles/jruby_9.2.0.0_rails6_mysql2.gemfile +40 -0
  44. data/gemfiles/jruby_9.2.0.0_rails6_mysql2.gemfile.lock +287 -0
  45. data/gemfiles/jruby_9.2.0.0_rails6_postgres.gemfile +40 -0
  46. data/gemfiles/jruby_9.2.0.0_rails6_postgres.gemfile.lock +287 -0
  47. data/gemfiles/jruby_9.2.0.0_rails6_postgres_redis.gemfile +41 -0
  48. data/gemfiles/jruby_9.2.0.0_rails6_postgres_redis.gemfile.lock +289 -0
  49. data/gemfiles/jruby_9.2.0.0_rails6_postgres_redis_activesupport.gemfile +41 -0
  50. data/gemfiles/jruby_9.2.0.0_rails6_postgres_redis_activesupport.gemfile.lock +289 -0
  51. data/gemfiles/jruby_9.2.0.0_rails6_postgres_sidekiq.gemfile +42 -0
  52. data/gemfiles/jruby_9.2.0.0_rails6_postgres_sidekiq.gemfile.lock +295 -0
  53. data/gemfiles/jruby_9.2.0.0_resque2_redis3.gemfile +36 -0
  54. data/gemfiles/jruby_9.2.0.0_resque2_redis3.gemfile.lock +180 -0
  55. data/gemfiles/jruby_9.2.0.0_resque2_redis4.gemfile +36 -0
  56. data/gemfiles/jruby_9.2.0.0_resque2_redis4.gemfile.lock +180 -0
  57. data/gemfiles/jruby_9.2.11.1_contrib.gemfile +79 -0
  58. data/gemfiles/jruby_9.2.11.1_contrib.gemfile.lock +1518 -0
  59. data/gemfiles/jruby_9.2.11.1_contrib_old.gemfile +35 -0
  60. data/gemfiles/jruby_9.2.11.1_contrib_old.gemfile.lock +157 -0
  61. data/gemfiles/jruby_9.2.11.1_core_old.gemfile +34 -0
  62. data/gemfiles/jruby_9.2.11.1_core_old.gemfile.lock +153 -0
  63. data/gemfiles/jruby_9.2.11.1_cucumber3.gemfile +35 -0
  64. data/gemfiles/jruby_9.2.11.1_cucumber3.gemfile.lock +174 -0
  65. data/gemfiles/jruby_9.2.11.1_cucumber4.gemfile +35 -0
  66. data/gemfiles/jruby_9.2.11.1_cucumber4.gemfile.lock +206 -0
  67. data/gemfiles/jruby_9.2.11.1_cucumber5.gemfile +35 -0
  68. data/gemfiles/jruby_9.2.11.1_cucumber5.gemfile.lock +206 -0
  69. data/gemfiles/jruby_9.2.11.1_rails5_mysql2.gemfile +40 -0
  70. data/gemfiles/jruby_9.2.11.1_rails5_mysql2.gemfile.lock +271 -0
  71. data/gemfiles/jruby_9.2.11.1_rails5_postgres.gemfile +40 -0
  72. data/gemfiles/jruby_9.2.11.1_rails5_postgres.gemfile.lock +271 -0
  73. data/gemfiles/jruby_9.2.11.1_rails5_postgres_redis.gemfile +41 -0
  74. data/gemfiles/jruby_9.2.11.1_rails5_postgres_redis.gemfile.lock +273 -0
  75. data/gemfiles/jruby_9.2.11.1_rails5_postgres_redis_activesupport.gemfile +41 -0
  76. data/gemfiles/jruby_9.2.11.1_rails5_postgres_redis_activesupport.gemfile.lock +273 -0
  77. data/gemfiles/jruby_9.2.11.1_rails5_postgres_sidekiq.gemfile +42 -0
  78. data/gemfiles/jruby_9.2.11.1_rails5_postgres_sidekiq.gemfile.lock +279 -0
  79. data/gemfiles/jruby_9.2.11.1_rails61_mysql2.gemfile +40 -0
  80. data/gemfiles/jruby_9.2.11.1_rails61_mysql2.gemfile.lock +290 -0
  81. data/gemfiles/jruby_9.2.11.1_rails61_postgres.gemfile +40 -0
  82. data/gemfiles/jruby_9.2.11.1_rails61_postgres.gemfile.lock +290 -0
  83. data/gemfiles/jruby_9.2.11.1_rails61_postgres_redis.gemfile +41 -0
  84. data/gemfiles/jruby_9.2.11.1_rails61_postgres_redis.gemfile.lock +292 -0
  85. data/gemfiles/jruby_9.2.11.1_rails61_postgres_sidekiq.gemfile +41 -0
  86. data/gemfiles/jruby_9.2.11.1_rails61_postgres_sidekiq.gemfile.lock +297 -0
  87. data/gemfiles/jruby_9.2.11.1_rails6_mysql2.gemfile +40 -0
  88. data/gemfiles/jruby_9.2.11.1_rails6_mysql2.gemfile.lock +287 -0
  89. data/gemfiles/jruby_9.2.11.1_rails6_postgres.gemfile +40 -0
  90. data/gemfiles/jruby_9.2.11.1_rails6_postgres.gemfile.lock +287 -0
  91. data/gemfiles/jruby_9.2.11.1_rails6_postgres_redis.gemfile +41 -0
  92. data/gemfiles/jruby_9.2.11.1_rails6_postgres_redis.gemfile.lock +289 -0
  93. data/gemfiles/jruby_9.2.11.1_rails6_postgres_redis_activesupport.gemfile +41 -0
  94. data/gemfiles/jruby_9.2.11.1_rails6_postgres_redis_activesupport.gemfile.lock +289 -0
  95. data/gemfiles/jruby_9.2.11.1_rails6_postgres_sidekiq.gemfile +42 -0
  96. data/gemfiles/jruby_9.2.11.1_rails6_postgres_sidekiq.gemfile.lock +295 -0
  97. data/gemfiles/jruby_9.2.11.1_resque2_redis3.gemfile +36 -0
  98. data/gemfiles/jruby_9.2.11.1_resque2_redis3.gemfile.lock +180 -0
  99. data/gemfiles/jruby_9.2.11.1_resque2_redis4.gemfile +36 -0
  100. data/gemfiles/jruby_9.2.11.1_resque2_redis4.gemfile.lock +180 -0
  101. data/gemfiles/ruby_2.0.0_contrib_old.gemfile +64 -0
  102. data/gemfiles/ruby_2.0.0_contrib_old.gemfile.lock +290 -0
  103. data/gemfiles/ruby_2.0.0_core_old.gemfile +33 -0
  104. data/gemfiles/ruby_2.0.0_core_old.gemfile.lock +118 -0
  105. data/gemfiles/ruby_2.0.0_rails30_postgres.gemfile +39 -0
  106. data/gemfiles/ruby_2.0.0_rails30_postgres.gemfile.lock +196 -0
  107. data/gemfiles/ruby_2.0.0_rails30_postgres_sidekiq.gemfile +40 -0
  108. data/gemfiles/ruby_2.0.0_rails30_postgres_sidekiq.gemfile.lock +205 -0
  109. data/gemfiles/ruby_2.0.0_rails32_mysql2.gemfile +43 -0
  110. data/gemfiles/ruby_2.0.0_rails32_mysql2.gemfile.lock +217 -0
  111. data/gemfiles/ruby_2.0.0_rails32_postgres.gemfile +39 -0
  112. data/gemfiles/ruby_2.0.0_rails32_postgres.gemfile.lock +204 -0
  113. data/gemfiles/ruby_2.0.0_rails32_postgres_redis.gemfile +41 -0
  114. data/gemfiles/ruby_2.0.0_rails32_postgres_redis.gemfile.lock +223 -0
  115. data/gemfiles/ruby_2.0.0_rails32_postgres_sidekiq.gemfile +40 -0
  116. data/gemfiles/ruby_2.0.0_rails32_postgres_sidekiq.gemfile.lock +213 -0
  117. data/gemfiles/ruby_2.1.10_contrib_old.gemfile +66 -0
  118. data/gemfiles/ruby_2.1.10_contrib_old.gemfile.lock +305 -0
  119. data/gemfiles/ruby_2.1.10_core_old.gemfile +33 -0
  120. data/gemfiles/ruby_2.1.10_core_old.gemfile.lock +118 -0
  121. data/gemfiles/ruby_2.1.10_rails30_postgres.gemfile +39 -0
  122. data/gemfiles/ruby_2.1.10_rails30_postgres.gemfile.lock +196 -0
  123. data/gemfiles/ruby_2.1.10_rails30_postgres_sidekiq.gemfile +40 -0
  124. data/gemfiles/ruby_2.1.10_rails30_postgres_sidekiq.gemfile.lock +205 -0
  125. data/gemfiles/ruby_2.1.10_rails32_mysql2.gemfile +42 -0
  126. data/gemfiles/ruby_2.1.10_rails32_mysql2.gemfile.lock +215 -0
  127. data/gemfiles/ruby_2.1.10_rails32_postgres.gemfile +39 -0
  128. data/gemfiles/ruby_2.1.10_rails32_postgres.gemfile.lock +204 -0
  129. data/gemfiles/ruby_2.1.10_rails32_postgres_redis.gemfile +41 -0
  130. data/gemfiles/ruby_2.1.10_rails32_postgres_redis.gemfile.lock +223 -0
  131. data/gemfiles/ruby_2.1.10_rails32_postgres_sidekiq.gemfile +40 -0
  132. data/gemfiles/ruby_2.1.10_rails32_postgres_sidekiq.gemfile.lock +213 -0
  133. data/gemfiles/ruby_2.1.10_rails4_mysql2.gemfile +38 -0
  134. data/gemfiles/ruby_2.1.10_rails4_mysql2.gemfile.lock +218 -0
  135. data/gemfiles/ruby_2.1.10_rails4_postgres.gemfile +38 -0
  136. data/gemfiles/ruby_2.1.10_rails4_postgres.gemfile.lock +218 -0
  137. data/gemfiles/ruby_2.1.10_rails4_postgres_redis.gemfile +40 -0
  138. data/gemfiles/ruby_2.1.10_rails4_postgres_redis.gemfile.lock +237 -0
  139. data/gemfiles/ruby_2.2.10_contrib.gemfile +73 -0
  140. data/gemfiles/ruby_2.2.10_contrib.gemfile.lock +1450 -0
  141. data/gemfiles/ruby_2.2.10_core_old.gemfile +33 -0
  142. data/gemfiles/ruby_2.2.10_core_old.gemfile.lock +118 -0
  143. data/gemfiles/ruby_2.2.10_rails30_postgres.gemfile +39 -0
  144. data/gemfiles/ruby_2.2.10_rails30_postgres.gemfile.lock +196 -0
  145. data/gemfiles/ruby_2.2.10_rails30_postgres_sidekiq.gemfile +40 -0
  146. data/gemfiles/ruby_2.2.10_rails30_postgres_sidekiq.gemfile.lock +205 -0
  147. data/gemfiles/ruby_2.2.10_rails32_mysql2.gemfile +41 -0
  148. data/gemfiles/ruby_2.2.10_rails32_mysql2.gemfile.lock +212 -0
  149. data/gemfiles/ruby_2.2.10_rails32_postgres.gemfile +39 -0
  150. data/gemfiles/ruby_2.2.10_rails32_postgres.gemfile.lock +204 -0
  151. data/gemfiles/ruby_2.2.10_rails32_postgres_redis.gemfile +41 -0
  152. data/gemfiles/ruby_2.2.10_rails32_postgres_redis.gemfile.lock +223 -0
  153. data/gemfiles/ruby_2.2.10_rails32_postgres_sidekiq.gemfile +40 -0
  154. data/gemfiles/ruby_2.2.10_rails32_postgres_sidekiq.gemfile.lock +213 -0
  155. data/gemfiles/ruby_2.2.10_rails4_mysql2.gemfile +38 -0
  156. data/gemfiles/ruby_2.2.10_rails4_mysql2.gemfile.lock +218 -0
  157. data/gemfiles/ruby_2.2.10_rails4_postgres.gemfile +38 -0
  158. data/gemfiles/ruby_2.2.10_rails4_postgres.gemfile.lock +218 -0
  159. data/gemfiles/ruby_2.2.10_rails4_postgres_redis.gemfile +40 -0
  160. data/gemfiles/ruby_2.2.10_rails4_postgres_redis.gemfile.lock +237 -0
  161. data/gemfiles/ruby_2.2.10_rails4_postgres_sidekiq.gemfile +40 -0
  162. data/gemfiles/ruby_2.2.10_rails4_postgres_sidekiq.gemfile.lock +229 -0
  163. data/gemfiles/ruby_2.2.10_rails5_mysql2.gemfile +38 -0
  164. data/gemfiles/ruby_2.2.10_rails5_mysql2.gemfile.lock +234 -0
  165. data/gemfiles/ruby_2.2.10_rails5_postgres.gemfile +38 -0
  166. data/gemfiles/ruby_2.2.10_rails5_postgres.gemfile.lock +234 -0
  167. data/gemfiles/ruby_2.2.10_rails5_postgres_redis.gemfile +39 -0
  168. data/gemfiles/ruby_2.2.10_rails5_postgres_redis.gemfile.lock +236 -0
  169. data/gemfiles/ruby_2.2.10_rails5_postgres_redis_activesupport.gemfile +39 -0
  170. data/gemfiles/ruby_2.2.10_rails5_postgres_redis_activesupport.gemfile.lock +236 -0
  171. data/gemfiles/ruby_2.2.10_rails5_postgres_sidekiq.gemfile +40 -0
  172. data/gemfiles/ruby_2.2.10_rails5_postgres_sidekiq.gemfile.lock +245 -0
  173. data/gemfiles/ruby_2.3.8_contrib.gemfile +73 -0
  174. data/gemfiles/ruby_2.3.8_contrib.gemfile.lock +1459 -0
  175. data/gemfiles/ruby_2.3.8_contrib_old.gemfile +34 -0
  176. data/gemfiles/ruby_2.3.8_contrib_old.gemfile.lock +127 -0
  177. data/gemfiles/ruby_2.3.8_core_old.gemfile +33 -0
  178. data/gemfiles/ruby_2.3.8_core_old.gemfile.lock +123 -0
  179. data/gemfiles/ruby_2.3.8_cucumber3.gemfile +34 -0
  180. data/gemfiles/ruby_2.3.8_cucumber3.gemfile.lock +144 -0
  181. data/gemfiles/ruby_2.3.8_cucumber4.gemfile +34 -0
  182. data/gemfiles/ruby_2.3.8_cucumber4.gemfile.lock +174 -0
  183. data/gemfiles/ruby_2.3.8_rails30_postgres.gemfile +39 -0
  184. data/gemfiles/ruby_2.3.8_rails30_postgres.gemfile.lock +201 -0
  185. data/gemfiles/ruby_2.3.8_rails30_postgres_sidekiq.gemfile +40 -0
  186. data/gemfiles/ruby_2.3.8_rails30_postgres_sidekiq.gemfile.lock +210 -0
  187. data/gemfiles/ruby_2.3.8_rails32_mysql2.gemfile +41 -0
  188. data/gemfiles/ruby_2.3.8_rails32_mysql2.gemfile.lock +217 -0
  189. data/gemfiles/ruby_2.3.8_rails32_postgres.gemfile +39 -0
  190. data/gemfiles/ruby_2.3.8_rails32_postgres.gemfile.lock +209 -0
  191. data/gemfiles/ruby_2.3.8_rails32_postgres_redis.gemfile +41 -0
  192. data/gemfiles/ruby_2.3.8_rails32_postgres_redis.gemfile.lock +228 -0
  193. data/gemfiles/ruby_2.3.8_rails32_postgres_sidekiq.gemfile +40 -0
  194. data/gemfiles/ruby_2.3.8_rails32_postgres_sidekiq.gemfile.lock +218 -0
  195. data/gemfiles/ruby_2.3.8_rails4_mysql2.gemfile +38 -0
  196. data/gemfiles/ruby_2.3.8_rails4_mysql2.gemfile.lock +223 -0
  197. data/gemfiles/ruby_2.3.8_rails4_postgres.gemfile +38 -0
  198. data/gemfiles/ruby_2.3.8_rails4_postgres.gemfile.lock +223 -0
  199. data/gemfiles/ruby_2.3.8_rails4_postgres_redis.gemfile +40 -0
  200. data/gemfiles/ruby_2.3.8_rails4_postgres_redis.gemfile.lock +242 -0
  201. data/gemfiles/ruby_2.3.8_rails4_postgres_sidekiq.gemfile +40 -0
  202. data/gemfiles/ruby_2.3.8_rails4_postgres_sidekiq.gemfile.lock +234 -0
  203. data/gemfiles/ruby_2.3.8_rails5_mysql2.gemfile +37 -0
  204. data/gemfiles/ruby_2.3.8_rails5_mysql2.gemfile.lock +234 -0
  205. data/gemfiles/ruby_2.3.8_rails5_postgres.gemfile +37 -0
  206. data/gemfiles/ruby_2.3.8_rails5_postgres.gemfile.lock +234 -0
  207. data/gemfiles/ruby_2.3.8_rails5_postgres_redis.gemfile +38 -0
  208. data/gemfiles/ruby_2.3.8_rails5_postgres_redis.gemfile.lock +236 -0
  209. data/gemfiles/ruby_2.3.8_rails5_postgres_redis_activesupport.gemfile +38 -0
  210. data/gemfiles/ruby_2.3.8_rails5_postgres_redis_activesupport.gemfile.lock +236 -0
  211. data/gemfiles/ruby_2.3.8_rails5_postgres_sidekiq.gemfile +39 -0
  212. data/gemfiles/ruby_2.3.8_rails5_postgres_sidekiq.gemfile.lock +245 -0
  213. data/gemfiles/ruby_2.3.8_resque2_redis3.gemfile +35 -0
  214. data/gemfiles/ruby_2.3.8_resque2_redis3.gemfile.lock +150 -0
  215. data/gemfiles/ruby_2.3.8_resque2_redis4.gemfile +35 -0
  216. data/gemfiles/ruby_2.3.8_resque2_redis4.gemfile.lock +150 -0
  217. data/gemfiles/ruby_2.4.6_contrib.gemfile +78 -0
  218. data/gemfiles/ruby_2.4.6_contrib.gemfile.lock +1513 -0
  219. data/gemfiles/ruby_2.4.6_contrib_old.gemfile +38 -0
  220. data/gemfiles/ruby_2.4.6_contrib_old.gemfile.lock +155 -0
  221. data/gemfiles/ruby_2.4.6_core_old.gemfile +37 -0
  222. data/gemfiles/ruby_2.4.6_core_old.gemfile.lock +151 -0
  223. data/gemfiles/ruby_2.4.6_cucumber3.gemfile +38 -0
  224. data/gemfiles/ruby_2.4.6_cucumber3.gemfile.lock +172 -0
  225. data/gemfiles/ruby_2.4.6_cucumber4.gemfile +38 -0
  226. data/gemfiles/ruby_2.4.6_cucumber4.gemfile.lock +202 -0
  227. data/gemfiles/ruby_2.4.6_rails5_mysql2.gemfile +41 -0
  228. data/gemfiles/ruby_2.4.6_rails5_mysql2.gemfile.lock +262 -0
  229. data/gemfiles/ruby_2.4.6_rails5_postgres.gemfile +41 -0
  230. data/gemfiles/ruby_2.4.6_rails5_postgres.gemfile.lock +262 -0
  231. data/gemfiles/ruby_2.4.6_rails5_postgres_redis.gemfile +42 -0
  232. data/gemfiles/ruby_2.4.6_rails5_postgres_redis.gemfile.lock +264 -0
  233. data/gemfiles/ruby_2.4.6_rails5_postgres_redis_activesupport.gemfile +42 -0
  234. data/gemfiles/ruby_2.4.6_rails5_postgres_redis_activesupport.gemfile.lock +264 -0
  235. data/gemfiles/ruby_2.4.6_rails5_postgres_sidekiq.gemfile +43 -0
  236. data/gemfiles/ruby_2.4.6_rails5_postgres_sidekiq.gemfile.lock +273 -0
  237. data/gemfiles/ruby_2.4.6_resque2_redis3.gemfile +39 -0
  238. data/gemfiles/ruby_2.4.6_resque2_redis3.gemfile.lock +178 -0
  239. data/gemfiles/ruby_2.4.6_resque2_redis4.gemfile +39 -0
  240. data/gemfiles/ruby_2.4.6_resque2_redis4.gemfile.lock +178 -0
  241. data/gemfiles/ruby_2.5.6_contrib.gemfile +83 -0
  242. data/gemfiles/ruby_2.5.6_contrib.gemfile.lock +1526 -0
  243. data/gemfiles/ruby_2.5.6_contrib_old.gemfile +39 -0
  244. data/gemfiles/ruby_2.5.6_contrib_old.gemfile.lock +165 -0
  245. data/gemfiles/ruby_2.5.6_core_old.gemfile +38 -0
  246. data/gemfiles/ruby_2.5.6_core_old.gemfile.lock +161 -0
  247. data/gemfiles/ruby_2.5.6_cucumber3.gemfile +39 -0
  248. data/gemfiles/ruby_2.5.6_cucumber3.gemfile.lock +182 -0
  249. data/gemfiles/ruby_2.5.6_cucumber4.gemfile +39 -0
  250. data/gemfiles/ruby_2.5.6_cucumber4.gemfile.lock +214 -0
  251. data/gemfiles/ruby_2.5.6_cucumber5.gemfile +39 -0
  252. data/gemfiles/ruby_2.5.6_cucumber5.gemfile.lock +214 -0
  253. data/gemfiles/ruby_2.5.6_rails5_mysql2.gemfile +44 -0
  254. data/gemfiles/ruby_2.5.6_rails5_mysql2.gemfile.lock +276 -0
  255. data/gemfiles/ruby_2.5.6_rails5_postgres.gemfile +44 -0
  256. data/gemfiles/ruby_2.5.6_rails5_postgres.gemfile.lock +276 -0
  257. data/gemfiles/ruby_2.5.6_rails5_postgres_redis.gemfile +45 -0
  258. data/gemfiles/ruby_2.5.6_rails5_postgres_redis.gemfile.lock +278 -0
  259. data/gemfiles/ruby_2.5.6_rails5_postgres_redis_activesupport.gemfile +45 -0
  260. data/gemfiles/ruby_2.5.6_rails5_postgres_redis_activesupport.gemfile.lock +278 -0
  261. data/gemfiles/ruby_2.5.6_rails5_postgres_sidekiq.gemfile +46 -0
  262. data/gemfiles/ruby_2.5.6_rails5_postgres_sidekiq.gemfile.lock +284 -0
  263. data/gemfiles/ruby_2.5.6_rails61_mysql2.gemfile +44 -0
  264. data/gemfiles/ruby_2.5.6_rails61_mysql2.gemfile.lock +295 -0
  265. data/gemfiles/ruby_2.5.6_rails61_postgres.gemfile +44 -0
  266. data/gemfiles/ruby_2.5.6_rails61_postgres.gemfile.lock +295 -0
  267. data/gemfiles/ruby_2.5.6_rails61_postgres_redis.gemfile +45 -0
  268. data/gemfiles/ruby_2.5.6_rails61_postgres_redis.gemfile.lock +297 -0
  269. data/gemfiles/ruby_2.5.6_rails61_postgres_sidekiq.gemfile +45 -0
  270. data/gemfiles/ruby_2.5.6_rails61_postgres_sidekiq.gemfile.lock +302 -0
  271. data/gemfiles/ruby_2.5.6_rails6_mysql2.gemfile +44 -0
  272. data/gemfiles/ruby_2.5.6_rails6_mysql2.gemfile.lock +292 -0
  273. data/gemfiles/ruby_2.5.6_rails6_postgres.gemfile +44 -0
  274. data/gemfiles/ruby_2.5.6_rails6_postgres.gemfile.lock +292 -0
  275. data/gemfiles/ruby_2.5.6_rails6_postgres_redis.gemfile +45 -0
  276. data/gemfiles/ruby_2.5.6_rails6_postgres_redis.gemfile.lock +294 -0
  277. data/gemfiles/ruby_2.5.6_rails6_postgres_redis_activesupport.gemfile +45 -0
  278. data/gemfiles/ruby_2.5.6_rails6_postgres_redis_activesupport.gemfile.lock +294 -0
  279. data/gemfiles/ruby_2.5.6_rails6_postgres_sidekiq.gemfile +46 -0
  280. data/gemfiles/ruby_2.5.6_rails6_postgres_sidekiq.gemfile.lock +300 -0
  281. data/gemfiles/ruby_2.5.6_resque2_redis3.gemfile +40 -0
  282. data/gemfiles/ruby_2.5.6_resque2_redis3.gemfile.lock +188 -0
  283. data/gemfiles/ruby_2.5.6_resque2_redis4.gemfile +40 -0
  284. data/gemfiles/ruby_2.5.6_resque2_redis4.gemfile.lock +188 -0
  285. data/gemfiles/ruby_2.6.4_contrib.gemfile +79 -0
  286. data/gemfiles/ruby_2.6.4_contrib.gemfile.lock +1524 -0
  287. data/gemfiles/ruby_2.6.4_contrib_old.gemfile +39 -0
  288. data/gemfiles/ruby_2.6.4_contrib_old.gemfile.lock +167 -0
  289. data/gemfiles/ruby_2.6.4_core_old.gemfile +38 -0
  290. data/gemfiles/ruby_2.6.4_core_old.gemfile.lock +163 -0
  291. data/gemfiles/ruby_2.6.4_cucumber3.gemfile +39 -0
  292. data/gemfiles/ruby_2.6.4_cucumber3.gemfile.lock +184 -0
  293. data/gemfiles/ruby_2.6.4_cucumber4.gemfile +39 -0
  294. data/gemfiles/ruby_2.6.4_cucumber4.gemfile.lock +216 -0
  295. data/gemfiles/ruby_2.6.4_cucumber5.gemfile +39 -0
  296. data/gemfiles/ruby_2.6.4_cucumber5.gemfile.lock +216 -0
  297. data/gemfiles/ruby_2.6.4_rails5_mysql2.gemfile +42 -0
  298. data/gemfiles/ruby_2.6.4_rails5_mysql2.gemfile.lock +276 -0
  299. data/gemfiles/ruby_2.6.4_rails5_postgres.gemfile +42 -0
  300. data/gemfiles/ruby_2.6.4_rails5_postgres.gemfile.lock +276 -0
  301. data/gemfiles/ruby_2.6.4_rails5_postgres_redis.gemfile +43 -0
  302. data/gemfiles/ruby_2.6.4_rails5_postgres_redis.gemfile.lock +278 -0
  303. data/gemfiles/ruby_2.6.4_rails5_postgres_redis_activesupport.gemfile +43 -0
  304. data/gemfiles/ruby_2.6.4_rails5_postgres_redis_activesupport.gemfile.lock +278 -0
  305. data/gemfiles/ruby_2.6.4_rails5_postgres_sidekiq.gemfile +44 -0
  306. data/gemfiles/ruby_2.6.4_rails5_postgres_sidekiq.gemfile.lock +284 -0
  307. data/gemfiles/ruby_2.6.4_rails61_mysql2.gemfile +42 -0
  308. data/gemfiles/ruby_2.6.4_rails61_mysql2.gemfile.lock +295 -0
  309. data/gemfiles/ruby_2.6.4_rails61_postgres.gemfile +42 -0
  310. data/gemfiles/ruby_2.6.4_rails61_postgres.gemfile.lock +295 -0
  311. data/gemfiles/ruby_2.6.4_rails61_postgres_redis.gemfile +43 -0
  312. data/gemfiles/ruby_2.6.4_rails61_postgres_redis.gemfile.lock +297 -0
  313. data/gemfiles/ruby_2.6.4_rails61_postgres_sidekiq.gemfile +43 -0
  314. data/gemfiles/ruby_2.6.4_rails61_postgres_sidekiq.gemfile.lock +302 -0
  315. data/gemfiles/ruby_2.6.4_rails6_mysql2.gemfile +42 -0
  316. data/gemfiles/ruby_2.6.4_rails6_mysql2.gemfile.lock +292 -0
  317. data/gemfiles/ruby_2.6.4_rails6_postgres.gemfile +42 -0
  318. data/gemfiles/ruby_2.6.4_rails6_postgres.gemfile.lock +292 -0
  319. data/gemfiles/ruby_2.6.4_rails6_postgres_redis.gemfile +43 -0
  320. data/gemfiles/ruby_2.6.4_rails6_postgres_redis.gemfile.lock +294 -0
  321. data/gemfiles/ruby_2.6.4_rails6_postgres_redis_activesupport.gemfile +43 -0
  322. data/gemfiles/ruby_2.6.4_rails6_postgres_redis_activesupport.gemfile.lock +294 -0
  323. data/gemfiles/ruby_2.6.4_rails6_postgres_sidekiq.gemfile +44 -0
  324. data/gemfiles/ruby_2.6.4_rails6_postgres_sidekiq.gemfile.lock +300 -0
  325. data/gemfiles/ruby_2.6.4_resque2_redis3.gemfile +40 -0
  326. data/gemfiles/ruby_2.6.4_resque2_redis3.gemfile.lock +190 -0
  327. data/gemfiles/ruby_2.6.4_resque2_redis4.gemfile +40 -0
  328. data/gemfiles/ruby_2.6.4_resque2_redis4.gemfile.lock +190 -0
  329. data/gemfiles/ruby_2.7.0_contrib.gemfile +78 -0
  330. data/gemfiles/ruby_2.7.0_contrib.gemfile.lock +1523 -0
  331. data/gemfiles/ruby_2.7.0_contrib_old.gemfile +39 -0
  332. data/gemfiles/ruby_2.7.0_contrib_old.gemfile.lock +167 -0
  333. data/gemfiles/ruby_2.7.0_core_old.gemfile +38 -0
  334. data/gemfiles/ruby_2.7.0_core_old.gemfile.lock +163 -0
  335. data/gemfiles/ruby_2.7.0_cucumber3.gemfile +39 -0
  336. data/gemfiles/ruby_2.7.0_cucumber3.gemfile.lock +184 -0
  337. data/gemfiles/ruby_2.7.0_cucumber4.gemfile +39 -0
  338. data/gemfiles/ruby_2.7.0_cucumber4.gemfile.lock +216 -0
  339. data/gemfiles/ruby_2.7.0_cucumber5.gemfile +39 -0
  340. data/gemfiles/ruby_2.7.0_cucumber5.gemfile.lock +216 -0
  341. data/gemfiles/ruby_2.7.0_rails5_mysql2.gemfile +42 -0
  342. data/gemfiles/ruby_2.7.0_rails5_mysql2.gemfile.lock +276 -0
  343. data/gemfiles/ruby_2.7.0_rails5_postgres.gemfile +42 -0
  344. data/gemfiles/ruby_2.7.0_rails5_postgres.gemfile.lock +276 -0
  345. data/gemfiles/ruby_2.7.0_rails5_postgres_redis.gemfile +44 -0
  346. data/gemfiles/ruby_2.7.0_rails5_postgres_redis.gemfile.lock +295 -0
  347. data/gemfiles/ruby_2.7.0_rails5_postgres_redis_activesupport.gemfile +44 -0
  348. data/gemfiles/ruby_2.7.0_rails5_postgres_redis_activesupport.gemfile.lock +295 -0
  349. data/gemfiles/ruby_2.7.0_rails5_postgres_sidekiq.gemfile +44 -0
  350. data/gemfiles/ruby_2.7.0_rails5_postgres_sidekiq.gemfile.lock +284 -0
  351. data/gemfiles/ruby_2.7.0_rails61_mysql2.gemfile +42 -0
  352. data/gemfiles/ruby_2.7.0_rails61_mysql2.gemfile.lock +295 -0
  353. data/gemfiles/ruby_2.7.0_rails61_postgres.gemfile +42 -0
  354. data/gemfiles/ruby_2.7.0_rails61_postgres.gemfile.lock +295 -0
  355. data/gemfiles/ruby_2.7.0_rails61_postgres_redis.gemfile +43 -0
  356. data/gemfiles/ruby_2.7.0_rails61_postgres_redis.gemfile.lock +297 -0
  357. data/gemfiles/ruby_2.7.0_rails61_postgres_sidekiq.gemfile +43 -0
  358. data/gemfiles/ruby_2.7.0_rails61_postgres_sidekiq.gemfile.lock +302 -0
  359. data/gemfiles/ruby_2.7.0_rails6_mysql2.gemfile +42 -0
  360. data/gemfiles/ruby_2.7.0_rails6_mysql2.gemfile.lock +292 -0
  361. data/gemfiles/ruby_2.7.0_rails6_postgres.gemfile +42 -0
  362. data/gemfiles/ruby_2.7.0_rails6_postgres.gemfile.lock +292 -0
  363. data/gemfiles/ruby_2.7.0_rails6_postgres_redis.gemfile +44 -0
  364. data/gemfiles/ruby_2.7.0_rails6_postgres_redis.gemfile.lock +311 -0
  365. data/gemfiles/ruby_2.7.0_rails6_postgres_redis_activesupport.gemfile +44 -0
  366. data/gemfiles/ruby_2.7.0_rails6_postgres_redis_activesupport.gemfile.lock +311 -0
  367. data/gemfiles/ruby_2.7.0_rails6_postgres_sidekiq.gemfile +44 -0
  368. data/gemfiles/ruby_2.7.0_rails6_postgres_sidekiq.gemfile.lock +300 -0
  369. data/gemfiles/ruby_2.7.0_resque2_redis3.gemfile +40 -0
  370. data/gemfiles/ruby_2.7.0_resque2_redis3.gemfile.lock +190 -0
  371. data/gemfiles/ruby_2.7.0_resque2_redis4.gemfile +40 -0
  372. data/gemfiles/ruby_2.7.0_resque2_redis4.gemfile.lock +190 -0
  373. data/gemfiles/ruby_3.0.0_contrib.gemfile +77 -0
  374. data/gemfiles/ruby_3.0.0_contrib.gemfile.lock +1534 -0
  375. data/gemfiles/ruby_3.0.0_core_old.gemfile +39 -0
  376. data/gemfiles/ruby_3.0.0_core_old.gemfile.lock +165 -0
  377. data/gemfiles/ruby_3.0.0_cucumber3.gemfile +40 -0
  378. data/gemfiles/ruby_3.0.0_cucumber3.gemfile.lock +186 -0
  379. data/gemfiles/ruby_3.0.0_cucumber4.gemfile +40 -0
  380. data/gemfiles/ruby_3.0.0_cucumber4.gemfile.lock +218 -0
  381. data/gemfiles/ruby_3.0.0_cucumber5.gemfile +40 -0
  382. data/gemfiles/ruby_3.0.0_cucumber5.gemfile.lock +218 -0
  383. data/gemfiles/ruby_3.0.0_rails61_mysql2.gemfile +43 -0
  384. data/gemfiles/ruby_3.0.0_rails61_mysql2.gemfile.lock +295 -0
  385. data/gemfiles/ruby_3.0.0_rails61_postgres.gemfile +43 -0
  386. data/gemfiles/ruby_3.0.0_rails61_postgres.gemfile.lock +295 -0
  387. data/gemfiles/ruby_3.0.0_rails61_postgres_redis.gemfile +44 -0
  388. data/gemfiles/ruby_3.0.0_rails61_postgres_redis.gemfile.lock +297 -0
  389. data/gemfiles/ruby_3.0.0_rails61_postgres_sidekiq.gemfile +44 -0
  390. data/gemfiles/ruby_3.0.0_rails61_postgres_sidekiq.gemfile.lock +302 -0
  391. data/gemfiles/ruby_3.0.0_resque2_redis3.gemfile +41 -0
  392. data/gemfiles/ruby_3.0.0_resque2_redis3.gemfile.lock +192 -0
  393. data/gemfiles/ruby_3.0.0_resque2_redis4.gemfile +41 -0
  394. data/gemfiles/ruby_3.0.0_resque2_redis4.gemfile.lock +192 -0
  395. data/lib/ddtrace/configuration/agent_settings_resolver.rb +241 -0
  396. data/lib/ddtrace/configuration/components.rb +22 -29
  397. data/lib/ddtrace/configuration/settings.rb +16 -6
  398. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -1
  399. data/lib/ddtrace/contrib/action_pack/utils.rb +1 -1
  400. data/lib/ddtrace/contrib/auto_instrument.rb +0 -1
  401. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +4 -0
  402. data/lib/ddtrace/error.rb +85 -9
  403. data/lib/ddtrace/ext/profiling.rb +1 -0
  404. data/lib/ddtrace/ext/transport.rb +1 -0
  405. data/lib/ddtrace/profiling.rb +73 -22
  406. data/lib/ddtrace/profiling/collectors/stack.rb +12 -6
  407. data/lib/ddtrace/profiling/ext/cpu.rb +0 -2
  408. data/lib/ddtrace/profiling/ext/cthread.rb +54 -31
  409. data/lib/ddtrace/profiling/profiler.rb +2 -0
  410. data/lib/ddtrace/profiling/recorder.rb +8 -0
  411. data/lib/ddtrace/profiling/scheduler.rb +32 -11
  412. data/lib/ddtrace/profiling/transport/http.rb +51 -55
  413. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +1 -0
  414. data/lib/ddtrace/runtime/container.rb +16 -8
  415. data/lib/ddtrace/tracer.rb +7 -28
  416. data/lib/ddtrace/transport/http.rb +36 -33
  417. data/lib/ddtrace/version.rb +13 -1
  418. data/lib/ddtrace/workers/loop.rb +13 -1
  419. data/lib/ddtrace/workers/trace_writer.rb +2 -5
  420. data/lib/ddtrace/writer.rb +4 -1
  421. metadata +393 -6
data/lib/ddtrace/error.rb CHANGED
@@ -1,23 +1,99 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Datadog global namespace
2
4
  module Datadog
3
5
  # Error is a value-object responsible for sanitizing/encapsulating error data
4
6
  class Error
5
7
  attr_reader :type, :message, :backtrace
6
8
 
7
- def self.build_from(value)
8
- case value
9
- when Error then value
10
- when Array then new(*value)
11
- when Exception then new(value.class, value.message, value.backtrace)
12
- when ContainsMessage then new(value.class, value.message)
13
- else BlankError
9
+ class << self
10
+ def build_from(value)
11
+ case value
12
+ when Error then value
13
+ when Array then new(*value)
14
+ when Exception then new(value.class, value.message, full_backtrace(value))
15
+ when ContainsMessage then new(value.class, value.message)
16
+ else BlankError
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1.0')
23
+ # Ruby 2.0 exceptions don't have `cause`.
24
+ # Only current exception stack trace is reported.
25
+ # This is the same behavior as before.
26
+ def full_backtrace(ex)
27
+ backtrace = ex.backtrace
28
+ backtrace.join("\n") if backtrace
29
+ end
30
+ else
31
+ # Returns a stack trace with nested error causes and details.
32
+ #
33
+ # This manually implements Ruby >= 2.6 error output for two reasons:
34
+ #
35
+ # 1. It is not available in Ruby < 2.6.
36
+ # 2. It's measurably faster to manually implement it in Ruby.
37
+ #
38
+ # This method mimics the exact output of
39
+ # `ex.full_message(highlight: false, order: :top)`
40
+ # but it's around 3x faster in our benchmark test
41
+ # at `error_spec.rb`.
42
+ def full_backtrace(ex)
43
+ backtrace = String.new
44
+ backtrace_for(ex, backtrace)
45
+
46
+ # Avoid circular causes
47
+ causes = {}
48
+ causes[ex] = true
49
+
50
+ while (cause = ex.cause) && !causes.key?(cause)
51
+ backtrace_for(cause, backtrace)
52
+ causes[cause] = true
53
+ end
54
+
55
+ backtrace
56
+ end
57
+
58
+ # Outputs the following format for exceptions:
59
+ #
60
+ # ```
61
+ # error_spec.rb:55:in `wrapper': wrapper layer (RuntimeError)
62
+ # from error_spec.rb:40:in `wrapper'
63
+ # from error_spec.rb:61:in `caller'
64
+ # ...
65
+ # ```
66
+ def backtrace_for(ex, backtrace)
67
+ trace = ex.backtrace
68
+ return unless trace
69
+
70
+ if trace[0]
71
+ # Add Exception information to error line
72
+ backtrace << trace[0]
73
+ backtrace << ': '
74
+ backtrace << ex.message
75
+ backtrace << ' ('
76
+ backtrace << ex.class.to_s
77
+ backtrace << ')'
78
+ end
79
+
80
+ if trace[1]
81
+ # Ident stack trace for caller lines, to separate
82
+ # them from the main error lines.
83
+ trace[1..-1].each do |line|
84
+ backtrace << "\n\tfrom "
85
+ backtrace << line
86
+ end
87
+ end
88
+
89
+ backtrace << "\n"
90
+ end
14
91
  end
15
92
  end
16
93
 
17
94
  def initialize(type = nil, message = nil, backtrace = nil)
18
- backtrace = Array(backtrace).join("\n")
95
+ backtrace = Array(backtrace).join("\n") unless backtrace.is_a?(String)
19
96
 
20
- # DEV: We should measure if `Utils.utf8_encode` is still needed in practice.
21
97
  @type = Utils.utf8_encode(type)
22
98
  @message = Utils.utf8_encode(message)
23
99
  @backtrace = Utils.utf8_encode(backtrace)
@@ -29,6 +29,7 @@ module Datadog
29
29
  FORM_FIELD_TAG_ENV = 'env'.freeze
30
30
  FORM_FIELD_TAG_HOST = 'host'.freeze
31
31
  FORM_FIELD_TAG_LANGUAGE = 'language'.freeze
32
+ FORM_FIELD_TAG_PID = 'pid'.freeze
32
33
  FORM_FIELD_TAG_PROFILER_VERSION = 'profiler_version'.freeze
33
34
  FORM_FIELD_TAG_RUNTIME = 'runtime'.freeze
34
35
  FORM_FIELD_TAG_RUNTIME_ENGINE = 'runtime_engine'.freeze
@@ -4,6 +4,7 @@ module Datadog
4
4
  module HTTP
5
5
  DEFAULT_HOST = '127.0.0.1'.freeze
6
6
  DEFAULT_PORT = 8126
7
+ DEFAULT_TIMEOUT_SECONDS = 1
7
8
  ENV_DEFAULT_HOST = 'DD_AGENT_HOST'.freeze
8
9
  ENV_DEFAULT_PORT = 'DD_TRACE_AGENT_PORT'.freeze
9
10
  ENV_DEFAULT_URL = 'DD_TRACE_AGENT_URL'.freeze
@@ -4,40 +4,68 @@ module Datadog
4
4
  module_function
5
5
 
6
6
  GOOGLE_PROTOBUF_MINIMUM_VERSION = Gem::Version.new('3.0')
7
+ private_constant :GOOGLE_PROTOBUF_MINIMUM_VERSION
7
8
 
8
9
  def supported?
9
- google_protobuf_supported?
10
+ unsupported_reason.nil?
10
11
  end
11
12
 
12
- def native_cpu_time_supported?
13
- require 'ddtrace/profiling/ext/cpu'
14
- Ext::CPU.supported?
13
+ def unsupported_reason
14
+ # NOTE: Only the first matching reason is returned, so try to keep a nice order on reasons -- e.g. tell users
15
+ # first that they can't use this on JRuby before telling them that they are missing protobuf
16
+
17
+ ruby_engine_unsupported? || ruby_version_unsupported? ||
18
+ protobuf_gem_unavailable? || protobuf_version_unsupported? || protobuf_failed_to_load?
15
19
  end
16
20
 
17
- def google_protobuf_supported?
18
- RUBY_PLATFORM != 'java' \
19
- && !Gem.loaded_specs['google-protobuf'].nil? \
20
- && Gem.loaded_specs['google-protobuf'].version >= GOOGLE_PROTOBUF_MINIMUM_VERSION \
21
- && !defined?(@failed_to_load_protobuf)
21
+ def self.ruby_engine_unsupported?
22
+ 'JRuby is not supported' if RUBY_ENGINE == 'jruby'
22
23
  end
24
+ private_class_method :ruby_engine_unsupported?
23
25
 
24
- def load_profiling
25
- require 'ddtrace/profiling/ext/cpu'
26
- require 'ddtrace/profiling/ext/forking'
26
+ def self.ruby_version_unsupported?
27
+ 'Ruby >= 2.1 is required' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
28
+ end
29
+ private_class_method :ruby_version_unsupported?
27
30
 
28
- require 'ddtrace/profiling/collectors/stack'
29
- require 'ddtrace/profiling/exporter'
30
- require 'ddtrace/profiling/recorder'
31
- require 'ddtrace/profiling/scheduler'
32
- require 'ddtrace/profiling/tasks/setup'
33
- require 'ddtrace/profiling/transport/io'
34
- require 'ddtrace/profiling/transport/http'
35
- require 'ddtrace/profiling/profiler'
31
+ def self.protobuf_gem_unavailable?
32
+ if Gem.loaded_specs['google-protobuf'].nil?
33
+ "Missing google-protobuf dependency; please add `gem 'google-protobuf', '~> 3.0'` to your Gemfile or gems.rb file"
34
+ end
35
+ end
36
+ private_class_method :protobuf_gem_unavailable?
37
+
38
+ def self.protobuf_version_unsupported?
39
+ if Gem.loaded_specs['google-protobuf'].version < GOOGLE_PROTOBUF_MINIMUM_VERSION
40
+ 'Your google-protobuf is too old; ensure that you have google-protobuf >= 3.0 by ' \
41
+ "adding `gem 'google-protobuf', '~> 3.0'` to your Gemfile or gems.rb file"
42
+ end
43
+ end
44
+ private_class_method :protobuf_version_unsupported?
45
+
46
+ def self.protobuf_failed_to_load?
47
+ unless protobuf_loaded_successfully?
48
+ 'There was an error loading the google-protobuf library; see previous warning message for details'
49
+ end
50
+ end
51
+ private_class_method :protobuf_failed_to_load?
52
+
53
+ # The `google-protobuf` gem depends on a native component, and its creators helpfully tried to provide precompiled
54
+ # versions of this extension on rubygems.org.
55
+ #
56
+ # Unfortunately, for a long time, the supported Ruby versions metadata on these precompiled versions of the extension
57
+ # was not correctly set. (This is fixed in newer versions -- but not all Ruby versions we want to support can use
58
+ # these.)
59
+ #
60
+ # Thus, the gem can still be installed, but can be in a broken state. To avoid breaking customer applications, we
61
+ # use this helper to load it and gracefully handle failures.
62
+ def self.protobuf_loaded_successfully?
63
+ return @protobuf_loaded if defined?(@protobuf_loaded)
36
64
 
37
65
  begin
38
- require 'ddtrace/profiling/pprof/pprof_pb' if google_protobuf_supported?
66
+ require 'google/protobuf'
67
+ @protobuf_loaded = true
39
68
  rescue LoadError => e
40
- @failed_to_load_protobuf = true
41
69
  Kernel.warn(
42
70
  "[DDTRACE] Error while loading google-protobuf gem. Cause: '#{e.message}' Location: '#{e.backtrace.first}'. " \
43
71
  'This can happen when google-protobuf is missing its native components. ' \
@@ -46,8 +74,31 @@ module Datadog
46
74
  'If the error persists, please contact support via <https://docs.datadoghq.com/help/> or ' \
47
75
  'file a bug at <https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug>.'
48
76
  )
77
+ @protobuf_loaded = false
49
78
  end
50
79
  end
80
+ private_class_method :protobuf_loaded_successfully?
81
+
82
+ def self.load_profiling
83
+ return false unless supported?
84
+
85
+ require 'ddtrace/profiling/ext/cpu'
86
+ require 'ddtrace/profiling/ext/forking'
87
+
88
+ require 'ddtrace/profiling/collectors/stack'
89
+ require 'ddtrace/profiling/exporter'
90
+ require 'ddtrace/profiling/recorder'
91
+ require 'ddtrace/profiling/scheduler'
92
+ require 'ddtrace/profiling/tasks/setup'
93
+ require 'ddtrace/profiling/transport/io'
94
+ require 'ddtrace/profiling/transport/http'
95
+ require 'ddtrace/profiling/profiler'
96
+
97
+ require 'ddtrace/profiling/pprof/pprof_pb'
98
+
99
+ true
100
+ end
101
+ private_class_method :load_profiling
51
102
 
52
103
  load_profiling if supported?
53
104
  end
@@ -11,6 +11,7 @@ module Datadog
11
11
  # Collects stack trace samples from Ruby threads for both CPU-time (if available) and wall-clock.
12
12
  # Runs on its own background thread.
13
13
  #
14
+ # rubocop:disable Metrics/ClassLength
14
15
  class Stack < Worker
15
16
  include Workers::Polling
16
17
 
@@ -27,7 +28,7 @@ module Datadog
27
28
 
28
29
  def initialize(
29
30
  recorder,
30
- max_frames: nil,
31
+ max_frames:,
31
32
  ignore_thread: nil,
32
33
  max_time_usage_pct: DEFAULT_MAX_TIME_USAGE_PCT,
33
34
  thread_api: Thread,
@@ -36,8 +37,7 @@ module Datadog
36
37
  enabled: true
37
38
  )
38
39
  @recorder = recorder
39
- # TODO: Make this a required named argument after we drop support for Ruby 2.0
40
- @max_frames = max_frames || raise(ArgumentError, 'missing keyword :max_frames')
40
+ @max_frames = max_frames
41
41
  @ignore_thread = ignore_thread
42
42
  @max_time_usage_pct = max_time_usage_pct
43
43
  @thread_api = thread_api
@@ -52,6 +52,11 @@ module Datadog
52
52
  self.enabled = enabled
53
53
 
54
54
  @warn_about_missing_cpu_time_instrumentation_only_once = Datadog::Utils::OnlyOnce.new
55
+
56
+ # Cache this proc, since it's pretty expensive to keep recreating it
57
+ @build_backtrace_location = method(:build_backtrace_location).to_proc
58
+ # Cache this buffer, since it's pretty expensive to keep accessing it
59
+ @stack_sample_event_recorder = recorder[Events::StackSample]
55
60
  end
56
61
 
57
62
  def start
@@ -183,7 +188,7 @@ module Datadog
183
188
  def convert_backtrace_locations(locations)
184
189
  locations.collect do |location|
185
190
  # Re-use existing BacktraceLocation if identical copy, otherwise build a new one.
186
- recorder[Events::StackSample].cache(:backtrace_locations).fetch(
191
+ @stack_sample_event_recorder.cache(:backtrace_locations).fetch(
187
192
  # Function name
188
193
  location.base_label,
189
194
  # Line number
@@ -191,13 +196,13 @@ module Datadog
191
196
  # Filename
192
197
  location.path,
193
198
  # Build function
194
- &method(:build_backtrace_location)
199
+ &@build_backtrace_location
195
200
  )
196
201
  end
197
202
  end
198
203
 
199
204
  def build_backtrace_location(_id, base_label, lineno, path)
200
- string_table = recorder[Events::StackSample].string_table
205
+ string_table = @stack_sample_event_recorder.string_table
201
206
 
202
207
  Profiling::BacktraceLocation.new(
203
208
  string_table.fetch_string(base_label),
@@ -248,6 +253,7 @@ module Datadog
248
253
  end
249
254
  end
250
255
  end
256
+ # rubocop:enable Metrics/ClassLength
251
257
  end
252
258
  end
253
259
  end
@@ -40,8 +40,6 @@ module Datadog
40
40
  'Feature requires Linux; Windows is not supported'
41
41
  elsif !RUBY_PLATFORM.include?('linux')
42
42
  "Feature requires Linux; #{RUBY_PLATFORM} is not supported"
43
- elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
44
- 'Ruby >= 2.1 is required'
45
43
  elsif Gem::Specification.find_all_by_name('rollbar', ROLLBAR_INCOMPATIBLE_VERSIONS).any?
46
44
  'You have an incompatible rollbar gem version installed; ensure that you have rollbar >= 3.1.2 by ' \
47
45
  "adding `gem 'rollbar', '>= 3.1.2'` to your Gemfile or gems.rb file. " \
@@ -8,13 +8,33 @@ module Datadog
8
8
  layout :value, :int
9
9
  end
10
10
 
11
- # Extension used to enable CPU-time profiling via use of Pthread's `getcpuclockid`.
12
- module CThread
11
+ # Enables interfacing with pthread via FFI
12
+ module NativePthread
13
13
  extend FFI::Library
14
14
  ffi_lib ['pthread', 'libpthread.so.0']
15
15
  attach_function :pthread_self, [], :ulong
16
16
  attach_function :pthread_getcpuclockid, [:ulong, CClockId], :int
17
17
 
18
+ # NOTE: Only returns thread ID for thread that evaluates this call.
19
+ # a.k.a. evaluating `get_native_thread_id(thread_a)` from within
20
+ # `thread_b` will return `thread_b`'s thread ID, not `thread_a`'s.
21
+ def self.get_native_thread_id(thread)
22
+ return unless ::Thread.current == thread
23
+
24
+ pthread_self
25
+ end
26
+
27
+ def self.get_clock_id(thread, pthread_id)
28
+ return unless ::Thread.current == thread && pthread_id
29
+
30
+ clock = CClockId.new
31
+ clock[:value] = 0
32
+ pthread_getcpuclockid(pthread_id, clock).zero? ? clock[:value] : nil
33
+ end
34
+ end
35
+
36
+ # Extension used to enable CPU-time profiling via use of pthread's `getcpuclockid`.
37
+ module CThread
18
38
  def self.prepended(base)
19
39
  # Threads that have already been created, will not have resolved
20
40
  # a thread/clock ID. This is because these IDs can only be resolved
@@ -27,8 +47,30 @@ module Datadog
27
47
  base.current.send(:update_native_ids) if base.current.is_a?(CThread)
28
48
  end
29
49
 
30
- attr_reader \
31
- :native_thread_id
50
+ # Process::Waiter crash workaround:
51
+ #
52
+ # This is a workaround for a Ruby VM segfault (usually something like
53
+ # "[BUG] Segmentation fault at 0x0000000000000008") in the affected Ruby versions.
54
+ # See https://bugs.ruby-lang.org/issues/17807 and the regression tests added to this module's specs for details.
55
+ #
56
+ # In those Ruby versions, there's a very special subclass of `Thread` called `Process::Waiter` that causes VM
57
+ # crashes whenever something tries to read its instance variables. This subclass of thread only shows up when
58
+ # the `Process.detach` API gets used.
59
+ # In this module's specs you can find crash regression tests that include a way of reproducing it.
60
+ #
61
+ # The workaround is to use `defined?` to check first if the instance variable exists. This seems to be fine
62
+ # with Ruby.
63
+ # Note that this crash doesn't affect `@foo ||=` nor instance variable writes (after the first write ever of any
64
+ # instance variable on a `Process::Waiter`, then further reads and writes to that or any other instance are OK;
65
+ # it looks like there's some lazily-created structure that is missing and did not get created).
66
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3') &&
67
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
68
+ attr_reader :native_thread_id
69
+ else
70
+ def native_thread_id
71
+ defined?(@native_thread_id) && @native_thread_id
72
+ end
73
+ end
32
74
 
33
75
  def initialize(*args)
34
76
  @pid = ::Process.pid
@@ -48,11 +90,6 @@ module Datadog
48
90
  end
49
91
  ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
50
92
 
51
- def clock_id
52
- update_native_ids if forked?
53
- defined?(@clock_id) && @clock_id
54
- end
55
-
56
93
  def cpu_time(unit = :float_second)
57
94
  return unless clock_id && ::Process.respond_to?(:clock_gettime)
58
95
 
@@ -71,36 +108,22 @@ module Datadog
71
108
 
72
109
  private
73
110
 
74
- # Retrieves number of classes from runtime
111
+ def clock_id
112
+ update_native_ids if forked?
113
+ defined?(@clock_id) && @clock_id
114
+ end
115
+
75
116
  def forked?
76
117
  ::Process.pid != (@pid ||= nil)
77
118
  end
78
119
 
79
120
  def update_native_ids
80
- # Can only resolve if invoked from same thread.
121
+ # Can only resolve if invoked from same thread
81
122
  return unless ::Thread.current == self
82
123
 
83
124
  @pid = ::Process.pid
84
- @native_thread_id = get_native_thread_id
85
- @clock_id = get_clock_id(@native_thread_id)
86
- end
87
-
88
- def get_native_thread_id
89
- return unless ::Thread.current == self
90
-
91
- # NOTE: Only returns thread ID for thread that evaluates this call.
92
- # a.k.a. evaluating `thread_a.get_native_thread_id` from within
93
- # `thread_b` will return `thread_b`'s thread ID, not `thread_a`'s.
94
- pthread_self
95
- end
96
-
97
- def get_clock_id(pthread_id)
98
- return unless pthread_id && alive?
99
-
100
- # Build a struct, pass it to Pthread's getcpuclockid function.
101
- clock = CClockId.new
102
- clock[:value] = 0
103
- pthread_getcpuclockid(pthread_id, clock).zero? ? clock[:value] : nil
125
+ @native_thread_id = NativePthread.get_native_thread_id(self)
126
+ @clock_id = NativePthread.get_clock_id(self, @native_thread_id)
104
127
  end
105
128
  end
106
129