ddtrace 0.42.0 → 0.52.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (572) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +22 -0
  3. data/.gitignore +7 -1
  4. data/CHANGELOG.md +1474 -362
  5. data/CONTRIBUTING.md +2 -6
  6. data/LICENSE-3rdparty.csv +2 -0
  7. data/README.md +1 -0
  8. data/bin/ddtracerb +15 -0
  9. data/ddtrace.gemspec +18 -39
  10. data/docs/DevelopmentGuide.md +45 -2
  11. data/docs/GettingStarted.md +335 -79
  12. data/docs/ProfilingDevelopment.md +107 -0
  13. data/ext/ddtrace_profiling_native_extension/extconf.rb +28 -0
  14. data/ext/ddtrace_profiling_native_extension/profiling.c +17 -0
  15. data/lib/datadog/ci.rb +17 -0
  16. data/lib/datadog/ci/configuration/components.rb +31 -0
  17. data/lib/datadog/ci/configuration/settings.rb +37 -0
  18. data/lib/datadog/ci/context_flush.rb +29 -0
  19. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +31 -0
  20. data/lib/datadog/ci/contrib/cucumber/ext.rb +20 -0
  21. data/lib/datadog/ci/contrib/cucumber/formatter.rb +98 -0
  22. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +27 -0
  23. data/lib/datadog/ci/contrib/cucumber/integration.rb +48 -0
  24. data/lib/datadog/ci/contrib/cucumber/patcher.rb +26 -0
  25. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +31 -0
  26. data/lib/datadog/ci/contrib/rspec/example.rb +74 -0
  27. data/lib/datadog/ci/contrib/rspec/ext.rb +19 -0
  28. data/lib/datadog/ci/contrib/rspec/integration.rb +49 -0
  29. data/lib/datadog/ci/contrib/rspec/patcher.rb +26 -0
  30. data/lib/datadog/ci/ext/app_types.rb +10 -0
  31. data/lib/datadog/ci/ext/environment.rb +443 -0
  32. data/lib/datadog/ci/ext/settings.rb +11 -0
  33. data/lib/datadog/ci/ext/test.rb +35 -0
  34. data/lib/datadog/ci/extensions.rb +18 -0
  35. data/lib/datadog/ci/test.rb +77 -0
  36. data/lib/datadog/contrib.rb +69 -0
  37. data/lib/datadog/core/environment/cgroup.rb +52 -0
  38. data/lib/datadog/core/environment/class_count.rb +20 -0
  39. data/lib/datadog/core/environment/container.rb +91 -0
  40. data/lib/datadog/core/environment/ext.rb +27 -0
  41. data/lib/datadog/core/environment/gc.rb +19 -0
  42. data/lib/datadog/core/environment/identity.rb +51 -0
  43. data/lib/datadog/core/environment/socket.rb +17 -0
  44. data/lib/datadog/core/environment/thread_count.rb +19 -0
  45. data/lib/datadog/core/environment/variable_helpers.rb +42 -0
  46. data/lib/ddtrace.rb +22 -48
  47. data/lib/ddtrace/analytics.rb +3 -0
  48. data/lib/ddtrace/auto_instrument.rb +5 -0
  49. data/lib/ddtrace/auto_instrument_base.rb +7 -0
  50. data/lib/ddtrace/buffer.rb +10 -8
  51. data/lib/ddtrace/chunker.rb +1 -0
  52. data/lib/ddtrace/configuration.rb +132 -24
  53. data/lib/ddtrace/configuration/agent_settings_resolver.rb +231 -0
  54. data/lib/ddtrace/configuration/base.rb +9 -11
  55. data/lib/ddtrace/configuration/components.rb +167 -26
  56. data/lib/ddtrace/configuration/dependency_resolver.rb +1 -0
  57. data/lib/ddtrace/configuration/option.rb +1 -0
  58. data/lib/ddtrace/configuration/option_definition.rb +2 -3
  59. data/lib/ddtrace/configuration/option_definition_set.rb +1 -0
  60. data/lib/ddtrace/configuration/option_set.rb +1 -0
  61. data/lib/ddtrace/configuration/options.rb +7 -9
  62. data/lib/ddtrace/configuration/pin_setup.rb +1 -0
  63. data/lib/ddtrace/configuration/settings.rb +132 -12
  64. data/lib/ddtrace/context.rb +41 -20
  65. data/lib/ddtrace/context_flush.rb +15 -2
  66. data/lib/ddtrace/context_provider.rb +13 -2
  67. data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +1 -0
  68. data/lib/ddtrace/contrib/action_cable/event.rb +6 -4
  69. data/lib/ddtrace/contrib/action_cable/events.rb +1 -0
  70. data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +1 -0
  71. data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +1 -0
  72. data/lib/ddtrace/contrib/action_cable/events/transmit.rb +1 -0
  73. data/lib/ddtrace/contrib/action_cable/ext.rb +1 -0
  74. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +1 -0
  75. data/lib/ddtrace/contrib/action_cable/integration.rb +8 -0
  76. data/lib/ddtrace/contrib/action_cable/patcher.rb +1 -0
  77. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +22 -13
  78. data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +2 -1
  79. data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +1 -0
  80. data/lib/ddtrace/contrib/action_pack/ext.rb +1 -0
  81. data/lib/ddtrace/contrib/action_pack/integration.rb +8 -0
  82. data/lib/ddtrace/contrib/action_pack/patcher.rb +1 -0
  83. data/lib/ddtrace/contrib/action_pack/utils.rb +2 -1
  84. data/lib/ddtrace/contrib/action_view/configuration/settings.rb +1 -0
  85. data/lib/ddtrace/contrib/action_view/event.rb +4 -7
  86. data/lib/ddtrace/contrib/action_view/events.rb +1 -0
  87. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +2 -0
  88. data/lib/ddtrace/contrib/action_view/events/render_template.rb +2 -0
  89. data/lib/ddtrace/contrib/action_view/ext.rb +1 -0
  90. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +1 -0
  91. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +1 -0
  92. data/lib/ddtrace/contrib/action_view/integration.rb +8 -0
  93. data/lib/ddtrace/contrib/action_view/patcher.rb +5 -4
  94. data/lib/ddtrace/contrib/action_view/utils.rb +2 -1
  95. data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +1 -0
  96. data/lib/ddtrace/contrib/active_model_serializers/event.rb +3 -2
  97. data/lib/ddtrace/contrib/active_model_serializers/events.rb +1 -0
  98. data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +1 -0
  99. data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +1 -0
  100. data/lib/ddtrace/contrib/active_model_serializers/ext.rb +1 -0
  101. data/lib/ddtrace/contrib/active_model_serializers/integration.rb +1 -0
  102. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +1 -0
  103. data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +31 -0
  104. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +108 -18
  105. data/lib/ddtrace/contrib/active_record/configuration/settings.rb +1 -0
  106. data/lib/ddtrace/contrib/active_record/event.rb +3 -2
  107. data/lib/ddtrace/contrib/active_record/events.rb +1 -0
  108. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +1 -0
  109. data/lib/ddtrace/contrib/active_record/events/sql.rb +1 -0
  110. data/lib/ddtrace/contrib/active_record/ext.rb +1 -0
  111. data/lib/ddtrace/contrib/active_record/integration.rb +8 -0
  112. data/lib/ddtrace/contrib/active_record/patcher.rb +1 -0
  113. data/lib/ddtrace/contrib/active_record/utils.rb +69 -21
  114. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +105 -3
  115. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +26 -4
  116. data/lib/ddtrace/contrib/active_support/cache/redis.rb +2 -5
  117. data/lib/ddtrace/contrib/active_support/configuration/settings.rb +1 -0
  118. data/lib/ddtrace/contrib/active_support/ext.rb +4 -0
  119. data/lib/ddtrace/contrib/active_support/integration.rb +8 -1
  120. data/lib/ddtrace/contrib/active_support/notifications/event.rb +15 -3
  121. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +3 -1
  122. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +10 -5
  123. data/lib/ddtrace/contrib/active_support/patcher.rb +1 -0
  124. data/lib/ddtrace/contrib/analytics.rb +1 -0
  125. data/lib/ddtrace/contrib/auto_instrument.rb +49 -0
  126. data/lib/ddtrace/contrib/aws/configuration/settings.rb +1 -0
  127. data/lib/ddtrace/contrib/aws/ext.rb +1 -0
  128. data/lib/ddtrace/contrib/aws/instrumentation.rb +32 -1
  129. data/lib/ddtrace/contrib/aws/integration.rb +1 -0
  130. data/lib/ddtrace/contrib/aws/parsed_context.rb +1 -0
  131. data/lib/ddtrace/contrib/aws/patcher.rb +6 -1
  132. data/lib/ddtrace/contrib/aws/services.rb +4 -0
  133. data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +1 -0
  134. data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +1 -0
  135. data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +1 -0
  136. data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +1 -0
  137. data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +1 -0
  138. data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +3 -1
  139. data/lib/ddtrace/contrib/configurable.rb +65 -38
  140. data/lib/ddtrace/contrib/configuration/resolver.rb +71 -5
  141. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +21 -20
  142. data/lib/ddtrace/contrib/configuration/settings.rb +8 -6
  143. data/lib/ddtrace/contrib/dalli/configuration/settings.rb +1 -0
  144. data/lib/ddtrace/contrib/dalli/ext.rb +1 -0
  145. data/lib/ddtrace/contrib/dalli/instrumentation.rb +2 -1
  146. data/lib/ddtrace/contrib/dalli/integration.rb +1 -0
  147. data/lib/ddtrace/contrib/dalli/patcher.rb +2 -39
  148. data/lib/ddtrace/contrib/dalli/quantize.rb +1 -0
  149. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
  150. data/lib/ddtrace/contrib/delayed_job/ext.rb +1 -0
  151. data/lib/ddtrace/contrib/delayed_job/integration.rb +1 -0
  152. data/lib/ddtrace/contrib/delayed_job/patcher.rb +1 -0
  153. data/lib/ddtrace/contrib/delayed_job/plugin.rb +3 -1
  154. data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +1 -0
  155. data/lib/ddtrace/contrib/elasticsearch/ext.rb +1 -0
  156. data/lib/ddtrace/contrib/elasticsearch/integration.rb +1 -0
  157. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +2 -0
  158. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +6 -2
  159. data/lib/ddtrace/contrib/ethon/configuration/settings.rb +1 -0
  160. data/lib/ddtrace/contrib/ethon/easy_patch.rb +13 -11
  161. data/lib/ddtrace/contrib/ethon/ext.rb +2 -0
  162. data/lib/ddtrace/contrib/ethon/integration.rb +1 -0
  163. data/lib/ddtrace/contrib/ethon/multi_patch.rb +2 -1
  164. data/lib/ddtrace/contrib/ethon/patcher.rb +4 -2
  165. data/lib/ddtrace/contrib/excon/configuration/settings.rb +1 -0
  166. data/lib/ddtrace/contrib/excon/ext.rb +1 -0
  167. data/lib/ddtrace/contrib/excon/integration.rb +1 -0
  168. data/lib/ddtrace/contrib/excon/middleware.rb +10 -7
  169. data/lib/ddtrace/contrib/excon/patcher.rb +1 -0
  170. data/lib/ddtrace/contrib/extensions.rb +90 -14
  171. data/lib/ddtrace/contrib/faraday/configuration/settings.rb +1 -0
  172. data/lib/ddtrace/contrib/faraday/connection.rb +1 -0
  173. data/lib/ddtrace/contrib/faraday/ext.rb +1 -0
  174. data/lib/ddtrace/contrib/faraday/integration.rb +1 -0
  175. data/lib/ddtrace/contrib/faraday/middleware.rb +2 -3
  176. data/lib/ddtrace/contrib/faraday/patcher.rb +3 -38
  177. data/lib/ddtrace/contrib/faraday/rack_builder.rb +1 -0
  178. data/lib/ddtrace/contrib/grape/configuration/settings.rb +8 -0
  179. data/lib/ddtrace/contrib/grape/endpoint.rb +68 -32
  180. data/lib/ddtrace/contrib/grape/ext.rb +2 -0
  181. data/lib/ddtrace/contrib/grape/instrumentation.rb +4 -3
  182. data/lib/ddtrace/contrib/grape/integration.rb +1 -0
  183. data/lib/ddtrace/contrib/grape/patcher.rb +2 -43
  184. data/lib/ddtrace/contrib/graphql/configuration/settings.rb +1 -0
  185. data/lib/ddtrace/contrib/graphql/ext.rb +1 -0
  186. data/lib/ddtrace/contrib/graphql/integration.rb +1 -0
  187. data/lib/ddtrace/contrib/graphql/patcher.rb +1 -0
  188. data/lib/ddtrace/contrib/grpc/configuration/settings.rb +2 -0
  189. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +13 -8
  190. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +1 -0
  191. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -4
  192. data/lib/ddtrace/contrib/grpc/ext.rb +1 -0
  193. data/lib/ddtrace/contrib/grpc/integration.rb +1 -0
  194. data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +1 -0
  195. data/lib/ddtrace/contrib/grpc/patcher.rb +3 -37
  196. data/lib/ddtrace/contrib/http/circuit_breaker.rb +2 -3
  197. data/lib/ddtrace/contrib/http/configuration/settings.rb +1 -0
  198. data/lib/ddtrace/contrib/http/ext.rb +1 -0
  199. data/lib/ddtrace/contrib/http/instrumentation.rb +9 -8
  200. data/lib/ddtrace/contrib/http/integration.rb +1 -0
  201. data/lib/ddtrace/contrib/http/patcher.rb +2 -1
  202. data/lib/ddtrace/contrib/http_annotation_helper.rb +1 -0
  203. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +33 -0
  204. data/lib/ddtrace/contrib/httpclient/ext.rb +18 -0
  205. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +148 -0
  206. data/lib/ddtrace/contrib/httpclient/integration.rb +44 -0
  207. data/lib/ddtrace/contrib/httpclient/patcher.rb +39 -0
  208. data/lib/ddtrace/contrib/httprb/configuration/settings.rb +1 -0
  209. data/lib/ddtrace/contrib/httprb/ext.rb +1 -0
  210. data/lib/ddtrace/contrib/httprb/instrumentation.rb +17 -22
  211. data/lib/ddtrace/contrib/httprb/integration.rb +1 -0
  212. data/lib/ddtrace/contrib/httprb/patcher.rb +8 -4
  213. data/lib/ddtrace/contrib/integration.rb +4 -3
  214. data/lib/ddtrace/contrib/kafka/configuration/settings.rb +1 -0
  215. data/lib/ddtrace/contrib/kafka/consumer_event.rb +1 -0
  216. data/lib/ddtrace/contrib/kafka/consumer_group_event.rb +1 -0
  217. data/lib/ddtrace/contrib/kafka/event.rb +4 -3
  218. data/lib/ddtrace/contrib/kafka/events.rb +1 -0
  219. data/lib/ddtrace/contrib/kafka/events/connection/request.rb +1 -0
  220. data/lib/ddtrace/contrib/kafka/events/consumer/process_batch.rb +1 -0
  221. data/lib/ddtrace/contrib/kafka/events/consumer/process_message.rb +1 -0
  222. data/lib/ddtrace/contrib/kafka/events/consumer_group/heartbeat.rb +1 -0
  223. data/lib/ddtrace/contrib/kafka/events/consumer_group/join_group.rb +1 -0
  224. data/lib/ddtrace/contrib/kafka/events/consumer_group/leave_group.rb +1 -0
  225. data/lib/ddtrace/contrib/kafka/events/consumer_group/sync_group.rb +1 -0
  226. data/lib/ddtrace/contrib/kafka/events/produce_operation/send_messages.rb +1 -0
  227. data/lib/ddtrace/contrib/kafka/events/producer/deliver_messages.rb +1 -0
  228. data/lib/ddtrace/contrib/kafka/ext.rb +1 -0
  229. data/lib/ddtrace/contrib/kafka/integration.rb +1 -0
  230. data/lib/ddtrace/contrib/kafka/patcher.rb +1 -0
  231. data/lib/ddtrace/contrib/lograge/configuration/settings.rb +19 -0
  232. data/lib/ddtrace/contrib/lograge/ext.rb +11 -0
  233. data/lib/ddtrace/contrib/lograge/instrumentation.rb +39 -0
  234. data/lib/ddtrace/contrib/lograge/integration.rb +46 -0
  235. data/lib/ddtrace/contrib/lograge/patcher.rb +26 -0
  236. data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +1 -0
  237. data/lib/ddtrace/contrib/mongodb/ext.rb +1 -0
  238. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +5 -2
  239. data/lib/ddtrace/contrib/mongodb/integration.rb +1 -0
  240. data/lib/ddtrace/contrib/mongodb/parsers.rb +1 -0
  241. data/lib/ddtrace/contrib/mongodb/patcher.rb +3 -2
  242. data/lib/ddtrace/contrib/mongodb/subscribers.rb +3 -3
  243. data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +1 -0
  244. data/lib/ddtrace/contrib/mysql2/ext.rb +1 -0
  245. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +2 -1
  246. data/lib/ddtrace/contrib/mysql2/integration.rb +1 -0
  247. data/lib/ddtrace/contrib/mysql2/patcher.rb +2 -1
  248. data/lib/ddtrace/contrib/patchable.rb +21 -9
  249. data/lib/ddtrace/contrib/patcher.rb +12 -8
  250. data/lib/ddtrace/contrib/presto/configuration/settings.rb +1 -0
  251. data/lib/ddtrace/contrib/presto/ext.rb +1 -0
  252. data/lib/ddtrace/contrib/presto/instrumentation.rb +2 -1
  253. data/lib/ddtrace/contrib/presto/integration.rb +1 -0
  254. data/lib/ddtrace/contrib/presto/patcher.rb +7 -3
  255. data/lib/ddtrace/contrib/qless/configuration/settings.rb +36 -0
  256. data/lib/ddtrace/contrib/qless/ext.rb +21 -0
  257. data/lib/ddtrace/contrib/qless/integration.rb +39 -0
  258. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  259. data/lib/ddtrace/contrib/qless/qless_job.rb +74 -0
  260. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +34 -0
  261. data/lib/ddtrace/contrib/que/configuration/settings.rb +2 -0
  262. data/lib/ddtrace/contrib/que/ext.rb +20 -19
  263. data/lib/ddtrace/contrib/que/integration.rb +1 -0
  264. data/lib/ddtrace/contrib/que/patcher.rb +1 -0
  265. data/lib/ddtrace/contrib/que/tracer.rb +4 -2
  266. data/lib/ddtrace/contrib/racecar/configuration/settings.rb +1 -0
  267. data/lib/ddtrace/contrib/racecar/event.rb +4 -2
  268. data/lib/ddtrace/contrib/racecar/events.rb +1 -0
  269. data/lib/ddtrace/contrib/racecar/events/batch.rb +1 -0
  270. data/lib/ddtrace/contrib/racecar/events/consume.rb +1 -0
  271. data/lib/ddtrace/contrib/racecar/events/message.rb +1 -0
  272. data/lib/ddtrace/contrib/racecar/ext.rb +1 -0
  273. data/lib/ddtrace/contrib/racecar/integration.rb +1 -0
  274. data/lib/ddtrace/contrib/racecar/patcher.rb +1 -0
  275. data/lib/ddtrace/contrib/rack/configuration/settings.rb +4 -3
  276. data/lib/ddtrace/contrib/rack/ext.rb +1 -0
  277. data/lib/ddtrace/contrib/rack/integration.rb +8 -0
  278. data/lib/ddtrace/contrib/rack/middlewares.rb +8 -12
  279. data/lib/ddtrace/contrib/rack/patcher.rb +2 -3
  280. data/lib/ddtrace/contrib/rack/request_queue.rb +7 -1
  281. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +11 -0
  282. data/lib/ddtrace/contrib/rails/configuration/settings.rb +1 -0
  283. data/lib/ddtrace/contrib/rails/ext.rb +1 -0
  284. data/lib/ddtrace/contrib/rails/framework.rb +26 -1
  285. data/lib/ddtrace/contrib/rails/integration.rb +1 -0
  286. data/lib/ddtrace/contrib/rails/log_injection.rb +1 -40
  287. data/lib/ddtrace/contrib/rails/middlewares.rb +1 -0
  288. data/lib/ddtrace/contrib/rails/patcher.rb +22 -12
  289. data/lib/ddtrace/contrib/rails/railtie.rb +1 -0
  290. data/lib/ddtrace/contrib/rails/utils.rb +5 -0
  291. data/lib/ddtrace/contrib/rake/configuration/settings.rb +1 -0
  292. data/lib/ddtrace/contrib/rake/ext.rb +1 -0
  293. data/lib/ddtrace/contrib/rake/instrumentation.rb +6 -3
  294. data/lib/ddtrace/contrib/rake/integration.rb +2 -1
  295. data/lib/ddtrace/contrib/rake/patcher.rb +2 -1
  296. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +15 -5
  297. data/lib/ddtrace/contrib/redis/configuration/settings.rb +6 -0
  298. data/lib/ddtrace/contrib/redis/ext.rb +2 -0
  299. data/lib/ddtrace/contrib/redis/integration.rb +1 -0
  300. data/lib/ddtrace/contrib/redis/patcher.rb +21 -3
  301. data/lib/ddtrace/contrib/redis/quantize.rb +29 -0
  302. data/lib/ddtrace/contrib/redis/tags.rb +6 -1
  303. data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
  304. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +7 -7
  305. data/lib/ddtrace/contrib/registerable.rb +5 -4
  306. data/lib/ddtrace/contrib/registry.rb +3 -2
  307. data/lib/ddtrace/contrib/resque/configuration/settings.rb +19 -1
  308. data/lib/ddtrace/contrib/resque/ext.rb +1 -0
  309. data/lib/ddtrace/contrib/resque/integration.rb +2 -1
  310. data/lib/ddtrace/contrib/resque/patcher.rb +5 -4
  311. data/lib/ddtrace/contrib/resque/resque_job.rb +26 -2
  312. data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +1 -0
  313. data/lib/ddtrace/contrib/rest_client/ext.rb +1 -0
  314. data/lib/ddtrace/contrib/rest_client/integration.rb +1 -0
  315. data/lib/ddtrace/contrib/rest_client/patcher.rb +3 -1
  316. data/lib/ddtrace/contrib/rest_client/request_patch.rb +3 -4
  317. data/lib/ddtrace/contrib/semantic_logger/configuration/settings.rb +19 -0
  318. data/lib/ddtrace/contrib/semantic_logger/ext.rb +11 -0
  319. data/lib/ddtrace/contrib/semantic_logger/instrumentation.rb +43 -0
  320. data/lib/ddtrace/contrib/semantic_logger/integration.rb +48 -0
  321. data/lib/ddtrace/contrib/semantic_logger/patcher.rb +26 -0
  322. data/lib/ddtrace/contrib/sequel/configuration/settings.rb +1 -0
  323. data/lib/ddtrace/contrib/sequel/database.rb +2 -1
  324. data/lib/ddtrace/contrib/sequel/dataset.rb +2 -1
  325. data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
  326. data/lib/ddtrace/contrib/sequel/integration.rb +1 -0
  327. data/lib/ddtrace/contrib/sequel/patcher.rb +3 -2
  328. data/lib/ddtrace/contrib/sequel/utils.rb +6 -6
  329. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +3 -0
  330. data/lib/ddtrace/contrib/shoryuken/ext.rb +1 -0
  331. data/lib/ddtrace/contrib/shoryuken/integration.rb +1 -0
  332. data/lib/ddtrace/contrib/shoryuken/patcher.rb +1 -0
  333. data/lib/ddtrace/contrib/shoryuken/tracer.rb +9 -2
  334. data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +1 -0
  335. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +2 -0
  336. data/lib/ddtrace/contrib/sidekiq/ext.rb +1 -0
  337. data/lib/ddtrace/contrib/sidekiq/integration.rb +1 -0
  338. data/lib/ddtrace/contrib/sidekiq/patcher.rb +1 -0
  339. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +6 -7
  340. data/lib/ddtrace/contrib/sidekiq/tracing.rb +1 -1
  341. data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +1 -0
  342. data/lib/ddtrace/contrib/sinatra/env.rb +2 -3
  343. data/lib/ddtrace/contrib/sinatra/ext.rb +1 -0
  344. data/lib/ddtrace/contrib/sinatra/headers.rb +2 -3
  345. data/lib/ddtrace/contrib/sinatra/integration.rb +1 -0
  346. data/lib/ddtrace/contrib/sinatra/patcher.rb +3 -1
  347. data/lib/ddtrace/contrib/sinatra/tracer.rb +14 -6
  348. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +13 -6
  349. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +2 -0
  350. data/lib/ddtrace/contrib/sneakers/ext.rb +12 -11
  351. data/lib/ddtrace/contrib/sneakers/integration.rb +1 -0
  352. data/lib/ddtrace/contrib/sneakers/patcher.rb +1 -0
  353. data/lib/ddtrace/contrib/sneakers/tracer.rb +17 -21
  354. data/lib/ddtrace/contrib/status_code_matcher.rb +70 -0
  355. data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +1 -0
  356. data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +5 -6
  357. data/lib/ddtrace/contrib/sucker_punch/ext.rb +1 -0
  358. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +5 -0
  359. data/lib/ddtrace/contrib/sucker_punch/integration.rb +1 -0
  360. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +2 -0
  361. data/lib/ddtrace/correlation.rb +3 -1
  362. data/lib/ddtrace/diagnostics/environment_logger.rb +9 -7
  363. data/lib/ddtrace/diagnostics/health.rb +1 -0
  364. data/lib/ddtrace/distributed_tracing/headers/b3.rb +1 -0
  365. data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +1 -0
  366. data/lib/ddtrace/distributed_tracing/headers/datadog.rb +1 -0
  367. data/lib/ddtrace/distributed_tracing/headers/headers.rb +2 -0
  368. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +2 -3
  369. data/lib/ddtrace/encoding.rb +3 -0
  370. data/lib/ddtrace/error.rb +78 -8
  371. data/lib/ddtrace/event.rb +1 -0
  372. data/lib/ddtrace/ext/analytics.rb +1 -0
  373. data/lib/ddtrace/ext/app_types.rb +1 -0
  374. data/lib/ddtrace/ext/correlation.rb +1 -0
  375. data/lib/ddtrace/ext/diagnostics.rb +1 -0
  376. data/lib/ddtrace/ext/distributed.rb +9 -2
  377. data/lib/ddtrace/ext/environment.rb +8 -0
  378. data/lib/ddtrace/ext/errors.rb +1 -0
  379. data/lib/ddtrace/ext/forced_tracing.rb +1 -0
  380. data/lib/ddtrace/ext/git.rb +20 -0
  381. data/lib/ddtrace/ext/http.rb +2 -1
  382. data/lib/ddtrace/ext/integration.rb +1 -0
  383. data/lib/ddtrace/ext/manual_tracing.rb +1 -0
  384. data/lib/ddtrace/ext/metrics.rb +1 -0
  385. data/lib/ddtrace/ext/net.rb +1 -0
  386. data/lib/ddtrace/ext/priority.rb +1 -0
  387. data/lib/ddtrace/ext/profiling.rb +56 -0
  388. data/lib/ddtrace/ext/runtime.rb +2 -7
  389. data/lib/ddtrace/ext/sampling.rb +1 -0
  390. data/lib/ddtrace/ext/sql.rb +1 -0
  391. data/lib/ddtrace/ext/test.rb +9 -0
  392. data/lib/ddtrace/ext/transport.rb +3 -0
  393. data/lib/ddtrace/forced_tracing.rb +3 -0
  394. data/lib/ddtrace/logger.rb +2 -1
  395. data/lib/ddtrace/metrics.rb +84 -24
  396. data/lib/ddtrace/opentelemetry/extensions.rb +2 -1
  397. data/lib/ddtrace/opentelemetry/span.rb +1 -0
  398. data/lib/ddtrace/opentracer.rb +21 -39
  399. data/lib/ddtrace/opentracer/binary_propagator.rb +1 -0
  400. data/lib/ddtrace/opentracer/carrier.rb +1 -0
  401. data/lib/ddtrace/opentracer/distributed_headers.rb +4 -0
  402. data/lib/ddtrace/opentracer/global_tracer.rb +1 -0
  403. data/lib/ddtrace/opentracer/propagator.rb +1 -0
  404. data/lib/ddtrace/opentracer/rack_propagator.rb +1 -0
  405. data/lib/ddtrace/opentracer/scope.rb +1 -0
  406. data/lib/ddtrace/opentracer/scope_manager.rb +1 -0
  407. data/lib/ddtrace/opentracer/span.rb +3 -6
  408. data/lib/ddtrace/opentracer/span_context.rb +1 -0
  409. data/lib/ddtrace/opentracer/span_context_factory.rb +1 -0
  410. data/lib/ddtrace/opentracer/text_map_propagator.rb +1 -0
  411. data/lib/ddtrace/opentracer/thread_local_scope.rb +2 -0
  412. data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +1 -0
  413. data/lib/ddtrace/opentracer/tracer.rb +1 -0
  414. data/lib/ddtrace/patcher.rb +28 -6
  415. data/lib/ddtrace/pin.rb +9 -61
  416. data/lib/ddtrace/pipeline.rb +1 -0
  417. data/lib/ddtrace/pipeline/span_filter.rb +2 -1
  418. data/lib/ddtrace/pipeline/span_processor.rb +1 -0
  419. data/lib/ddtrace/profiling.rb +151 -0
  420. data/lib/ddtrace/profiling/backtrace_location.rb +33 -0
  421. data/lib/ddtrace/profiling/buffer.rb +42 -0
  422. data/lib/ddtrace/profiling/collectors/stack.rb +257 -0
  423. data/lib/ddtrace/profiling/encoding/profile.rb +38 -0
  424. data/lib/ddtrace/profiling/event.rb +14 -0
  425. data/lib/ddtrace/profiling/events/stack.rb +81 -0
  426. data/lib/ddtrace/profiling/exporter.rb +24 -0
  427. data/lib/ddtrace/profiling/ext/cpu.rb +67 -0
  428. data/lib/ddtrace/profiling/ext/cthread.rb +156 -0
  429. data/lib/ddtrace/profiling/ext/forking.rb +98 -0
  430. data/lib/ddtrace/profiling/flush.rb +44 -0
  431. data/lib/ddtrace/profiling/native_extension.rb +18 -0
  432. data/lib/ddtrace/profiling/pprof/builder.rb +120 -0
  433. data/lib/ddtrace/profiling/pprof/converter.rb +90 -0
  434. data/lib/ddtrace/profiling/pprof/message_set.rb +15 -0
  435. data/lib/ddtrace/profiling/pprof/payload.rb +19 -0
  436. data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
  437. data/lib/ddtrace/profiling/pprof/pprof_pb.rb +82 -0
  438. data/lib/ddtrace/profiling/pprof/stack_sample.rb +117 -0
  439. data/lib/ddtrace/profiling/pprof/string_table.rb +11 -0
  440. data/lib/ddtrace/profiling/pprof/template.rb +119 -0
  441. data/lib/ddtrace/profiling/preload.rb +4 -0
  442. data/lib/ddtrace/profiling/profiler.rb +31 -0
  443. data/lib/ddtrace/profiling/recorder.rb +96 -0
  444. data/lib/ddtrace/profiling/scheduler.rb +134 -0
  445. data/lib/ddtrace/profiling/tasks/setup.rb +82 -0
  446. data/lib/ddtrace/profiling/trace_identifiers/ddtrace.rb +41 -0
  447. data/lib/ddtrace/profiling/trace_identifiers/helper.rb +46 -0
  448. data/lib/ddtrace/profiling/transport/client.rb +15 -0
  449. data/lib/ddtrace/profiling/transport/http.rb +120 -0
  450. data/lib/ddtrace/profiling/transport/http/api.rb +44 -0
  451. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +101 -0
  452. data/lib/ddtrace/profiling/transport/http/api/instance.rb +37 -0
  453. data/lib/ddtrace/profiling/transport/http/api/spec.rb +41 -0
  454. data/lib/ddtrace/profiling/transport/http/builder.rb +29 -0
  455. data/lib/ddtrace/profiling/transport/http/client.rb +34 -0
  456. data/lib/ddtrace/profiling/transport/http/response.rb +22 -0
  457. data/lib/ddtrace/profiling/transport/io.rb +31 -0
  458. data/lib/ddtrace/profiling/transport/io/client.rb +28 -0
  459. data/lib/ddtrace/profiling/transport/io/response.rb +17 -0
  460. data/lib/ddtrace/profiling/transport/parcel.rb +18 -0
  461. data/lib/ddtrace/profiling/transport/request.rb +16 -0
  462. data/lib/ddtrace/profiling/transport/response.rb +9 -0
  463. data/lib/ddtrace/propagation/grpc_propagator.rb +2 -0
  464. data/lib/ddtrace/propagation/http_propagator.rb +18 -2
  465. data/lib/ddtrace/quantization/hash.rb +1 -0
  466. data/lib/ddtrace/quantization/http.rb +4 -0
  467. data/lib/ddtrace/runtime/metrics.rb +21 -14
  468. data/lib/ddtrace/sampler.rb +2 -1
  469. data/lib/ddtrace/sampling.rb +1 -0
  470. data/lib/ddtrace/sampling/matcher.rb +1 -0
  471. data/lib/ddtrace/sampling/rate_limiter.rb +66 -16
  472. data/lib/ddtrace/sampling/rule.rb +2 -1
  473. data/lib/ddtrace/sampling/rule_sampler.rb +6 -10
  474. data/lib/ddtrace/span.rb +44 -19
  475. data/lib/ddtrace/sync_writer.rb +17 -15
  476. data/lib/ddtrace/tasks/exec.rb +47 -0
  477. data/lib/ddtrace/tasks/help.rb +15 -0
  478. data/lib/ddtrace/tracer.rb +60 -49
  479. data/lib/ddtrace/transport/http.rb +51 -38
  480. data/lib/ddtrace/transport/http/adapters/net.rb +28 -8
  481. data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
  482. data/lib/ddtrace/transport/http/adapters/test.rb +1 -0
  483. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +3 -4
  484. data/lib/ddtrace/transport/http/api.rb +1 -0
  485. data/lib/ddtrace/transport/http/api/endpoint.rb +1 -0
  486. data/lib/ddtrace/transport/http/api/fallbacks.rb +1 -0
  487. data/lib/ddtrace/transport/http/api/instance.rb +1 -0
  488. data/lib/ddtrace/transport/http/api/map.rb +1 -0
  489. data/lib/ddtrace/transport/http/api/spec.rb +1 -0
  490. data/lib/ddtrace/transport/http/builder.rb +8 -1
  491. data/lib/ddtrace/transport/http/client.rb +3 -1
  492. data/lib/ddtrace/transport/http/env.rb +9 -0
  493. data/lib/ddtrace/transport/http/response.rb +1 -0
  494. data/lib/ddtrace/transport/http/statistics.rb +3 -2
  495. data/lib/ddtrace/transport/http/traces.rb +6 -6
  496. data/lib/ddtrace/transport/io.rb +2 -1
  497. data/lib/ddtrace/transport/io/client.rb +17 -9
  498. data/lib/ddtrace/transport/io/response.rb +2 -3
  499. data/lib/ddtrace/transport/io/traces.rb +10 -1
  500. data/lib/ddtrace/transport/parcel.rb +7 -0
  501. data/lib/ddtrace/transport/request.rb +1 -0
  502. data/lib/ddtrace/transport/response.rb +1 -0
  503. data/lib/ddtrace/transport/statistics.rb +1 -0
  504. data/lib/ddtrace/transport/traces.rb +21 -3
  505. data/lib/ddtrace/utils.rb +23 -12
  506. data/lib/ddtrace/utils/compression.rb +28 -0
  507. data/lib/ddtrace/utils/database.rb +1 -0
  508. data/lib/ddtrace/utils/forking.rb +53 -0
  509. data/lib/ddtrace/utils/object_set.rb +40 -0
  510. data/lib/ddtrace/utils/only_once.rb +41 -0
  511. data/lib/ddtrace/utils/sequence.rb +18 -0
  512. data/lib/ddtrace/utils/string_table.rb +46 -0
  513. data/lib/ddtrace/utils/time.rb +34 -2
  514. data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
  515. data/lib/ddtrace/vendor/active_record/connection_specification.rb +1 -0
  516. data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
  517. data/lib/ddtrace/vendor/multipart-post/multipart.rb +13 -0
  518. data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +9 -0
  519. data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +117 -0
  520. data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +58 -0
  521. data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +136 -0
  522. data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +10 -0
  523. data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +33 -0
  524. data/lib/ddtrace/version.rb +15 -2
  525. data/lib/ddtrace/worker.rb +1 -0
  526. data/lib/ddtrace/workers.rb +8 -2
  527. data/lib/ddtrace/workers/async.rb +15 -5
  528. data/lib/ddtrace/workers/loop.rb +32 -5
  529. data/lib/ddtrace/workers/polling.rb +13 -5
  530. data/lib/ddtrace/workers/queue.rb +3 -1
  531. data/lib/ddtrace/workers/runtime_metrics.rb +22 -4
  532. data/lib/ddtrace/workers/trace_writer.rb +14 -16
  533. data/lib/ddtrace/writer.rb +33 -8
  534. metadata +149 -402
  535. data/.circleci/config.yml +0 -548
  536. data/.circleci/images/primary/Dockerfile-2.0.0 +0 -73
  537. data/.circleci/images/primary/Dockerfile-2.1.10 +0 -73
  538. data/.circleci/images/primary/Dockerfile-2.2.10 +0 -73
  539. data/.circleci/images/primary/Dockerfile-2.3.8 +0 -75
  540. data/.circleci/images/primary/Dockerfile-2.4.6 +0 -73
  541. data/.circleci/images/primary/Dockerfile-2.5.6 +0 -73
  542. data/.circleci/images/primary/Dockerfile-2.6.4 +0 -73
  543. data/.circleci/images/primary/Dockerfile-2.7.0 +0 -73
  544. data/.circleci/images/primary/Dockerfile-jruby-9.2 +0 -77
  545. data/.dockerignore +0 -1
  546. data/.env +0 -26
  547. data/.github/CODEOWNERS +0 -1
  548. data/.gitlab-ci.yml +0 -27
  549. data/.rspec +0 -1
  550. data/.rubocop.yml +0 -85
  551. data/.simplecov +0 -38
  552. data/Appraisals +0 -1121
  553. data/Gemfile +0 -7
  554. data/Rakefile +0 -788
  555. data/benchmarks/postgres_database.yml +0 -9
  556. data/benchmarks/sidekiq_test.rb +0 -154
  557. data/docker-compose.yml +0 -370
  558. data/lib/ddtrace/augmentation.rb +0 -13
  559. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  560. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  561. data/lib/ddtrace/augmentation/shim.rb +0 -102
  562. data/lib/ddtrace/environment.rb +0 -41
  563. data/lib/ddtrace/monkey.rb +0 -58
  564. data/lib/ddtrace/runtime/cgroup.rb +0 -44
  565. data/lib/ddtrace/runtime/class_count.rb +0 -17
  566. data/lib/ddtrace/runtime/container.rb +0 -73
  567. data/lib/ddtrace/runtime/gc.rb +0 -16
  568. data/lib/ddtrace/runtime/identity.rb +0 -41
  569. data/lib/ddtrace/runtime/object_space.rb +0 -19
  570. data/lib/ddtrace/runtime/socket.rb +0 -14
  571. data/lib/ddtrace/runtime/thread_count.rb +0 -16
  572. data/tasks/release_gem.rake +0 -28
data/CONTRIBUTING.md CHANGED
@@ -20,8 +20,6 @@ Additionally, if you can, include:
20
20
  - Links to similar features that would serve as a good comparison
21
21
  - (Any other details that would be useful for implementing this feature!)
22
22
 
23
- Feature requests will be reviewed, discussed, and then added to [our Community project](https://github.com/DataDog/dd-trace-rb/projects/2).
24
-
25
23
  ## Found a bug?
26
24
 
27
25
  For any urgent matters (such as outages) or issues concerning the Datadog service or UI, contact our support team via https://docs.datadoghq.com/help/ for direct, faster assistance.
@@ -46,7 +44,7 @@ If at all possible, also provide:
46
44
  - Code sample or test that reproduces the problem
47
45
  - An explanation of what causes the bug and/or how it can be fixed
48
46
 
49
- Reports that include rich detail are better, and ones with code that reproduce the bug are best. Bug requests are triaged, reviewed, and added to [our Community project](https://github.com/DataDog/dd-trace-rb/projects/2).
47
+ Reports that include rich detail are better, and ones with code that reproduce the bug are best.
50
48
 
51
49
  ## Have a patch?
52
50
 
@@ -74,9 +72,7 @@ We also recommend that you share in your description:
74
72
  - Benchmarks if the feature is anticipated to have performance implications
75
73
  - Any limitations, constraints or risks that are important to consider
76
74
 
77
- Pull requests will be reviewed and added to [our Community project](https://github.com/DataDog/dd-trace-rb/projects/2).
78
-
79
- For more information on common topics such as debugging locally, or how to write new integrations, check out [our development guide](https://github.com/DataDog/dd-trace-rb/docs/DevelopmentGuide.md). If at any point you have a question or need assistance with your pull request, feel free to mention a project member! We're always happy to help contributors with their pull requests.
75
+ For more information on common topics such as debugging locally, or how to write new integrations, check out [our development guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md). If at any point you have a question or need assistance with your pull request, feel free to mention a project member! We're always happy to help contributors with their pull requests.
80
76
 
81
77
  ## Final word
82
78
 
@@ -0,0 +1,2 @@
1
+ Component,Origin,License,Copyright
2
+ ddtrace/vendor/multipart-post,https://github.com/socketry/multipart-post,MIT,"Copyright (c) 2007-2013 Nick Sieger."
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Datadog Trace Client
2
2
 
3
3
  [![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)
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)
4
5
 
5
6
  ``ddtrace`` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
6
7
  databases and microservices so that developers have great visiblity into bottlenecks and troublesome requests.
data/bin/ddtracerb ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require 'ddtrace/tasks/exec'
3
+ require 'ddtrace/tasks/help'
4
+
5
+ command = ARGV.shift
6
+
7
+ case command
8
+ when 'exec'
9
+ Datadog::Tasks::Exec.new(ARGV).run
10
+ when 'help', '--help'
11
+ Datadog::Tasks::Help.new.run
12
+ else
13
+ puts "Command '#{command}' is not valid for ddtrace."
14
+ Datadog::Tasks::Help.new.run
15
+ end
data/ddtrace.gemspec CHANGED
@@ -7,7 +7,7 @@ require 'ddtrace/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'ddtrace'
9
9
  spec.version = Datadog::VERSION::STRING
10
- spec.required_ruby_version = ">= #{Datadog::VERSION::MINIMUM_RUBY_VERSION}"
10
+ spec.required_ruby_version = [">= #{Datadog::VERSION::MINIMUM_RUBY_VERSION}", "< #{Datadog::VERSION::MAXIMUM_RUBY_VERSION}"]
11
11
  spec.required_rubygems_version = '>= 2.0.0'
12
12
  spec.authors = ['Datadog, Inc.']
13
13
  spec.email = ['dev@datadoghq.com']
@@ -28,47 +28,26 @@ Gem::Specification.new do |spec|
28
28
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
29
29
  end
30
30
 
31
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
- spec.bindir = 'exe'
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.files =
32
+ `git ls-files -z`
33
+ .split("\x0")
34
+ .reject { |f| f.match(%r{^(test|spec|features|[.]circleci|[.]github|[.]dd-ci|benchmarks|gemfiles|integration|tasks|sorbet)/}) }
35
+ .reject do |f|
36
+ ['.dockerignore', '.env', '.gitattributes', '.gitlab-ci.yml', '.rspec', '.rubocop.yml',
37
+ '.rubocop_todo.yml', '.simplecov', 'Appraisals', 'Gemfile', 'Rakefile', 'docker-compose.yml'].include?(f)
38
+ end
39
+ spec.executables = ['ddtracerb']
34
40
  spec.require_paths = ['lib']
35
41
 
36
- spec.add_dependency 'msgpack'
37
-
38
- # Optional extensions
39
- # TODO: Move this to Appraisals?
40
- spec.add_development_dependency 'dogstatsd-ruby', '>= 3.3.0'
41
- spec.add_development_dependency 'opentracing', '>= 0.4.1'
42
-
43
- # Development dependencies
44
- spec.add_development_dependency 'concurrent-ruby' # Leave it open as we also have it as an integration and want Appraisal to control the version under test.
45
- spec.add_development_dependency 'rake', '>= 10.5'
46
- spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
47
- spec.add_development_dependency 'rspec', '~> 3.0'
48
- spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
49
- spec.add_development_dependency 'ruby-prof', '~> 1.4' if RUBY_PLATFORM != 'java' && RUBY_VERSION >= '2.4.0'
50
- spec.add_development_dependency 'minitest', '= 5.10.1'
51
- spec.add_development_dependency 'minitest-around', '0.5.0'
52
- spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
53
- spec.add_development_dependency 'appraisal', '~> 2.2'
54
- spec.add_development_dependency 'yard', '~> 0.9'
55
- spec.add_development_dependency 'webmock', '~> 2.0'
56
- spec.add_development_dependency 'builder'
57
- if RUBY_PLATFORM != 'java'
58
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
42
+ if RUBY_VERSION >= '2.2.0'
43
+ spec.add_dependency 'msgpack'
59
44
  else
60
- spec.add_development_dependency 'jdbc-sqlite3', '~> 3'
45
+ # msgpack 1.4 fails for Ruby 2.1: https://github.com/msgpack/msgpack-ruby/issues/205
46
+ spec.add_dependency 'msgpack', '< 1.4'
61
47
  end
62
- spec.add_development_dependency 'climate_control', '~> 0.2.0'
63
48
 
64
- # locking transitive dependency of webmock
65
- spec.add_development_dependency 'addressable', '~> 2.4.0'
66
- spec.add_development_dependency 'benchmark-ips', '~> 2.8'
67
- spec.add_development_dependency 'benchmark-memory', '~> 0.1'
68
- spec.add_development_dependency 'memory_profiler', '~> 0.9'
69
- spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
70
- spec.add_development_dependency 'pry', '~> 0.10.4'
71
- spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
72
- spec.add_development_dependency 'simplecov', '~> 0.17'
73
- spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
49
+ # Used by the profiler
50
+ spec.add_dependency 'ffi', '~> 1.0'
51
+
52
+ spec.extensions = ['ext/ddtrace_profiling_native_extension/extconf.rb']
74
53
  end
@@ -9,6 +9,8 @@ This guide covers some of the common how-tos and technical reference material fo
9
9
  - [Writing tests](#writing-tests)
10
10
  - [Running tests](#running-tests)
11
11
  - [Checking code quality](#checking-code-quality)
12
+ - [Running benchmarks](#running-benchmarks)
13
+ - [Type checking](#type-checking)
12
14
  - [Appendix](#appendix)
13
15
  - [Writing new integrations](#writing-new-integrations)
14
16
  - [Custom transport adapters](#custom-transport-adapters)
@@ -114,6 +116,34 @@ Because you are likely not running all tests locally, your report will contain p
114
116
  You *must* check the CI step `coverage` for the complete test coverage report, ensuring coverage is not
115
117
  decreased.
116
118
 
119
+ **Ensuring tests don't leak resources**
120
+
121
+ Tests execution can create resources that are hard to track: threads, sockets, files, etc. Because these resources can come
122
+ from the both the test setup as well as the code under test, making sure all resources are properly disposed is important
123
+ to prevent the application from inadvertently creating cumulative resources during its execution.
124
+
125
+ When running tests that utilize threads, you might see an error message similar to this one:
126
+
127
+ ```
128
+ Test leaked 1 thread: "Datadog::Workers::AsyncTransport integration tests"
129
+ Ensure all threads are terminated when test finishes:
130
+ 1: #<Thread:0x00007fcbc99863d0 /Users/marco.costa/work/dd-trace-rb/spec/spec_helper.rb:145 sleep> (Thread)
131
+ Thread Creation Site:
132
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'new'
133
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'block (4 levels) in <top (required)>'
134
+ Thread Backtrace:
135
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'sleep'
136
+ .dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'block (5 levels) in <top (required)>'
137
+ ./dd-trace-rb/spec/spec_helper.rb:147:in 'block in initialize'
138
+ ```
139
+
140
+ This means that this test did not finish all threads by the time the test had finished. In this case, the thread
141
+ creation can be traced to `workers_integration_spec.rb:245:in 'new'`. The thread itself is sleeping at `workers_integration_spec.rb:262:in 'sleep'`.
142
+
143
+ The actionable in this case would be to ensure that the thread created in `workers_integration_spec.rb:245` is properly terminated by invoking `Thread#join` during the test tear down, which will wait for the thread to finish before returning.
144
+
145
+ Depending on the situation, the thread in question might need to be forced to terminate. It's recommended to have a mechanism in place to terminate it (a shared variable that changes value when the thread should exit), but as a last resort, `Thread#terminate` forces the thread to finish. Keep in mind that regardless of the termination method, `Thread#join` must be called to ensure that the thread has completely finished its shutdown process.
146
+
117
147
  ### Checking code quality
118
148
 
119
149
  **Linting**
@@ -134,6 +164,19 @@ $ bundle exec rake spec:benchmark
134
164
 
135
165
  Results are printed to STDOUT as well as written to the `./tmp/benchmark/` directory.
136
166
 
167
+ ## Type checking
168
+
169
+ This library uses the [Sorbet](https://sorbet.org/) type checker. Sorbet can be run with `bundle exec srb tc` (or `bundle exec rake
170
+ typecheck`). There's also Language Server Protocol support, if your editor supports it.
171
+
172
+ Type checking can be controlled on a file-by-file manner, using a `# typed: ...` comment. The default (when none is provided) is assuming `# typed: false`.
173
+
174
+ Things to note:
175
+
176
+ * For compatibility with older Rubies, we use Sorbet but do not yet allow type annotations in the codebase. If Sorbet is blocking you, feel free to use `# typed: false` or `# typed: ignore` with a quick note on why this was needed. In many cases, Sorbet can typecheck a file correctly with no extra type annotations.
177
+
178
+ * Most integration-specific code will reference optional external dependencies which Sorbet cannot see into. You'll probably need to use `# typed: false` or `# typed: ignore` for those files as well.
179
+
137
180
  ## Appendix
138
181
 
139
182
  ### Writing new integrations
@@ -151,9 +194,9 @@ To get started quickly, it's perfectly fine to copy-paste an existing integratio
151
194
 
152
195
  Once you have it working in your application, you can [add unit tests](#writing-tests), [run them locally](#running-tests), and [check for code quality](#checking-code-quality) using Docker Compose.
153
196
 
154
- Then [open a pull request](https://github.com/DataDog/dd-trace-rb/CONTRIBUTING.md#have-a-patch) and be sure to add the following to the description:
197
+ Then [open a pull request](../CONTRIBUTING.md#have-a-patch) and be sure to add the following to the description:
155
198
 
156
- - [Documentation](https://github.com/DataDog/dd-trace-rb/docs/GettingStarted.md) for the integration, including versions supported.
199
+ - [Documentation](./GettingStarted.md) for the integration, including versions supported.
157
200
  - Links to the repository/website of the library being integrated
158
201
  - Screenshots showing a sample trace
159
202
  - Any additional code snippets, sample apps, benchmarks, or other resources that demonstrate its implementation are a huge plus!
@@ -34,6 +34,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
34
34
  - [Active Support](#active-support)
35
35
  - [AWS](#aws)
36
36
  - [Concurrent Ruby](#concurrent-ruby)
37
+ - [Cucumber](#cucumber)
37
38
  - [Dalli](#dalli)
38
39
  - [DelayedJob](#delayedjob)
39
40
  - [Elasticsearch](#elasticsearch)
@@ -44,10 +45,13 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
44
45
  - [GraphQL](#graphql)
45
46
  - [gRPC](#grpc)
46
47
  - [http.rb](#http-rb)
48
+ - [httpclient](#httpclient)
49
+ - [httpx](#httpx)
47
50
  - [MongoDB](#mongodb)
48
51
  - [MySQL2](#mysql2)
49
52
  - [Net/HTTP](#net-http)
50
53
  - [Presto](#presto)
54
+ - [Qless](#qless)
51
55
  - [Que](#que)
52
56
  - [Racecar](#racecar)
53
57
  - [Rack](#rack)
@@ -56,6 +60,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
56
60
  - [Redis](#redis)
57
61
  - [Rest Client](#rest-client)
58
62
  - [Resque](#resque)
63
+ - [RSpec](#rspec)
59
64
  - [Shoryuken](#shoryuken)
60
65
  - [Sequel](#sequel)
61
66
  - [Sidekiq](#sidekiq)
@@ -66,7 +71,9 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
66
71
  - [Tracer settings](#tracer-settings)
67
72
  - [Custom logging](#custom-logging)
68
73
  - [Environment and tags](#environment-and-tags)
74
+ - [Environment variables](#environment-variables)
69
75
  - [Sampling](#sampling)
76
+ - [Application-side sampling](#application-side-sampling)
70
77
  - [Priority sampling](#priority-sampling)
71
78
  - [Distributed tracing](#distributed-tracing)
72
79
  - [HTTP request queuing](#http-request-queuing)
@@ -78,6 +85,12 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
78
85
  - [Metrics](#metrics)
79
86
  - [For application runtime](#for-application-runtime)
80
87
  - [OpenTracing](#opentracing)
88
+ - [Profiling](#profiling)
89
+ - [Troubleshooting](#troubleshooting)
90
+ - [Profiling Resque jobs](#profiling-resque-jobs)
91
+ - [Known issues and suggested configurations](#known-issues-and-suggested-configurations)
92
+ - [Payload too large](#payload-too-large)
93
+ - [Stack level too deep](#stack-level-too-deep)
81
94
 
82
95
  ## Compatibility
83
96
 
@@ -85,14 +98,15 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
85
98
 
86
99
  | Type | Documentation | Version | Support type | Gem version support |
87
100
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
88
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
101
+ | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
102
+ | | | 2.7 | Full | Latest |
89
103
  | | | 2.6 | Full | Latest |
90
104
  | | | 2.5 | Full | Latest |
91
105
  | | | 2.4 | Full | Latest |
92
106
  | | | 2.3 | Full | Latest |
93
107
  | | | 2.2 | Full | Latest |
94
108
  | | | 2.1 | Full | Latest |
95
- | | | 2.0 | Full | Latest |
109
+ | | | 2.0 | EOL since June 7th, 2021 | < 0.50.0 |
96
110
  | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
97
111
  | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
98
112
  | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
@@ -123,14 +137,38 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
123
137
 
124
138
  The following steps will help you quickly start tracing your Ruby application.
125
139
 
126
- ### Setup the Datadog Agent
140
+ ### Configure the Datadog Agent for APM
127
141
 
128
142
  Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
129
143
 
130
- [Install and configure the Datadog Agent](https://docs.datadoghq.com/tracing/setup), see additional documentation for [tracing Docker applications](https://docs.datadoghq.com/tracing/setup/docker/).
144
+ Install and configure the Datadog Agent to receive traces from your now instrumented application. By default the Datadog Agent is enabled in your `datadog.yaml` file under `apm_enabled: true` and listens for trace traffic at `localhost:8126`. For containerized environments, follow the steps below to enable trace collection within the Datadog Agent.
145
+
146
+ #### Containers
147
+
148
+ 1. Set `apm_non_local_traffic: true` in your main [`datadog.yaml` configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/#agent-main-configuration-file).
149
+
150
+ 2. See the specific setup instructions for [Docker](https://docs.datadoghq.com/agent/docker/apm/?tab=ruby), [Kubernetes](https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm), [Amazon ECS](https://docs.datadoghq.com/agent/amazon_ecs/apm/?tab=ruby) or [Fargate](https://docs.datadoghq.com/integrations/ecs_fargate/#trace-collection) to ensure that the Agent is configured to receive traces in a containerized environment:
151
+
152
+ 3. After having instrumented your application, the tracing client sends traces to `localhost:8126` by default. If this is not the correct host and port change it by setting the env variables `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
153
+
131
154
 
132
155
  ### Quickstart for Rails applications
133
156
 
157
+ #### Automatic instrumentation
158
+
159
+ 1. Add the `ddtrace` gem to your Gemfile:
160
+
161
+ ```ruby
162
+ source 'https://rubygems.org'
163
+ gem 'ddtrace', require: 'ddtrace/auto_instrument'
164
+ ```
165
+
166
+ 2. Install the gem with `bundle install`
167
+
168
+ 3. You can configure, override, or disable any specific integration settings by also adding a [Rails Manual Configuration](#rails-manual-configuration) file.
169
+
170
+ #### Manual instrumentation
171
+
134
172
  1. Add the `ddtrace` gem to your Gemfile:
135
173
 
136
174
  ```ruby
@@ -152,6 +190,25 @@ Before downloading tracing on your application, install the Datadog Agent. The R
152
190
 
153
191
  ### Quickstart for Ruby applications
154
192
 
193
+ #### Automatic instrumentation
194
+
195
+ 1. Install the gem with `gem install ddtrace`
196
+ 2. Requiring any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
197
+ 3. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
198
+
199
+ ```ruby
200
+ # Example frameworks and libraries
201
+ require 'sinatra'
202
+ require 'faraday'
203
+ require 'redis'
204
+
205
+ require 'ddtrace/auto_instrument'
206
+ ```
207
+
208
+ You can configure, override, or disable any specific integration settings by also adding a [Ruby Manual Configuration Block](#ruby-manual-configuration).
209
+
210
+ #### Manual instrumentation
211
+
155
212
  1. Install the gem with `gem install ddtrace`
156
213
  2. Add a configuration block to your Ruby application:
157
214
 
@@ -226,7 +283,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
226
283
  | `resource` | `String` | Name of the resource or action being operated on. Traces with the same resource value will be grouped together for the purpose of metrics (but still independently viewable.) Usually domain specific, such as a URL, query, request, etc. (e.g. `'Article#submit'`, `http://example.com/articles/list`.) | `name` of Span. |
227
284
  | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
228
285
  | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
229
- | `start_time` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
286
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
230
287
  | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
231
288
  | `on_error` | `Proc` | Handler invoked when a block is provided to trace, and it raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
232
289
 
@@ -338,6 +395,7 @@ For a list of available integrations, and their configuration options, please re
338
395
  | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
339
396
  | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
340
397
  | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
398
+ | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
341
399
  | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
342
400
  | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
343
401
  | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
@@ -348,11 +406,15 @@ For a list of available integrations, and their configuration options, please re
348
406
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
349
407
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
350
408
  | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
409
+ | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
410
+ | httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
351
411
  | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
412
+ | Makara (through Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
352
413
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
353
414
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
354
415
  | Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
355
416
  | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
417
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
356
418
  | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
357
419
  | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
358
420
  | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
@@ -361,6 +423,7 @@ For a list of available integrations, and their configuration options, please re
361
423
  | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
362
424
  | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
363
425
  | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
426
+ | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
364
427
  | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
365
428
  | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
366
429
  | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
@@ -386,7 +449,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
386
449
 
387
450
  | Key | Description | Default |
388
451
  | --- | ----------- | ------- |
389
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
390
452
  | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
391
453
 
392
454
  ### Action View
@@ -406,7 +468,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
406
468
 
407
469
  | Key | Description | Default |
408
470
  | ---| --- | --- |
409
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
410
471
  | `service_name` | Service name used for rendering instrumentation. | `action_view` |
411
472
  | `template_base_path` | Used when the template name is parsed. If you don't store your templates in the `views/` folder, you may need to change this value | `'views/'` |
412
473
 
@@ -428,7 +489,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
428
489
 
429
490
  | Key | Description | Default |
430
491
  | --- | ----------- | ------- |
431
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
432
492
  | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
433
493
 
434
494
  ### Action Pack
@@ -448,7 +508,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
448
508
 
449
509
  | Key | Description | Default |
450
510
  | ---| --- | --- |
451
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
452
511
  | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
453
512
 
454
513
  ### Active Record
@@ -476,7 +535,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
476
535
 
477
536
  | Key | Description | Default |
478
537
  | ---| --- | --- |
479
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
480
538
  | `orm_service_name` | Service name used for the mapping portion of query results to ActiveRecord objects. Inherits service name from parent by default. | _parent.service_name_ (e.g. `'mysql2'`) |
481
539
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
482
540
 
@@ -495,16 +553,19 @@ Datadog.configure do |c|
495
553
  # Only available if you are using Rails with ActiveRecord.
496
554
  c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
497
555
 
556
+ # Block configuration pattern.
498
557
  c.use :active_record, describes: :secondary_database do |second_db|
499
558
  second_db.service_name = 'secondary-db'
500
559
  end
501
560
 
502
561
  # Connection string with the following connection settings:
503
- # Adapter, user, host, port, database
562
+ # adapter, username, host, port, database
563
+ # Other fields are ignored.
504
564
  c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
505
565
 
506
- # Hash with following connection settings
507
- # Adapter, user, host, port, database
566
+ # Hash with following connection settings:
567
+ # adapter, username, host, port, database
568
+ # Other fields are ignored.
508
569
  c.use :active_record, describes: {
509
570
  adapter: 'mysql2',
510
571
  host: '127.0.0.1',
@@ -513,9 +574,34 @@ Datadog.configure do |c|
513
574
  username: 'root'
514
575
  },
515
576
  service_name: 'secondary-db'
577
+
578
+ # If using the `makara` gem, it's possible to match on connection `role`:
579
+ c.use :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
580
+ c.use :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
581
+ end
582
+ ```
583
+
584
+ You can also create configurations based on partial matching of database connection fields:
585
+
586
+ ```ruby
587
+ Datadog.configure do |c|
588
+ # Matches any connection on host `127.0.0.1`.
589
+ c.use :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
590
+
591
+ # Matches any `mysql2` connection.
592
+ c.use :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
593
+
594
+ # Matches any `mysql2` connection to the `reports` database.
595
+ #
596
+ # In case of multiple matching `describe` configurations, the latest one applies.
597
+ # In this case a connection with both adapter `mysql` and database `reports`
598
+ # will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
599
+ c.use :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
516
600
  end
517
601
  ```
518
602
 
603
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
604
+
519
605
  If ActiveRecord traces an event that uses a connection that matches a key defined by `describes`, it will use the trace settings assigned to that connection. If the connection does not match any of the described connections, it will use default settings defined by `c.use :active_record` instead.
520
606
 
521
607
  ### Active Support
@@ -538,7 +624,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
538
624
 
539
625
  | Key | Description | Default |
540
626
  | ---| --- | --- |
541
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
542
627
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
543
628
 
544
629
  ### AWS
@@ -561,7 +646,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
561
646
 
562
647
  | Key | Description | Default |
563
648
  | --- | ----------- | ------- |
564
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
565
649
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
566
650
 
567
651
  ### Concurrent Ruby
@@ -590,6 +674,41 @@ Where `options` is an optional `Hash` that accepts the following parameters:
590
674
  | --- | ----------- | ------- |
591
675
  | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
592
676
 
677
+ ### Cucumber
678
+
679
+ Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
680
+
681
+ To activate your integration, use the `Datadog.configure` method:
682
+
683
+ ```ruby
684
+ require 'cucumber'
685
+ require 'ddtrace'
686
+
687
+ # Configure default Cucumber integration
688
+ Datadog.configure do |c|
689
+ c.use :cucumber, options
690
+ end
691
+
692
+ # Example of how to attach tags from scenario to active span
693
+ Around do |scenario, block|
694
+ active_span = Datadog.configuration[:cucumber][:tracer].active_span
695
+ unless active_span.nil?
696
+ scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
697
+ active_span.set_tag(*tag.name.split(':', 2))
698
+ end
699
+ end
700
+ block.call
701
+ end
702
+ ```
703
+
704
+ Where `options` is an optional `Hash` that accepts the following parameters:
705
+
706
+ | Key | Description | Default |
707
+ | --- | ----------- | ------- |
708
+ | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
709
+ | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
710
+ | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
711
+
593
712
  ### Dalli
594
713
 
595
714
  Dalli integration will trace all calls to your `memcached` server:
@@ -612,7 +731,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
612
731
 
613
732
  | Key | Description | Default |
614
733
  | --- | ----------- | ------- |
615
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
616
734
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
617
735
 
618
736
  ### DelayedJob
@@ -633,9 +751,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
633
751
 
634
752
  | Key | Description | Default |
635
753
  | --- | ----------- | ------- |
636
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
637
754
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
638
755
  | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
756
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
639
757
 
640
758
  ### Elasticsearch
641
759
 
@@ -658,7 +776,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
658
776
 
659
777
  | Key | Description | Default |
660
778
  | --- | ----------- | ------- |
661
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
662
779
  | `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{}` |
663
780
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
664
781
 
@@ -684,7 +801,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
684
801
 
685
802
  | Key | Description | Default |
686
803
  | --- | ----------- | ------- |
687
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
688
804
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
689
805
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
690
806
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -716,7 +832,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
716
832
 
717
833
  | Key | Description | Default |
718
834
  | --- | ----------- | ------- |
719
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
720
835
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
721
836
  | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
722
837
  | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
@@ -779,7 +894,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
779
894
 
780
895
  | Key | Description | Default |
781
896
  | --- | ----------- | ------- |
782
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
783
897
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
784
898
  | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
785
899
  | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
@@ -813,9 +927,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
813
927
 
814
928
  | Key | Description | Default |
815
929
  | --- | ----------- | ------- |
816
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
817
930
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
818
931
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
932
+ | `error_statuses`| Defines a status code or range of status codes which should be marked as errors. `'404,405,500-599'` or `[404,405,'500-599']` | `nil` |
819
933
 
820
934
  ### GraphQL
821
935
 
@@ -837,7 +951,6 @@ The `use :graphql` method accepts the following parameters. Additional options c
837
951
 
838
952
  | Key | Description | Default |
839
953
  | --- | ----------- | ------- |
840
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
841
954
  | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
842
955
  | `schemas` | Required. Array of `GraphQL::Schema` objects which to trace. Tracing will be added to all the schemas listed, using the options provided to this configuration. If you do not provide any, then tracing will not be activated. | `[]` |
843
956
 
@@ -916,8 +1029,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
916
1029
 
917
1030
  | Key | Description | Default |
918
1031
  | --- | ----------- | ------- |
919
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
920
1032
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
1033
+ | `error_handler` | Custom error handler invoked when a request is an error. A `Proc` that accepts `span` and `error` parameters. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
921
1034
 
922
1035
  **Configuring clients to use different settings**
923
1036
 
@@ -958,11 +1071,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
958
1071
 
959
1072
  | Key | Description | Default |
960
1073
  | --- | ----------- | ------- |
961
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
962
1074
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
963
1075
  | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
964
1076
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
965
1077
 
1078
+ ### httpclient
1079
+
1080
+ The httpclient integration will trace any HTTP call using the httpclient gem.
1081
+
1082
+ ```ruby
1083
+ require 'httpclient'
1084
+ require 'ddtrace'
1085
+ Datadog.configure do |c|
1086
+ c.use :httpclient, options
1087
+ # optionally, specify a different service name for hostnames matching a regex
1088
+ c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1089
+ httpclient.service_name = 'user.example.com'
1090
+ httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1091
+ end
1092
+ end
1093
+ ```
1094
+
1095
+ Where `options` is an optional `Hash` that accepts the following parameters:
1096
+
1097
+ | Key | Description | Default |
1098
+ | --- | ----------- | ------- |
1099
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1100
+ | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1101
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1102
+
1103
+ ### httpx
1104
+
1105
+ `httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
1106
+
1107
+ ```ruby
1108
+ require "ddtrace"
1109
+ require "httpx/adapters/datadog"
1110
+
1111
+ Datadog.configure do |c|
1112
+ c.use :httpx
1113
+
1114
+ # optionally, specify a different service name for hostnames matching a regex
1115
+ c.use :httpx, describes: /user-[^.]+\.example\.com/ do |http|
1116
+ http.service_name = 'user.example.com'
1117
+ http.split_by_domain = false # Only necessary if split_by_domain is true by default
1118
+ end
1119
+ end
1120
+ ```
1121
+
966
1122
  ### Kafka
967
1123
 
968
1124
  The Kafka integration provides tracing of the `ruby-kafka` gem:
@@ -983,7 +1139,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
983
1139
 
984
1140
  | Key | Description | Default |
985
1141
  | --- | ----------- | ------- |
986
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
987
1142
  | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
988
1143
  | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
989
1144
 
@@ -1012,7 +1167,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1012
1167
 
1013
1168
  | Key | Description | Default |
1014
1169
  | --- | ----------- | ------- |
1015
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1016
1170
  | `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{ show: [:collection, :database, :operation] }` |
1017
1171
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
1018
1172
 
@@ -1036,7 +1190,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1036
1190
 
1037
1191
  | Key | Description | Default |
1038
1192
  | --- | ----------- | ------- |
1039
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1040
1193
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1041
1194
 
1042
1195
  ### Net/HTTP
@@ -1069,7 +1222,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1069
1222
 
1070
1223
  | Key | Description | Default |
1071
1224
  | --- | ----------- | ------- |
1072
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1073
1225
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1074
1226
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1075
1227
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -1110,9 +1262,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1110
1262
 
1111
1263
  | Key | Description | Default |
1112
1264
  | --- | ----------- | ------- |
1113
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1114
1265
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1115
1266
 
1267
+ ### Qless
1268
+
1269
+ The Qless integration uses lifecycle hooks to trace job executions.
1270
+
1271
+ To add tracing to a Qless job:
1272
+
1273
+ ```ruby
1274
+ require 'ddtrace'
1275
+
1276
+ Datadog.configure do |c|
1277
+ c.use :qless, options
1278
+ end
1279
+ ```
1280
+
1281
+ Where `options` is an optional `Hash` that accepts the following parameters:
1282
+
1283
+ | Key | Description | Default |
1284
+ | --- | ----------- | ------- |
1285
+ | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1286
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1287
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1288
+
1116
1289
  ### Que
1117
1290
 
1118
1291
  The Que integration is a middleware which will trace job executions.
@@ -1131,11 +1304,11 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1131
1304
 
1132
1305
  | Key | Description | Default |
1133
1306
  | --- | ----------- | ------- |
1134
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1135
1307
  | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1136
1308
  | `service_name` | Service name used for `que` instrumentation | `'que'` |
1137
1309
  | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1138
1310
  | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1311
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1139
1312
 
1140
1313
  ### Racecar
1141
1314
 
@@ -1155,7 +1328,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1155
1328
 
1156
1329
  | Key | Description | Default |
1157
1330
  | --- | ----------- | ------- |
1158
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1159
1331
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1160
1332
 
1161
1333
  ### Rack
@@ -1185,11 +1357,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1185
1357
 
1186
1358
  | Key | Description | Default |
1187
1359
  | --- | ----------- | ------- |
1188
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1189
1360
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1190
1361
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
1191
1362
  | `headers` | Hash of HTTP request or response headers to add as tags to the `rack.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
1192
- | `middleware_names` | Enable this if you want to use the middleware classes as the resource names for `rack` spans. Requires `application` option to use. | `false` |
1363
+ | `middleware_names` | Enable this if you want to use the last executed middleware class as the resource name for the `rack` span. If enabled alongside the `rails` instrumention, `rails` takes precedence by setting the `rack` resource name to the active `rails` controller when applicable. Requires `application` option to use. | `false` |
1193
1364
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1194
1365
  | `quantize.query` | Hash containing options for query portion of URL quantization. May include `:show` or `:exclude`. See options below. Option must be nested inside the `quantize` option. | `{}` |
1195
1366
  | `quantize.query.show` | Defines which values should always be shown. Shows no values by default. May be an Array of strings, or `:all` to show all values. Option must be nested inside the `query` option. | `nil` |
@@ -1248,7 +1419,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1248
1419
 
1249
1420
  | Key | Description | Default |
1250
1421
  | --- | ----------- | ------- |
1251
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `nil` |
1252
1422
  | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1253
1423
  | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1254
1424
  | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
@@ -1268,8 +1438,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1268
1438
  | 2.1 | | 3.0 - 4.2 |
1269
1439
  | 2.2 - 2.3 | | 3.0 - 5.2 |
1270
1440
  | 2.4 | | 4.2.8 - 5.2 |
1271
- | 2.5 | | 4.2.8 - 6.0 |
1272
- | 2.6 - 2.7 | 9.2 | 5.0 - 6.0 |
1441
+ | 2.5 | | 4.2.8 - 6.1 |
1442
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1443
+ | 3.0 | | 6.1 |
1273
1444
 
1274
1445
  ### Rake
1275
1446
 
@@ -1297,7 +1468,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1297
1468
 
1298
1469
  | Key | Description | Default |
1299
1470
  | --- | ----------- | ------- |
1300
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1301
1471
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1302
1472
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1303
1473
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
@@ -1357,8 +1527,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1357
1527
 
1358
1528
  | Key | Description | Default |
1359
1529
  | --- | ----------- | ------- |
1360
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1361
1530
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1531
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1362
1532
 
1363
1533
  You can also set *per-instance* configuration as it follows:
1364
1534
 
@@ -1396,12 +1566,17 @@ Datadog.configure do |c|
1396
1566
  # The default configuration for any redis client
1397
1567
  c.use :redis, service_name: 'redis-default'
1398
1568
 
1399
- # The configuration matching a given unix socket
1569
+ # The configuration matching a given unix socket.
1400
1570
  c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1401
1571
 
1402
- # Connection string
1403
- c.use :redis, describes: { url: 'redis://127.0.0.1:6379/0' }, service_name: 'redis-connection-string'
1404
- # Client host, port, db, scheme
1572
+ # For network connections, only these fields are considered during matching:
1573
+ # scheme, host, port, db
1574
+ # Other fields are ignored.
1575
+
1576
+ # Network connection string
1577
+ c.use :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
1578
+ c.use :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
1579
+ # Network client hash
1405
1580
  c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1406
1581
  # Only a subset of the connection hash
1407
1582
  c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
@@ -1409,6 +1584,8 @@ Datadog.configure do |c|
1409
1584
  end
1410
1585
  ```
1411
1586
 
1587
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1588
+
1412
1589
  ### Resque
1413
1590
 
1414
1591
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1416,16 +1593,11 @@ The Resque integration uses Resque hooks that wraps the `perform` method.
1416
1593
  To add tracing to a Resque job:
1417
1594
 
1418
1595
  ```ruby
1596
+ require 'resque'
1419
1597
  require 'ddtrace'
1420
1598
 
1421
- class MyJob
1422
- def self.perform(*args)
1423
- # do_something
1424
- end
1425
- end
1426
-
1427
1599
  Datadog.configure do |c|
1428
- c.use :resque, options
1600
+ c.use :resque, **options
1429
1601
  end
1430
1602
  ```
1431
1603
 
@@ -1433,9 +1605,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1433
1605
 
1434
1606
  | Key | Description | Default |
1435
1607
  | --- | ----------- | ------- |
1436
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1437
1608
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1438
- | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1609
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1610
+ | `workers` | **[DEPRECATED]** Limits instrumented worker classes to only the ones specified in an array (e.g. `[MyJob]`). If not provided, instruments all workers. | `nil` |
1439
1611
 
1440
1612
  ### Rest Client
1441
1613
 
@@ -1454,10 +1626,33 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1454
1626
 
1455
1627
  | Key | Description | Default |
1456
1628
  | --- | ----------- | ------- |
1457
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1458
1629
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1459
1630
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1460
1631
 
1632
+ ### RSpec
1633
+
1634
+ RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1635
+
1636
+ To activate your integration, use the `Datadog.configure` method:
1637
+
1638
+ ```ruby
1639
+ require 'rspec'
1640
+ require 'ddtrace'
1641
+
1642
+ # Configure default RSpec integration
1643
+ Datadog.configure do |c|
1644
+ c.use :rspec, options
1645
+ end
1646
+ ```
1647
+
1648
+ Where `options` is an optional `Hash` that accepts the following parameters:
1649
+
1650
+ | Key | Description | Default |
1651
+ | --- | ----------- | ------- |
1652
+ | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1653
+ | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1654
+ | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1655
+
1461
1656
  ### Sequel
1462
1657
 
1463
1658
  The Sequel integration traces queries made to your database.
@@ -1488,11 +1683,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1488
1683
 
1489
1684
  | Key | Description | Default |
1490
1685
  | --- | ----------- | ------- |
1491
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1492
1686
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1493
1687
 
1494
- Only Ruby 2.0+ is supported.
1495
-
1496
1688
  **Configuring databases to use different settings**
1497
1689
 
1498
1690
  If you use multiple databases with Sequel, you can give each of them different settings by configuring their respective `Sequel::Database` objects:
@@ -1524,8 +1716,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1524
1716
 
1525
1717
  | Key | Description | Default |
1526
1718
  | --- | ----------- | ------- |
1527
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1528
1719
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1720
+ | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1721
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1529
1722
 
1530
1723
  ### Sidekiq
1531
1724
 
@@ -1545,10 +1738,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1545
1738
 
1546
1739
  | Key | Description | Default |
1547
1740
  | --- | ----------- | ------- |
1548
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1549
1741
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1550
1742
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1551
1743
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1744
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1552
1745
 
1553
1746
  ### Sinatra
1554
1747
 
@@ -1608,7 +1801,6 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
1608
1801
 
1609
1802
  | Key | Description | Default |
1610
1803
  | --- | ----------- | ------- |
1611
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1612
1804
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
1613
1805
  | `headers` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
1614
1806
  | `resource_script_names` | Prepend resource names with script name | `false` |
@@ -1632,10 +1824,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1632
1824
 
1633
1825
  | Key | Description | Default |
1634
1826
  | --- | ----------- | ------- |
1635
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1636
1827
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1637
1828
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1638
1829
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1830
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1639
1831
 
1640
1832
  ### Sucker Punch
1641
1833
 
@@ -1656,7 +1848,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1656
1848
 
1657
1849
  | Key | Description | Default |
1658
1850
  | --- | ----------- | ------- |
1659
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1660
1851
  | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1661
1852
 
1662
1853
  ## Advanced configuration
@@ -1672,13 +1863,20 @@ Datadog.configure do |c|
1672
1863
  c.tracer.enabled = true
1673
1864
  c.tracer.hostname = 'my-agent'
1674
1865
  c.tracer.port = 8126
1675
- c.tracer.partial_flush.enabled = false
1866
+
1867
+ # Ensure all traces are ingested by Datadog
1868
+ c.sampling.default_rate = 1.0 # Recommended
1869
+ c.sampling.rate_limit = 200
1870
+ # or provide a custom implementation (overrides c.sampling settings)
1676
1871
  c.tracer.sampler = Datadog::AllSampler.new
1677
1872
 
1678
- # OR for advanced use cases, you can specify your own tracer:
1873
+ # Breaks down very large traces into smaller batches
1874
+ c.tracer.partial_flush.enabled = false
1875
+
1876
+ # You can specify your own tracer
1679
1877
  c.tracer.instance = Datadog::Tracer.new
1680
1878
 
1681
- # To enable debug mode:
1879
+ # To enable debug mode
1682
1880
  c.diagnostics.debug = true
1683
1881
  end
1684
1882
  ```
@@ -1690,9 +1888,12 @@ Available options are:
1690
1888
  - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1691
1889
  - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1692
1890
  - `port`: set the port the trace agent is listening on.
1891
+ - `sampling.default_rate`: default tracer sampling rate, between `0.0` (0%) and `1.0` (100%, recommended). `1.0` or Tracing without Limits™, allows you to send all of your traffic and retention can be [configured within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/). When this configuration is not set, the Datadog agent will keep an intelligent assortment of diverse traces.
1892
+ - `sampling.rate_limit`: maximum number of traces per second to sample. Defaults to 100 per second.
1693
1893
  - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1694
1894
  - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1695
1895
  - `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
1896
+ - `time_now_provider`: when testing, it might be helpful to use a different time provider. For Timecop, for example, `->{ Time.now_without_mock_time }` allows the tracer to use the real wall time. Span duration calculation will still use the system monotonic clock when available, thus not being affected by this setting. Defaults to `->{ Time.now }`.
1696
1897
 
1697
1898
  #### Custom logging
1698
1899
 
@@ -1746,13 +1947,22 @@ Other Environment Variables:
1746
1947
 
1747
1948
  - `DD_TRACE_AGENT_URL`: Sets the URL endpoint where traces are sent. Has priority over `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT` if set. e.g. `DD_TRACE_AGENT_URL=http://localhost:8126`.
1748
1949
  - `DD_TRACE_<INTEGRATION>_ENABLED`: Enables or disables an **activated** integration. Defaults to `true`.. e.g. `DD_TRACE_RAILS_ENABLED=false`. This option has no effects on integrations that have not been explicitly activated (e.g. `Datadog.configure{ |c| c.use :integration }`).on code. This environment variable can only be used to disable an integration.
1749
- - `DD_TRACE_<INTEGRATION>_ANALYTICS_ENABLED`: Enables or disable App Analytics for a specific integration. Valid values are: true or false (default). e.g. `DD_TRACE_ACTION_CABLE_ANALYTICS_ENABLED=true`.
1750
- - `DD_TRACE_<INTEGRATION>_ANALYTICS_SAMPLE_RATE`: Sets the App Analytics sampling rate for a specific integration. A floating number between 0.0 and 1.0 (default). e.g. `DD_TRACE_ACTION_CABLE_ANALYTICS_SAMPLE_RATE=0.5`.
1950
+ - `DD_TRACE_SAMPLE_RATE`: Sets the trace sampling rate between `0.0` (0%) and `1.0` (100%, recommended). `1.0` or Tracing without Limits™, allows you to send all of your traffic and retention can be [configured within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/). When this configuration is not set, the Datadog agent will keep an intelligent assortment of diverse traces.
1751
1951
  - `DD_LOGS_INJECTION`: Automatically enables injection [Trace Correlation](#trace-correlation) information, such as `dd.trace_id`, into Rails logs. Supports the default logger (`ActiveSupport::TaggedLogging`) and `Lograge`. Details on the format of Trace Correlation information can be found in the [Trace Correlation](#trace-correlation) section. Valid values are: `true` or `false`(default). e.g. `DD_LOGS_INJECTION=true`.
1752
1952
 
1753
1953
  ### Sampling
1754
1954
 
1755
- `ddtrace` can perform trace sampling. While the trace agent already samples traces to reduce bandwidth usage, client sampling reduces the performance overhead.
1955
+ Datadog's Tracing without Limits™ allows you to send all of your traffic and [configure retention within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/).
1956
+
1957
+ We recommend setting the environment variable `DD_TRACE_SAMPLE_RATE=1.0` in all new applications using `ddtrace`.
1958
+
1959
+ App Analytics, previously configured with the `analytics_enabled` setting, is deprecated in favor of Tracing without Limits™. Documentation for this [deprecated configuration is still available](https://docs.datadoghq.com/tracing/legacy_app_analytics/).
1960
+
1961
+ #### Application-side sampling
1962
+
1963
+ While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
1964
+
1965
+ This will **reduce visibility and is not recommended**. See [DD_TRACE_SAMPLE_RATE](#environment-variables) for the recommended sampling approach.
1756
1966
 
1757
1967
  `Datadog::RateSampler` samples a ratio of the traces. For example:
1758
1968
 
@@ -1910,12 +2120,14 @@ For more details on how to activate distributed tracing for integrations, see th
1910
2120
 
1911
2121
  - [Excon](#excon)
1912
2122
  - [Faraday](#faraday)
1913
- - [Rest Client](#restclient)
2123
+ - [Rest Client](#rest-client)
1914
2124
  - [Net/HTTP](#nethttp)
1915
2125
  - [Rack](#rack)
1916
2126
  - [Rails](#rails)
1917
2127
  - [Sinatra](#sinatra)
1918
2128
  - [http.rb](#http-rb)
2129
+ - [httpclient](#httpclient)
2130
+ - [httpx](#httpx)
1919
2131
 
1920
2132
  **Using the HTTP propagator**
1921
2133
 
@@ -1944,9 +2156,7 @@ end
1944
2156
 
1945
2157
  Traces that originate from HTTP requests can be configured to include the time spent in a frontend web server or load balancer queue before the request reaches the Ruby application.
1946
2158
 
1947
- This functionality is **experimental** and deactivated by default.
1948
-
1949
- To activate this feature, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
2159
+ This feature is disabled by default. To activate it, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
1950
2160
 
1951
2161
  ```
1952
2162
  # /etc/nginx/conf.d/ruby_service.conf
@@ -1960,9 +2170,7 @@ server {
1960
2170
  }
1961
2171
  ```
1962
2172
 
1963
- Then you must enable the request queuing feature in the integration handling the request.
1964
-
1965
- For Rack-based applications, see the [documentation](#rack) for details for enabling this feature.
2173
+ Then you must enable the request queuing feature, by setting `request_queuing: true`, in the integration handling the request. For Rack-based applications, see the [documentation](#rack) for details.
1966
2174
 
1967
2175
  ### Processing Pipeline
1968
2176
 
@@ -2035,7 +2243,7 @@ In many cases, such as logging, it may be useful to correlate trace IDs to other
2035
2243
 
2036
2244
  ##### Automatic
2037
2245
 
2038
- For Rails applications using the default logger (`ActiveSupport::TaggedLogging`) or `lograge`, you can automatically enable trace correlation injection by setting the `rails` instrumentation configuration option `log_injection` to `true` or by setting environment variable `DD_LOGS_INJECTION=true`:
2246
+ For Rails applications using the default logger (`ActiveSupport::TaggedLogging`), `semantic_logger`, or `lograge`, you can automatically enable trace correlation injection by setting the `rails` instrumentation configuration option `log_injection` to `true` or by setting environment variable `DD_LOGS_INJECTION=true`:
2039
2247
 
2040
2248
  ```ruby
2041
2249
  # config/initializers/datadog.rb
@@ -2046,11 +2254,9 @@ Datadog.configure do |c|
2046
2254
  end
2047
2255
  ```
2048
2256
 
2049
- _Note:_ For `lograge` users who have also defined `lograge.custom_options` in an `initializers/lograge.rb` configuration file, due to the order that Rails loads initializers (alphabetical), automatic trace correlation may not take effect, since `initializers/datadog.rb` would be overwritten by the `initializers/lograge.rb` initializer. To support automatic trace correlation with _existing_ `lograge.custom_options`, use the [Manual (Lograge)](#manual-lograge) configuration below.
2050
-
2051
2257
  ##### Manual (Lograge)
2052
2258
 
2053
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
2259
+ After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
2054
2260
 
2055
2261
  ```ruby
2056
2262
  config.lograge.custom_options = lambda do |event|
@@ -2207,7 +2413,7 @@ The tracer and its integrations can produce some additional metrics that can pro
2207
2413
  To configure your application for metrics collection:
2208
2414
 
2209
2415
  1. [Configure your Datadog agent for StatsD](https://docs.datadoghq.com/developers/dogstatsd/#setup)
2210
- 2. Add `gem 'dogstatsd-ruby'` to your Gemfile
2416
+ 2. Add `gem 'dogstatsd-ruby', '~> 5.2'` to your Gemfile
2211
2417
 
2212
2418
  #### For application runtime
2213
2419
 
@@ -2277,3 +2483,53 @@ However, additional instrumentation provided by Datadog can be activated alongsi
2277
2483
  | `OpenTracing::FORMAT_TEXT_MAP` | Yes | |
2278
2484
  | `OpenTracing::FORMAT_RACK` | Yes | Because of the loss of resolution in the Rack format, please note that baggage items with names containing either upper case characters or `-` will be converted to lower case and `_` in a round-trip respectively. We recommend avoiding these characters or accommodating accordingly on the receiving end. |
2279
2485
  | `OpenTracing::FORMAT_BINARY` | No | |
2486
+
2487
+ ### Profiling
2488
+
2489
+ *Currently available as BETA feature.*
2490
+
2491
+ `ddtrace` can produce profiles that measure method-level application resource usage within production environments. These profiles can give insight into resources spent in Ruby code outside of existing trace instrumentation.
2492
+
2493
+ **Setup**
2494
+
2495
+ To get started with profiling, follow the [Profiler Getting Started Guide](https://docs.datadoghq.com/tracing/profiler/getting_started/?code-lang=ruby).
2496
+
2497
+ #### Troubleshooting
2498
+
2499
+ If you run into issues with profiling, please check the [Profiler Troubleshooting Guide](https://docs.datadoghq.com/tracing/profiler/profiler_troubleshooting/?code-lang=ruby).
2500
+
2501
+ #### Profiling Resque jobs
2502
+
2503
+ When profiling [Resque](https://github.com/resque/resque) jobs, you should set the `RUN_AT_EXIT_HOOKS=1` option described in the [Resque](https://github.com/resque/resque/blob/v2.0.0/docs/HOOKS.md#worker-hooks) documentation.
2504
+
2505
+ Without this flag, profiles for short-lived Resque jobs will not be available as Resque kills worker processes before they have a chance to submit this information.
2506
+
2507
+ ## Known issues and suggested configurations
2508
+
2509
+ ### Payload too large
2510
+
2511
+ By default, Datadog limits the size of trace payloads to prevent memory overhead within instrumented applications. As a result, traces containing thousands of operations may not be sent to Datadog.
2512
+
2513
+ If traces are missing, enable [debug mode](#tracer-settings) to check if messages containing `"Dropping trace. Payload too large"` are logged.
2514
+
2515
+ Since debug mode is verbose, Datadog does not recommend leaving this enabled or enabling this in production. Disable it after confirming. You can inspect the [Datadog Agent logs](https://docs.datadoghq.com/agent/guide/agent-log-files/) for similar messages.
2516
+
2517
+ If you have confirmed that traces are dropped due to large payloads, then enable the [partial_flush](#tracer-settings) setting to break down large traces into smaller chunks.
2518
+
2519
+ ### Stack level too deep
2520
+
2521
+ Datadog tracing collects trace data by adding instrumentation into other common libraries (e.g. Rails, Rack, etc.) Some libraries provide APIs to add this instrumentation, but some do not. In order to add instrumentation into libraries lacking an instrumentation API, Datadog uses a technique called "monkey-patching" to modify the code of that library.
2522
+
2523
+ In Ruby version 1.9.3 and earlier, "monkey-patching" often involved the use of [`alias_method`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-alias_method), also known as *method rewriting*, to destructively replace existing Ruby methods. However, this practice would often create conflicts & errors if two libraries attempted to "rewrite" the same method. (e.g. two different APM packages trying to instrument the same method.)
2524
+
2525
+ In Ruby 2.0, the [`Module#prepend`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-prepend) feature was introduced. This feature avoids destructive method rewriting and allows multiple "monkey patches" on the same method. Consequently, it has become the safest, preferred means to "monkey patch" code.
2526
+
2527
+ Datadog instrumentation almost exclusively uses the `Module#prepend` feature to add instrumentation non-destructively. However, some libraries (typically those supporting Ruby < 2.0) still use `alias_method` which can create conflicts with Datadog instrumentation, often resulting in `SystemStackError` or `stack level too deep` errors.
2528
+
2529
+ As the implementation of `alias_method` exists within those libraries, Datadog generally cannot fix them. However, some libraries have known workarounds:
2530
+
2531
+ * `rack-mini-profiler`: [Net::HTTP stack level too deep errors](https://github.com/MiniProfiler/rack-mini-profiler#nethttp-stack-level-too-deep-errors).
2532
+
2533
+ For libraries without a known workaround, consider removing the library using `alias` or `Module#alias_method` or separating libraries into different environments for testing.
2534
+
2535
+ For any further questions or to report an occurence of this issue, please [reach out to Datadog support](https://docs.datadoghq.com/help)