ddtrace 0.42.0 → 0.54.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (602) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +22 -0
  3. data/.gitignore +7 -1
  4. data/CHANGELOG.md +1645 -370
  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 +21 -39
  10. data/docs/DevelopmentGuide.md +46 -8
  11. data/docs/GettingStarted.md +439 -92
  12. data/docs/ProfilingDevelopment.md +107 -0
  13. data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +86 -0
  14. data/ext/ddtrace_profiling_native_extension/clock_id.h +4 -0
  15. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +52 -0
  16. data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +14 -0
  17. data/ext/ddtrace_profiling_native_extension/extconf.rb +197 -0
  18. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +35 -0
  19. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +3 -0
  20. data/ext/ddtrace_profiling_native_extension/profiling.c +22 -0
  21. data/lib/datadog/ci/configuration/components.rb +31 -0
  22. data/lib/datadog/ci/configuration/settings.rb +37 -0
  23. data/lib/datadog/ci/context_flush.rb +29 -0
  24. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +31 -0
  25. data/lib/datadog/ci/contrib/cucumber/ext.rb +20 -0
  26. data/lib/datadog/ci/contrib/cucumber/formatter.rb +99 -0
  27. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +27 -0
  28. data/lib/datadog/ci/contrib/cucumber/integration.rb +48 -0
  29. data/lib/datadog/ci/contrib/cucumber/patcher.rb +26 -0
  30. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +31 -0
  31. data/lib/datadog/ci/contrib/rspec/example.rb +75 -0
  32. data/lib/datadog/ci/contrib/rspec/ext.rb +19 -0
  33. data/lib/datadog/ci/contrib/rspec/integration.rb +49 -0
  34. data/lib/datadog/ci/contrib/rspec/patcher.rb +26 -0
  35. data/lib/datadog/ci/ext/app_types.rb +10 -0
  36. data/lib/datadog/ci/ext/environment.rb +485 -0
  37. data/lib/datadog/ci/ext/settings.rb +11 -0
  38. data/lib/datadog/ci/ext/test.rb +36 -0
  39. data/lib/datadog/ci/extensions.rb +18 -0
  40. data/lib/datadog/ci/test.rb +81 -0
  41. data/lib/datadog/ci.rb +17 -0
  42. data/lib/datadog/contrib.rb +71 -0
  43. data/lib/datadog/core/environment/cgroup.rb +52 -0
  44. data/lib/datadog/core/environment/class_count.rb +20 -0
  45. data/lib/datadog/core/environment/container.rb +91 -0
  46. data/lib/datadog/core/environment/ext.rb +27 -0
  47. data/lib/datadog/core/environment/gc.rb +19 -0
  48. data/lib/datadog/core/environment/identity.rb +51 -0
  49. data/lib/datadog/core/environment/socket.rb +17 -0
  50. data/lib/datadog/core/environment/thread_count.rb +19 -0
  51. data/lib/datadog/core/environment/variable_helpers.rb +42 -0
  52. data/lib/datadog/core/environment/vm_cache.rb +46 -0
  53. data/lib/ddtrace/analytics.rb +3 -0
  54. data/lib/ddtrace/auto_instrument.rb +5 -0
  55. data/lib/ddtrace/auto_instrument_base.rb +7 -0
  56. data/lib/ddtrace/buffer.rb +38 -24
  57. data/lib/ddtrace/chunker.rb +1 -0
  58. data/lib/ddtrace/configuration/agent_settings_resolver.rb +309 -0
  59. data/lib/ddtrace/configuration/base.rb +9 -11
  60. data/lib/ddtrace/configuration/components.rb +167 -26
  61. data/lib/ddtrace/configuration/dependency_resolver.rb +1 -0
  62. data/lib/ddtrace/configuration/option.rb +1 -0
  63. data/lib/ddtrace/configuration/option_definition.rb +2 -3
  64. data/lib/ddtrace/configuration/option_definition_set.rb +1 -0
  65. data/lib/ddtrace/configuration/option_set.rb +1 -0
  66. data/lib/ddtrace/configuration/options.rb +7 -9
  67. data/lib/ddtrace/configuration/pin_setup.rb +1 -0
  68. data/lib/ddtrace/configuration/settings.rb +142 -12
  69. data/lib/ddtrace/configuration.rb +132 -24
  70. data/lib/ddtrace/context.rb +51 -22
  71. data/lib/ddtrace/context_flush.rb +15 -2
  72. data/lib/ddtrace/context_provider.rb +13 -2
  73. data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +1 -0
  74. data/lib/ddtrace/contrib/action_cable/event.rb +6 -4
  75. data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +1 -0
  76. data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +1 -0
  77. data/lib/ddtrace/contrib/action_cable/events/transmit.rb +1 -0
  78. data/lib/ddtrace/contrib/action_cable/events.rb +1 -0
  79. data/lib/ddtrace/contrib/action_cable/ext.rb +1 -0
  80. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +47 -0
  81. data/lib/ddtrace/contrib/action_cable/integration.rb +8 -0
  82. data/lib/ddtrace/contrib/action_cable/patcher.rb +2 -0
  83. data/lib/ddtrace/contrib/action_mailer/configuration/settings.rb +32 -0
  84. data/lib/ddtrace/contrib/action_mailer/event.rb +50 -0
  85. data/lib/ddtrace/contrib/action_mailer/events/deliver.rb +54 -0
  86. data/lib/ddtrace/contrib/action_mailer/events/process.rb +41 -0
  87. data/lib/ddtrace/contrib/action_mailer/events.rb +31 -0
  88. data/lib/ddtrace/contrib/action_mailer/ext.rb +32 -0
  89. data/lib/ddtrace/contrib/action_mailer/integration.rb +45 -0
  90. data/lib/ddtrace/contrib/action_mailer/patcher.rb +27 -0
  91. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +22 -13
  92. data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +2 -1
  93. data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +1 -0
  94. data/lib/ddtrace/contrib/action_pack/ext.rb +1 -0
  95. data/lib/ddtrace/contrib/action_pack/integration.rb +8 -0
  96. data/lib/ddtrace/contrib/action_pack/patcher.rb +1 -0
  97. data/lib/ddtrace/contrib/action_pack/utils.rb +2 -1
  98. data/lib/ddtrace/contrib/action_view/configuration/settings.rb +1 -0
  99. data/lib/ddtrace/contrib/action_view/event.rb +4 -7
  100. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +2 -0
  101. data/lib/ddtrace/contrib/action_view/events/render_template.rb +2 -0
  102. data/lib/ddtrace/contrib/action_view/events.rb +1 -0
  103. data/lib/ddtrace/contrib/action_view/ext.rb +1 -0
  104. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +1 -0
  105. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +1 -0
  106. data/lib/ddtrace/contrib/action_view/integration.rb +8 -0
  107. data/lib/ddtrace/contrib/action_view/patcher.rb +5 -4
  108. data/lib/ddtrace/contrib/action_view/utils.rb +2 -1
  109. data/lib/ddtrace/contrib/active_job/configuration/settings.rb +33 -0
  110. data/lib/ddtrace/contrib/active_job/event.rb +54 -0
  111. data/lib/ddtrace/contrib/active_job/events/discard.rb +46 -0
  112. data/lib/ddtrace/contrib/active_job/events/enqueue.rb +45 -0
  113. data/lib/ddtrace/contrib/active_job/events/enqueue_at.rb +45 -0
  114. data/lib/ddtrace/contrib/active_job/events/enqueue_retry.rb +47 -0
  115. data/lib/ddtrace/contrib/active_job/events/perform.rb +45 -0
  116. data/lib/ddtrace/contrib/active_job/events/retry_stopped.rb +46 -0
  117. data/lib/ddtrace/contrib/active_job/events.rb +39 -0
  118. data/lib/ddtrace/contrib/active_job/ext.rb +32 -0
  119. data/lib/ddtrace/contrib/active_job/integration.rb +46 -0
  120. data/lib/ddtrace/contrib/active_job/log_injection.rb +21 -0
  121. data/lib/ddtrace/contrib/active_job/patcher.rb +33 -0
  122. data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +1 -0
  123. data/lib/ddtrace/contrib/active_model_serializers/event.rb +3 -2
  124. data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +1 -0
  125. data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +1 -0
  126. data/lib/ddtrace/contrib/active_model_serializers/events.rb +1 -0
  127. data/lib/ddtrace/contrib/active_model_serializers/ext.rb +1 -0
  128. data/lib/ddtrace/contrib/active_model_serializers/integration.rb +1 -0
  129. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +1 -0
  130. data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +31 -0
  131. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +108 -18
  132. data/lib/ddtrace/contrib/active_record/configuration/settings.rb +1 -0
  133. data/lib/ddtrace/contrib/active_record/event.rb +3 -2
  134. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +1 -0
  135. data/lib/ddtrace/contrib/active_record/events/sql.rb +1 -0
  136. data/lib/ddtrace/contrib/active_record/events.rb +1 -0
  137. data/lib/ddtrace/contrib/active_record/ext.rb +1 -0
  138. data/lib/ddtrace/contrib/active_record/integration.rb +8 -0
  139. data/lib/ddtrace/contrib/active_record/patcher.rb +1 -0
  140. data/lib/ddtrace/contrib/active_record/utils.rb +69 -21
  141. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +105 -3
  142. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +26 -4
  143. data/lib/ddtrace/contrib/active_support/cache/redis.rb +2 -5
  144. data/lib/ddtrace/contrib/active_support/configuration/settings.rb +1 -0
  145. data/lib/ddtrace/contrib/active_support/ext.rb +4 -0
  146. data/lib/ddtrace/contrib/active_support/integration.rb +8 -1
  147. data/lib/ddtrace/contrib/active_support/notifications/event.rb +15 -3
  148. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +3 -1
  149. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +10 -5
  150. data/lib/ddtrace/contrib/active_support/patcher.rb +1 -0
  151. data/lib/ddtrace/contrib/analytics.rb +1 -0
  152. data/lib/ddtrace/contrib/auto_instrument.rb +48 -0
  153. data/lib/ddtrace/contrib/aws/configuration/settings.rb +1 -0
  154. data/lib/ddtrace/contrib/aws/ext.rb +1 -0
  155. data/lib/ddtrace/contrib/aws/instrumentation.rb +32 -1
  156. data/lib/ddtrace/contrib/aws/integration.rb +1 -0
  157. data/lib/ddtrace/contrib/aws/parsed_context.rb +1 -0
  158. data/lib/ddtrace/contrib/aws/patcher.rb +6 -1
  159. data/lib/ddtrace/contrib/aws/services.rb +4 -0
  160. data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +1 -0
  161. data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +1 -0
  162. data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +1 -0
  163. data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +1 -0
  164. data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +1 -0
  165. data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +3 -1
  166. data/lib/ddtrace/contrib/configurable.rb +65 -38
  167. data/lib/ddtrace/contrib/configuration/resolver.rb +71 -5
  168. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +21 -20
  169. data/lib/ddtrace/contrib/configuration/settings.rb +8 -6
  170. data/lib/ddtrace/contrib/dalli/configuration/settings.rb +1 -0
  171. data/lib/ddtrace/contrib/dalli/ext.rb +1 -0
  172. data/lib/ddtrace/contrib/dalli/instrumentation.rb +2 -1
  173. data/lib/ddtrace/contrib/dalli/integration.rb +1 -0
  174. data/lib/ddtrace/contrib/dalli/patcher.rb +2 -39
  175. data/lib/ddtrace/contrib/dalli/quantize.rb +1 -0
  176. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
  177. data/lib/ddtrace/contrib/delayed_job/ext.rb +1 -0
  178. data/lib/ddtrace/contrib/delayed_job/integration.rb +1 -0
  179. data/lib/ddtrace/contrib/delayed_job/patcher.rb +1 -0
  180. data/lib/ddtrace/contrib/delayed_job/plugin.rb +5 -3
  181. data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +1 -0
  182. data/lib/ddtrace/contrib/elasticsearch/ext.rb +1 -0
  183. data/lib/ddtrace/contrib/elasticsearch/integration.rb +1 -0
  184. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +2 -0
  185. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +6 -2
  186. data/lib/ddtrace/contrib/ethon/configuration/settings.rb +1 -0
  187. data/lib/ddtrace/contrib/ethon/easy_patch.rb +13 -11
  188. data/lib/ddtrace/contrib/ethon/ext.rb +2 -0
  189. data/lib/ddtrace/contrib/ethon/integration.rb +1 -0
  190. data/lib/ddtrace/contrib/ethon/multi_patch.rb +2 -1
  191. data/lib/ddtrace/contrib/ethon/patcher.rb +4 -2
  192. data/lib/ddtrace/contrib/excon/configuration/settings.rb +1 -0
  193. data/lib/ddtrace/contrib/excon/ext.rb +1 -0
  194. data/lib/ddtrace/contrib/excon/integration.rb +1 -0
  195. data/lib/ddtrace/contrib/excon/middleware.rb +10 -7
  196. data/lib/ddtrace/contrib/excon/patcher.rb +1 -0
  197. data/lib/ddtrace/contrib/extensions.rb +90 -14
  198. data/lib/ddtrace/contrib/faraday/configuration/settings.rb +1 -0
  199. data/lib/ddtrace/contrib/faraday/connection.rb +1 -0
  200. data/lib/ddtrace/contrib/faraday/ext.rb +1 -0
  201. data/lib/ddtrace/contrib/faraday/integration.rb +1 -0
  202. data/lib/ddtrace/contrib/faraday/middleware.rb +2 -3
  203. data/lib/ddtrace/contrib/faraday/patcher.rb +3 -38
  204. data/lib/ddtrace/contrib/faraday/rack_builder.rb +1 -0
  205. data/lib/ddtrace/contrib/grape/configuration/settings.rb +8 -0
  206. data/lib/ddtrace/contrib/grape/endpoint.rb +68 -32
  207. data/lib/ddtrace/contrib/grape/ext.rb +2 -0
  208. data/lib/ddtrace/contrib/grape/instrumentation.rb +4 -3
  209. data/lib/ddtrace/contrib/grape/integration.rb +1 -0
  210. data/lib/ddtrace/contrib/grape/patcher.rb +2 -43
  211. data/lib/ddtrace/contrib/graphql/configuration/settings.rb +1 -0
  212. data/lib/ddtrace/contrib/graphql/ext.rb +1 -0
  213. data/lib/ddtrace/contrib/graphql/integration.rb +1 -0
  214. data/lib/ddtrace/contrib/graphql/patcher.rb +1 -0
  215. data/lib/ddtrace/contrib/grpc/configuration/settings.rb +2 -0
  216. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +1 -0
  217. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -4
  218. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +13 -8
  219. data/lib/ddtrace/contrib/grpc/ext.rb +1 -0
  220. data/lib/ddtrace/contrib/grpc/integration.rb +1 -0
  221. data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +1 -0
  222. data/lib/ddtrace/contrib/grpc/patcher.rb +3 -37
  223. data/lib/ddtrace/contrib/http/circuit_breaker.rb +2 -3
  224. data/lib/ddtrace/contrib/http/configuration/settings.rb +1 -0
  225. data/lib/ddtrace/contrib/http/ext.rb +1 -0
  226. data/lib/ddtrace/contrib/http/instrumentation.rb +9 -8
  227. data/lib/ddtrace/contrib/http/integration.rb +1 -0
  228. data/lib/ddtrace/contrib/http/patcher.rb +2 -1
  229. data/lib/ddtrace/contrib/http_annotation_helper.rb +1 -0
  230. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +33 -0
  231. data/lib/ddtrace/contrib/httpclient/ext.rb +18 -0
  232. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +148 -0
  233. data/lib/ddtrace/contrib/httpclient/integration.rb +44 -0
  234. data/lib/ddtrace/contrib/httpclient/patcher.rb +39 -0
  235. data/lib/ddtrace/contrib/httprb/configuration/settings.rb +1 -0
  236. data/lib/ddtrace/contrib/httprb/ext.rb +1 -0
  237. data/lib/ddtrace/contrib/httprb/instrumentation.rb +17 -22
  238. data/lib/ddtrace/contrib/httprb/integration.rb +1 -0
  239. data/lib/ddtrace/contrib/httprb/patcher.rb +8 -4
  240. data/lib/ddtrace/contrib/integration.rb +4 -3
  241. data/lib/ddtrace/contrib/kafka/configuration/settings.rb +1 -0
  242. data/lib/ddtrace/contrib/kafka/consumer_event.rb +1 -0
  243. data/lib/ddtrace/contrib/kafka/consumer_group_event.rb +1 -0
  244. data/lib/ddtrace/contrib/kafka/event.rb +4 -3
  245. data/lib/ddtrace/contrib/kafka/events/connection/request.rb +1 -0
  246. data/lib/ddtrace/contrib/kafka/events/consumer/process_batch.rb +1 -0
  247. data/lib/ddtrace/contrib/kafka/events/consumer/process_message.rb +1 -0
  248. data/lib/ddtrace/contrib/kafka/events/consumer_group/heartbeat.rb +1 -0
  249. data/lib/ddtrace/contrib/kafka/events/consumer_group/join_group.rb +1 -0
  250. data/lib/ddtrace/contrib/kafka/events/consumer_group/leave_group.rb +1 -0
  251. data/lib/ddtrace/contrib/kafka/events/consumer_group/sync_group.rb +1 -0
  252. data/lib/ddtrace/contrib/kafka/events/produce_operation/send_messages.rb +1 -0
  253. data/lib/ddtrace/contrib/kafka/events/producer/deliver_messages.rb +1 -0
  254. data/lib/ddtrace/contrib/kafka/events.rb +1 -0
  255. data/lib/ddtrace/contrib/kafka/ext.rb +1 -0
  256. data/lib/ddtrace/contrib/kafka/integration.rb +1 -0
  257. data/lib/ddtrace/contrib/kafka/patcher.rb +1 -0
  258. data/lib/ddtrace/contrib/lograge/configuration/settings.rb +19 -0
  259. data/lib/ddtrace/contrib/lograge/ext.rb +11 -0
  260. data/lib/ddtrace/contrib/lograge/instrumentation.rb +39 -0
  261. data/lib/ddtrace/contrib/lograge/integration.rb +46 -0
  262. data/lib/ddtrace/contrib/lograge/patcher.rb +26 -0
  263. data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +1 -0
  264. data/lib/ddtrace/contrib/mongodb/ext.rb +1 -0
  265. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +6 -3
  266. data/lib/ddtrace/contrib/mongodb/integration.rb +6 -0
  267. data/lib/ddtrace/contrib/mongodb/parsers.rb +1 -0
  268. data/lib/ddtrace/contrib/mongodb/patcher.rb +3 -2
  269. data/lib/ddtrace/contrib/mongodb/subscribers.rb +3 -3
  270. data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +1 -0
  271. data/lib/ddtrace/contrib/mysql2/ext.rb +1 -0
  272. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +2 -1
  273. data/lib/ddtrace/contrib/mysql2/integration.rb +1 -0
  274. data/lib/ddtrace/contrib/mysql2/patcher.rb +2 -1
  275. data/lib/ddtrace/contrib/patchable.rb +21 -9
  276. data/lib/ddtrace/contrib/patcher.rb +12 -8
  277. data/lib/ddtrace/contrib/presto/configuration/settings.rb +1 -0
  278. data/lib/ddtrace/contrib/presto/ext.rb +1 -0
  279. data/lib/ddtrace/contrib/presto/instrumentation.rb +2 -1
  280. data/lib/ddtrace/contrib/presto/integration.rb +1 -0
  281. data/lib/ddtrace/contrib/presto/patcher.rb +7 -3
  282. data/lib/ddtrace/contrib/qless/configuration/settings.rb +36 -0
  283. data/lib/ddtrace/contrib/qless/ext.rb +21 -0
  284. data/lib/ddtrace/contrib/qless/integration.rb +39 -0
  285. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  286. data/lib/ddtrace/contrib/qless/qless_job.rb +74 -0
  287. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +34 -0
  288. data/lib/ddtrace/contrib/que/configuration/settings.rb +2 -0
  289. data/lib/ddtrace/contrib/que/ext.rb +20 -19
  290. data/lib/ddtrace/contrib/que/integration.rb +1 -0
  291. data/lib/ddtrace/contrib/que/patcher.rb +1 -0
  292. data/lib/ddtrace/contrib/que/tracer.rb +4 -2
  293. data/lib/ddtrace/contrib/racecar/configuration/settings.rb +1 -0
  294. data/lib/ddtrace/contrib/racecar/event.rb +4 -2
  295. data/lib/ddtrace/contrib/racecar/events/batch.rb +1 -0
  296. data/lib/ddtrace/contrib/racecar/events/consume.rb +1 -0
  297. data/lib/ddtrace/contrib/racecar/events/message.rb +1 -0
  298. data/lib/ddtrace/contrib/racecar/events.rb +1 -0
  299. data/lib/ddtrace/contrib/racecar/ext.rb +1 -0
  300. data/lib/ddtrace/contrib/racecar/integration.rb +1 -0
  301. data/lib/ddtrace/contrib/racecar/patcher.rb +1 -0
  302. data/lib/ddtrace/contrib/rack/configuration/settings.rb +4 -3
  303. data/lib/ddtrace/contrib/rack/ext.rb +1 -0
  304. data/lib/ddtrace/contrib/rack/integration.rb +8 -0
  305. data/lib/ddtrace/contrib/rack/middlewares.rb +8 -12
  306. data/lib/ddtrace/contrib/rack/patcher.rb +2 -3
  307. data/lib/ddtrace/contrib/rack/request_queue.rb +7 -1
  308. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  309. data/lib/ddtrace/contrib/rails/configuration/settings.rb +8 -0
  310. data/lib/ddtrace/contrib/rails/ext.rb +1 -0
  311. data/lib/ddtrace/contrib/rails/framework.rb +50 -2
  312. data/lib/ddtrace/contrib/rails/integration.rb +1 -0
  313. data/lib/ddtrace/contrib/rails/log_injection.rb +1 -40
  314. data/lib/ddtrace/contrib/rails/middlewares.rb +1 -0
  315. data/lib/ddtrace/contrib/rails/patcher.rb +40 -21
  316. data/lib/ddtrace/contrib/rails/railtie.rb +1 -0
  317. data/lib/ddtrace/contrib/rails/utils.rb +5 -0
  318. data/lib/ddtrace/contrib/rake/configuration/settings.rb +1 -0
  319. data/lib/ddtrace/contrib/rake/ext.rb +1 -0
  320. data/lib/ddtrace/contrib/rake/instrumentation.rb +6 -3
  321. data/lib/ddtrace/contrib/rake/integration.rb +2 -1
  322. data/lib/ddtrace/contrib/rake/patcher.rb +2 -1
  323. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +15 -5
  324. data/lib/ddtrace/contrib/redis/configuration/settings.rb +6 -0
  325. data/lib/ddtrace/contrib/redis/ext.rb +2 -0
  326. data/lib/ddtrace/contrib/redis/instrumentation.rb +90 -0
  327. data/lib/ddtrace/contrib/redis/integration.rb +1 -0
  328. data/lib/ddtrace/contrib/redis/patcher.rb +3 -67
  329. data/lib/ddtrace/contrib/redis/quantize.rb +29 -0
  330. data/lib/ddtrace/contrib/redis/tags.rb +6 -1
  331. data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
  332. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +7 -7
  333. data/lib/ddtrace/contrib/registerable.rb +4 -4
  334. data/lib/ddtrace/contrib/registry.rb +3 -2
  335. data/lib/ddtrace/contrib/resque/configuration/settings.rb +19 -1
  336. data/lib/ddtrace/contrib/resque/ext.rb +1 -0
  337. data/lib/ddtrace/contrib/resque/integration.rb +2 -5
  338. data/lib/ddtrace/contrib/resque/patcher.rb +5 -4
  339. data/lib/ddtrace/contrib/resque/resque_job.rb +26 -2
  340. data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +1 -0
  341. data/lib/ddtrace/contrib/rest_client/ext.rb +1 -0
  342. data/lib/ddtrace/contrib/rest_client/integration.rb +1 -0
  343. data/lib/ddtrace/contrib/rest_client/patcher.rb +3 -1
  344. data/lib/ddtrace/contrib/rest_client/request_patch.rb +3 -4
  345. data/lib/ddtrace/contrib/semantic_logger/configuration/settings.rb +19 -0
  346. data/lib/ddtrace/contrib/semantic_logger/ext.rb +11 -0
  347. data/lib/ddtrace/contrib/semantic_logger/instrumentation.rb +43 -0
  348. data/lib/ddtrace/contrib/semantic_logger/integration.rb +48 -0
  349. data/lib/ddtrace/contrib/semantic_logger/patcher.rb +26 -0
  350. data/lib/ddtrace/contrib/sequel/configuration/settings.rb +1 -0
  351. data/lib/ddtrace/contrib/sequel/database.rb +2 -1
  352. data/lib/ddtrace/contrib/sequel/dataset.rb +2 -1
  353. data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
  354. data/lib/ddtrace/contrib/sequel/integration.rb +1 -0
  355. data/lib/ddtrace/contrib/sequel/patcher.rb +3 -2
  356. data/lib/ddtrace/contrib/sequel/utils.rb +6 -6
  357. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +3 -0
  358. data/lib/ddtrace/contrib/shoryuken/ext.rb +1 -0
  359. data/lib/ddtrace/contrib/shoryuken/integration.rb +1 -0
  360. data/lib/ddtrace/contrib/shoryuken/patcher.rb +1 -0
  361. data/lib/ddtrace/contrib/shoryuken/tracer.rb +9 -2
  362. data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +1 -0
  363. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +2 -0
  364. data/lib/ddtrace/contrib/sidekiq/ext.rb +4 -0
  365. data/lib/ddtrace/contrib/sidekiq/integration.rb +11 -0
  366. data/lib/ddtrace/contrib/sidekiq/patcher.rb +27 -0
  367. data/lib/ddtrace/contrib/sidekiq/server_internal_tracer/heartbeat.rb +30 -0
  368. data/lib/ddtrace/contrib/sidekiq/server_internal_tracer/job_fetch.rb +30 -0
  369. data/lib/ddtrace/contrib/sidekiq/server_internal_tracer/scheduled_push.rb +29 -0
  370. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +6 -7
  371. data/lib/ddtrace/contrib/sidekiq/tracing.rb +1 -1
  372. data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +1 -0
  373. data/lib/ddtrace/contrib/sinatra/env.rb +4 -4
  374. data/lib/ddtrace/contrib/sinatra/ext.rb +1 -0
  375. data/lib/ddtrace/contrib/sinatra/headers.rb +2 -3
  376. data/lib/ddtrace/contrib/sinatra/integration.rb +1 -0
  377. data/lib/ddtrace/contrib/sinatra/patcher.rb +3 -1
  378. data/lib/ddtrace/contrib/sinatra/tracer.rb +28 -7
  379. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +13 -6
  380. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +2 -0
  381. data/lib/ddtrace/contrib/sneakers/ext.rb +12 -11
  382. data/lib/ddtrace/contrib/sneakers/integration.rb +1 -0
  383. data/lib/ddtrace/contrib/sneakers/patcher.rb +1 -0
  384. data/lib/ddtrace/contrib/sneakers/tracer.rb +17 -21
  385. data/lib/ddtrace/contrib/status_code_matcher.rb +70 -0
  386. data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +1 -0
  387. data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +5 -6
  388. data/lib/ddtrace/contrib/sucker_punch/ext.rb +1 -0
  389. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +5 -0
  390. data/lib/ddtrace/contrib/sucker_punch/integration.rb +1 -0
  391. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +2 -0
  392. data/lib/ddtrace/correlation.rb +3 -1
  393. data/lib/ddtrace/diagnostics/environment_logger.rb +9 -7
  394. data/lib/ddtrace/diagnostics/health.rb +1 -0
  395. data/lib/ddtrace/distributed_tracing/headers/b3.rb +1 -0
  396. data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +1 -0
  397. data/lib/ddtrace/distributed_tracing/headers/datadog.rb +1 -0
  398. data/lib/ddtrace/distributed_tracing/headers/headers.rb +2 -0
  399. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +2 -3
  400. data/lib/ddtrace/encoding.rb +3 -0
  401. data/lib/ddtrace/error.rb +78 -8
  402. data/lib/ddtrace/event.rb +1 -0
  403. data/lib/ddtrace/ext/analytics.rb +1 -0
  404. data/lib/ddtrace/ext/app_types.rb +1 -0
  405. data/lib/ddtrace/ext/correlation.rb +1 -0
  406. data/lib/ddtrace/ext/diagnostics.rb +1 -0
  407. data/lib/ddtrace/ext/distributed.rb +9 -2
  408. data/lib/ddtrace/ext/environment.rb +8 -0
  409. data/lib/ddtrace/ext/errors.rb +1 -0
  410. data/lib/ddtrace/ext/forced_tracing.rb +1 -0
  411. data/lib/ddtrace/ext/git.rb +32 -0
  412. data/lib/ddtrace/ext/http.rb +2 -1
  413. data/lib/ddtrace/ext/integration.rb +1 -0
  414. data/lib/ddtrace/ext/manual_tracing.rb +1 -0
  415. data/lib/ddtrace/ext/metrics.rb +1 -0
  416. data/lib/ddtrace/ext/net.rb +1 -0
  417. data/lib/ddtrace/ext/priority.rb +7 -4
  418. data/lib/ddtrace/ext/profiling.rb +53 -0
  419. data/lib/ddtrace/ext/runtime.rb +5 -7
  420. data/lib/ddtrace/ext/sampling.rb +1 -0
  421. data/lib/ddtrace/ext/sql.rb +1 -0
  422. data/lib/ddtrace/ext/test.rb +9 -0
  423. data/lib/ddtrace/ext/transport.rb +14 -0
  424. data/lib/ddtrace/forced_tracing.rb +3 -0
  425. data/lib/ddtrace/logger.rb +2 -1
  426. data/lib/ddtrace/metrics.rb +84 -24
  427. data/lib/ddtrace/opentelemetry/extensions.rb +2 -1
  428. data/lib/ddtrace/opentelemetry/span.rb +1 -0
  429. data/lib/ddtrace/opentracer/binary_propagator.rb +1 -0
  430. data/lib/ddtrace/opentracer/carrier.rb +1 -0
  431. data/lib/ddtrace/opentracer/distributed_headers.rb +4 -0
  432. data/lib/ddtrace/opentracer/global_tracer.rb +1 -0
  433. data/lib/ddtrace/opentracer/propagator.rb +1 -0
  434. data/lib/ddtrace/opentracer/rack_propagator.rb +1 -0
  435. data/lib/ddtrace/opentracer/scope.rb +1 -0
  436. data/lib/ddtrace/opentracer/scope_manager.rb +1 -0
  437. data/lib/ddtrace/opentracer/span.rb +3 -6
  438. data/lib/ddtrace/opentracer/span_context.rb +1 -0
  439. data/lib/ddtrace/opentracer/span_context_factory.rb +1 -0
  440. data/lib/ddtrace/opentracer/text_map_propagator.rb +1 -0
  441. data/lib/ddtrace/opentracer/thread_local_scope.rb +2 -0
  442. data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +1 -0
  443. data/lib/ddtrace/opentracer/tracer.rb +1 -0
  444. data/lib/ddtrace/opentracer.rb +21 -39
  445. data/lib/ddtrace/patcher.rb +28 -6
  446. data/lib/ddtrace/pin.rb +9 -61
  447. data/lib/ddtrace/pipeline/span_filter.rb +2 -1
  448. data/lib/ddtrace/pipeline/span_processor.rb +1 -0
  449. data/lib/ddtrace/pipeline.rb +1 -0
  450. data/lib/ddtrace/profiling/backtrace_location.rb +33 -0
  451. data/lib/ddtrace/profiling/buffer.rb +42 -0
  452. data/lib/ddtrace/profiling/collectors/stack.rb +297 -0
  453. data/lib/ddtrace/profiling/encoding/profile.rb +46 -0
  454. data/lib/ddtrace/profiling/event.rb +14 -0
  455. data/lib/ddtrace/profiling/events/stack.rb +81 -0
  456. data/lib/ddtrace/profiling/exporter.rb +24 -0
  457. data/lib/ddtrace/profiling/ext/forking.rb +98 -0
  458. data/lib/ddtrace/profiling/flush.rb +44 -0
  459. data/lib/ddtrace/profiling/native_extension.rb +40 -0
  460. data/lib/ddtrace/profiling/pprof/builder.rb +126 -0
  461. data/lib/ddtrace/profiling/pprof/converter.rb +103 -0
  462. data/lib/ddtrace/profiling/pprof/message_set.rb +15 -0
  463. data/lib/ddtrace/profiling/pprof/payload.rb +19 -0
  464. data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
  465. data/lib/ddtrace/profiling/pprof/pprof_pb.rb +82 -0
  466. data/lib/ddtrace/profiling/pprof/stack_sample.rb +140 -0
  467. data/lib/ddtrace/profiling/pprof/string_table.rb +11 -0
  468. data/lib/ddtrace/profiling/pprof/template.rb +119 -0
  469. data/lib/ddtrace/profiling/preload.rb +4 -0
  470. data/lib/ddtrace/profiling/profiler.rb +31 -0
  471. data/lib/ddtrace/profiling/recorder.rb +96 -0
  472. data/lib/ddtrace/profiling/scheduler.rb +150 -0
  473. data/lib/ddtrace/profiling/tasks/setup.rb +90 -0
  474. data/lib/ddtrace/profiling/trace_identifiers/ddtrace.rb +42 -0
  475. data/lib/ddtrace/profiling/trace_identifiers/helper.rb +46 -0
  476. data/lib/ddtrace/profiling/transport/client.rb +15 -0
  477. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +94 -0
  478. data/lib/ddtrace/profiling/transport/http/api/instance.rb +37 -0
  479. data/lib/ddtrace/profiling/transport/http/api/spec.rb +41 -0
  480. data/lib/ddtrace/profiling/transport/http/api.rb +44 -0
  481. data/lib/ddtrace/profiling/transport/http/builder.rb +29 -0
  482. data/lib/ddtrace/profiling/transport/http/client.rb +34 -0
  483. data/lib/ddtrace/profiling/transport/http/response.rb +22 -0
  484. data/lib/ddtrace/profiling/transport/http.rb +111 -0
  485. data/lib/ddtrace/profiling/transport/io/client.rb +28 -0
  486. data/lib/ddtrace/profiling/transport/io/response.rb +17 -0
  487. data/lib/ddtrace/profiling/transport/io.rb +31 -0
  488. data/lib/ddtrace/profiling/transport/parcel.rb +18 -0
  489. data/lib/ddtrace/profiling/transport/request.rb +16 -0
  490. data/lib/ddtrace/profiling/transport/response.rb +9 -0
  491. data/lib/ddtrace/profiling.rb +149 -0
  492. data/lib/ddtrace/propagation/grpc_propagator.rb +2 -0
  493. data/lib/ddtrace/propagation/http_propagator.rb +18 -2
  494. data/lib/ddtrace/quantization/hash.rb +1 -0
  495. data/lib/ddtrace/quantization/http.rb +4 -0
  496. data/lib/ddtrace/runtime/metrics.rb +35 -14
  497. data/lib/ddtrace/sampler.rb +20 -9
  498. data/lib/ddtrace/sampling/matcher.rb +1 -0
  499. data/lib/ddtrace/sampling/rate_limiter.rb +66 -16
  500. data/lib/ddtrace/sampling/rule.rb +2 -1
  501. data/lib/ddtrace/sampling/rule_sampler.rb +19 -11
  502. data/lib/ddtrace/sampling.rb +1 -0
  503. data/lib/ddtrace/span.rb +27 -14
  504. data/lib/ddtrace/sync_writer.rb +17 -15
  505. data/lib/ddtrace/tasks/exec.rb +47 -0
  506. data/lib/ddtrace/tasks/help.rb +15 -0
  507. data/lib/ddtrace/tracer.rb +61 -50
  508. data/lib/ddtrace/transport/http/adapters/net.rb +41 -11
  509. data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
  510. data/lib/ddtrace/transport/http/adapters/test.rb +5 -2
  511. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +26 -16
  512. data/lib/ddtrace/transport/http/api/endpoint.rb +1 -0
  513. data/lib/ddtrace/transport/http/api/fallbacks.rb +1 -0
  514. data/lib/ddtrace/transport/http/api/instance.rb +1 -0
  515. data/lib/ddtrace/transport/http/api/map.rb +1 -0
  516. data/lib/ddtrace/transport/http/api/spec.rb +1 -0
  517. data/lib/ddtrace/transport/http/api.rb +1 -0
  518. data/lib/ddtrace/transport/http/builder.rb +21 -7
  519. data/lib/ddtrace/transport/http/client.rb +3 -1
  520. data/lib/ddtrace/transport/http/env.rb +9 -0
  521. data/lib/ddtrace/transport/http/response.rb +1 -0
  522. data/lib/ddtrace/transport/http/statistics.rb +3 -2
  523. data/lib/ddtrace/transport/http/traces.rb +6 -6
  524. data/lib/ddtrace/transport/http.rb +48 -41
  525. data/lib/ddtrace/transport/io/client.rb +17 -9
  526. data/lib/ddtrace/transport/io/response.rb +2 -3
  527. data/lib/ddtrace/transport/io/traces.rb +10 -1
  528. data/lib/ddtrace/transport/io.rb +2 -1
  529. data/lib/ddtrace/transport/parcel.rb +7 -0
  530. data/lib/ddtrace/transport/request.rb +1 -0
  531. data/lib/ddtrace/transport/response.rb +1 -0
  532. data/lib/ddtrace/transport/statistics.rb +1 -0
  533. data/lib/ddtrace/transport/traces.rb +21 -3
  534. data/lib/ddtrace/utils/compression.rb +28 -0
  535. data/lib/ddtrace/utils/database.rb +1 -0
  536. data/lib/ddtrace/utils/forking.rb +53 -0
  537. data/lib/ddtrace/utils/object_set.rb +40 -0
  538. data/lib/ddtrace/utils/only_once.rb +41 -0
  539. data/lib/ddtrace/utils/sequence.rb +18 -0
  540. data/lib/ddtrace/utils/string_table.rb +46 -0
  541. data/lib/ddtrace/utils/time.rb +40 -3
  542. data/lib/ddtrace/utils.rb +23 -12
  543. data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
  544. data/lib/ddtrace/vendor/active_record/connection_specification.rb +1 -0
  545. data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
  546. data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +117 -0
  547. data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +58 -0
  548. data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +136 -0
  549. data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +10 -0
  550. data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +9 -0
  551. data/lib/ddtrace/vendor/multipart-post/multipart.rb +13 -0
  552. data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +33 -0
  553. data/lib/ddtrace/version.rb +16 -3
  554. data/lib/ddtrace/worker.rb +1 -0
  555. data/lib/ddtrace/workers/async.rb +15 -5
  556. data/lib/ddtrace/workers/{loop.rb → interval_loop.rb} +23 -12
  557. data/lib/ddtrace/workers/polling.rb +14 -6
  558. data/lib/ddtrace/workers/queue.rb +3 -1
  559. data/lib/ddtrace/workers/runtime_metrics.rb +22 -4
  560. data/lib/ddtrace/workers/trace_writer.rb +14 -16
  561. data/lib/ddtrace/workers.rb +8 -2
  562. data/lib/ddtrace/writer.rb +33 -8
  563. data/lib/ddtrace.rb +22 -48
  564. metadata +182 -405
  565. data/.circleci/config.yml +0 -548
  566. data/.circleci/images/primary/Dockerfile-2.0.0 +0 -73
  567. data/.circleci/images/primary/Dockerfile-2.1.10 +0 -73
  568. data/.circleci/images/primary/Dockerfile-2.2.10 +0 -73
  569. data/.circleci/images/primary/Dockerfile-2.3.8 +0 -75
  570. data/.circleci/images/primary/Dockerfile-2.4.6 +0 -73
  571. data/.circleci/images/primary/Dockerfile-2.5.6 +0 -73
  572. data/.circleci/images/primary/Dockerfile-2.6.4 +0 -73
  573. data/.circleci/images/primary/Dockerfile-2.7.0 +0 -73
  574. data/.circleci/images/primary/Dockerfile-jruby-9.2 +0 -77
  575. data/.dockerignore +0 -1
  576. data/.env +0 -26
  577. data/.github/CODEOWNERS +0 -1
  578. data/.gitlab-ci.yml +0 -27
  579. data/.rspec +0 -1
  580. data/.rubocop.yml +0 -85
  581. data/.simplecov +0 -38
  582. data/Appraisals +0 -1121
  583. data/Gemfile +0 -7
  584. data/Rakefile +0 -788
  585. data/benchmarks/postgres_database.yml +0 -9
  586. data/benchmarks/sidekiq_test.rb +0 -154
  587. data/docker-compose.yml +0 -370
  588. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  589. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  590. data/lib/ddtrace/augmentation/shim.rb +0 -102
  591. data/lib/ddtrace/augmentation.rb +0 -13
  592. data/lib/ddtrace/environment.rb +0 -41
  593. data/lib/ddtrace/monkey.rb +0 -58
  594. data/lib/ddtrace/runtime/cgroup.rb +0 -44
  595. data/lib/ddtrace/runtime/class_count.rb +0 -17
  596. data/lib/ddtrace/runtime/container.rb +0 -73
  597. data/lib/ddtrace/runtime/gc.rb +0 -16
  598. data/lib/ddtrace/runtime/identity.rb +0 -41
  599. data/lib/ddtrace/runtime/object_space.rb +0 -19
  600. data/lib/ddtrace/runtime/socket.rb +0 -14
  601. data/lib/ddtrace/runtime/thread_count.rb +0 -16
  602. data/tasks/release_gem.rake +0 -28
@@ -28,12 +28,15 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
28
28
  - [Integration instrumentation](#integration-instrumentation)
29
29
  - [Action Cable](#action-cable)
30
30
  - [Action View](#action-view)
31
+ - [Action Mailer](#action-mailer)
31
32
  - [Active Model Serializers](#active-model-serializers)
32
33
  - [Action Pack](#action-pack)
34
+ - [Active Job](#active-job)
33
35
  - [Active Record](#active-record)
34
36
  - [Active Support](#active-support)
35
37
  - [AWS](#aws)
36
38
  - [Concurrent Ruby](#concurrent-ruby)
39
+ - [Cucumber](#cucumber)
37
40
  - [Dalli](#dalli)
38
41
  - [DelayedJob](#delayedjob)
39
42
  - [Elasticsearch](#elasticsearch)
@@ -43,11 +46,14 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
43
46
  - [Grape](#grape)
44
47
  - [GraphQL](#graphql)
45
48
  - [gRPC](#grpc)
46
- - [http.rb](#http-rb)
49
+ - [http.rb](#httprb)
50
+ - [httpclient](#httpclient)
51
+ - [httpx](#httpx)
47
52
  - [MongoDB](#mongodb)
48
53
  - [MySQL2](#mysql2)
49
- - [Net/HTTP](#net-http)
54
+ - [Net/HTTP](#nethttp)
50
55
  - [Presto](#presto)
56
+ - [Qless](#qless)
51
57
  - [Que](#que)
52
58
  - [Racecar](#racecar)
53
59
  - [Rack](#rack)
@@ -56,6 +62,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
56
62
  - [Redis](#redis)
57
63
  - [Rest Client](#rest-client)
58
64
  - [Resque](#resque)
65
+ - [RSpec](#rspec)
59
66
  - [Shoryuken](#shoryuken)
60
67
  - [Sequel](#sequel)
61
68
  - [Sidekiq](#sidekiq)
@@ -66,7 +73,9 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
66
73
  - [Tracer settings](#tracer-settings)
67
74
  - [Custom logging](#custom-logging)
68
75
  - [Environment and tags](#environment-and-tags)
76
+ - [Environment variables](#environment-variables)
69
77
  - [Sampling](#sampling)
78
+ - [Application-side sampling](#application-side-sampling)
70
79
  - [Priority sampling](#priority-sampling)
71
80
  - [Distributed tracing](#distributed-tracing)
72
81
  - [HTTP request queuing](#http-request-queuing)
@@ -78,6 +87,12 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
78
87
  - [Metrics](#metrics)
79
88
  - [For application runtime](#for-application-runtime)
80
89
  - [OpenTracing](#opentracing)
90
+ - [Profiling](#profiling)
91
+ - [Troubleshooting](#troubleshooting)
92
+ - [Profiling Resque jobs](#profiling-resque-jobs)
93
+ - [Known issues and suggested configurations](#known-issues-and-suggested-configurations)
94
+ - [Payload too large](#payload-too-large)
95
+ - [Stack level too deep](#stack-level-too-deep)
81
96
 
82
97
  ## Compatibility
83
98
 
@@ -85,14 +100,15 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
85
100
 
86
101
  | Type | Documentation | Version | Support type | Gem version support |
87
102
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
88
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
103
+ | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
104
+ | | | 2.7 | Full | Latest |
89
105
  | | | 2.6 | Full | Latest |
90
106
  | | | 2.5 | Full | Latest |
91
107
  | | | 2.4 | Full | Latest |
92
108
  | | | 2.3 | Full | Latest |
93
109
  | | | 2.2 | Full | Latest |
94
110
  | | | 2.1 | Full | Latest |
95
- | | | 2.0 | Full | Latest |
111
+ | | | 2.0 | EOL since June 7th, 2021 | < 0.50.0 |
96
112
  | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
97
113
  | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
98
114
  | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
@@ -119,18 +135,51 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
119
135
 
120
136
  *EOL* indicates support is no longer provided.
121
137
 
138
+ ### Apple macOS support
139
+
140
+ Use of `ddtrace` on macOS is supported for development, but not for production deployments.
141
+
142
+ ### Microsoft Windows support
143
+
144
+ Using `ddtrace` on Microsoft Windows is currently unsupported. We'll still accept community contributions and issues,
145
+ but will consider them as having low priority.
146
+
122
147
  ## Installation
123
148
 
124
149
  The following steps will help you quickly start tracing your Ruby application.
125
150
 
126
- ### Setup the Datadog Agent
151
+ ### Configure the Datadog Agent for APM
152
+
153
+ Before downloading tracing on your application, [install the Datadog Agent on the host](https://docs.datadoghq.com/agent/). The Ruby APM tracer sends trace data through the Datadog Agent.
154
+
155
+ 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.
156
+
157
+ #### Containers
158
+
159
+ 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).
127
160
 
128
- Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
161
+ 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:
162
+
163
+ 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`.
129
164
 
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/).
131
165
 
132
166
  ### Quickstart for Rails applications
133
167
 
168
+ #### Automatic instrumentation
169
+
170
+ 1. Add the `ddtrace` gem to your Gemfile:
171
+
172
+ ```ruby
173
+ source 'https://rubygems.org'
174
+ gem 'ddtrace', require: 'ddtrace/auto_instrument'
175
+ ```
176
+
177
+ 2. Install the gem with `bundle install`
178
+
179
+ 3. You can configure, override, or disable any specific integration settings by also adding a Rails manual instrumentation configuration file (next).
180
+
181
+ #### Manual instrumentation
182
+
134
183
  1. Add the `ddtrace` gem to your Gemfile:
135
184
 
136
185
  ```ruby
@@ -152,6 +201,25 @@ Before downloading tracing on your application, install the Datadog Agent. The R
152
201
 
153
202
  ### Quickstart for Ruby applications
154
203
 
204
+ #### Automatic instrumentation
205
+
206
+ 1. Install the gem with `gem install ddtrace`
207
+ 2. Requiring any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
208
+ 3. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
209
+
210
+ ```ruby
211
+ # Example frameworks and libraries
212
+ require 'sinatra'
213
+ require 'faraday'
214
+ require 'redis'
215
+
216
+ require 'ddtrace/auto_instrument'
217
+ ```
218
+
219
+ You can configure, override, or disable any specific integration settings by also adding a Ruby manual configuration block (next).
220
+
221
+ #### Manual instrumentation
222
+
155
223
  1. Install the gem with `gem install ddtrace`
156
224
  2. Add a configuration block to your Ruby application:
157
225
 
@@ -226,7 +294,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
226
294
  | `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
295
  | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
228
296
  | `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` |
297
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
230
298
  | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
231
299
  | `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
300
 
@@ -331,13 +399,16 @@ For a list of available integrations, and their configuration options, please re
331
399
  | Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
332
400
  | ------------------------ | -------------------------- | ------------------------ | --------------------------| ----------------------------------- | ------------------------------------------------------------------------------ |
333
401
  | Action Cable | `action_cable` | `>= 5.0` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
402
+ | Action Mailer | `action_mailer` | `>= 5.0` | `>= 5.0` | *[Link](#action-mailer)* | *[Link](https://github.com/rails/rails/tree/master/actionmailer)* |
334
403
  | Action View | `action_view` | `>= 3.0` | `>= 3.0` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
335
404
  | Active Model Serializers | `active_model_serializers` | `>= 0.9` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
336
405
  | Action Pack | `action_pack` | `>= 3.0` | `>= 3.0` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
406
+ | Active Job | `active_job` | `>= 4.2` | `>= 4.2` | *[Link](#active-job)* | *[Link](https://github.com/rails/rails/tree/master/activejob)* |
337
407
  | Active Record | `active_record` | `>= 3.0` | `>= 3.0` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
338
408
  | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
339
409
  | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
340
410
  | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
411
+ | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
341
412
  | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
342
413
  | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
343
414
  | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
@@ -347,12 +418,16 @@ For a list of available integrations, and their configuration options, please re
347
418
  | Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
348
419
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
349
420
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
350
- | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
421
+ | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#httprb)* | *[Link](https://github.com/httprb/http)* |
422
+ | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
423
+ | httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
351
424
  | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
425
+ | Makara (through Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
352
426
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
353
427
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
354
428
  | 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
429
  | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
430
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
356
431
  | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
357
432
  | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
358
433
  | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
@@ -361,6 +436,7 @@ For a list of available integrations, and their configuration options, please re
361
436
  | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
362
437
  | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
363
438
  | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
439
+ | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
364
440
  | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
365
441
  | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
366
442
  | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
@@ -386,7 +462,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
386
462
 
387
463
  | Key | Description | Default |
388
464
  | --- | ----------- | ------- |
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
465
  | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
391
466
 
392
467
  ### Action View
@@ -406,10 +481,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
406
481
 
407
482
  | Key | Description | Default |
408
483
  | ---| --- | --- |
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
484
  | `service_name` | Service name used for rendering instrumentation. | `action_view` |
411
485
  | `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
486
 
487
+ ### Action Mailer
488
+
489
+ The Action Mailer integration provides tracing for Rails 5 ActionMailer actions.
490
+
491
+ You can enable it through `Datadog.configure`:
492
+
493
+ ```ruby
494
+ require 'ddtrace'
495
+ Datadog.configure do |c|
496
+ c.use :action_mailer, options
497
+ end
498
+ ```
499
+
500
+ Where `options` is an optional `Hash` that accepts the following parameters:
501
+
502
+ | Key | Description | Default |
503
+ | --- | ----------- | ------- |
504
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
505
+ | `service_name` | Service name used for `action_mailer` instrumentation | `'action_mailer'` |
506
+ | `email_data` | Whether or not to append additional email payload metadata to `action_mailer.deliver` spans. Fields include `['subject', 'to', 'from', 'bcc', 'cc', 'date', 'perform_deliveries']`. | `false` |
507
+
413
508
  ### Active Model Serializers
414
509
 
415
510
  The Active Model Serializers integration traces the `serialize` event for version 0.9+ and the `render` event for version 0.10+.
@@ -428,7 +523,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
428
523
 
429
524
  | Key | Description | Default |
430
525
  | --- | ----------- | ------- |
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
526
  | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
433
527
 
434
528
  ### Action Pack
@@ -448,9 +542,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
448
542
 
449
543
  | Key | Description | Default |
450
544
  | ---| --- | --- |
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
545
  | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
453
546
 
547
+ ### Active Job
548
+
549
+ Most of the time, Active Job is set up as part of Rails, but it can be activated separately:
550
+
551
+ ```ruby
552
+ require 'active_job'
553
+ require 'ddtrace'
554
+
555
+ Datadog.configure do |c|
556
+ c.use :active_job, options
557
+ end
558
+
559
+ ExampleJob.perform_later
560
+ ```
561
+
562
+ Where `options` is an optional `Hash` that accepts the following parameters:
563
+
564
+ | Key | Description | Default |
565
+ | --- | ----------- | ------- |
566
+ | `service_name` | Service name used for `active_job` instrumentation | `'active_job'` |
567
+ | `log_injection` | Automatically enables injection [Trace Correlation](#trace-correlation) information, such as `dd.trace_id`, into Active Job 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. | `false` |
568
+
454
569
  ### Active Record
455
570
 
456
571
  Most of the time, Active Record is set up as part of a web framework (Rails, Sinatra...) however, it can be set up alone:
@@ -476,7 +591,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
476
591
 
477
592
  | Key | Description | Default |
478
593
  | ---| --- | --- |
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
594
  | `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
595
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
482
596
 
@@ -495,16 +609,19 @@ Datadog.configure do |c|
495
609
  # Only available if you are using Rails with ActiveRecord.
496
610
  c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
497
611
 
612
+ # Block configuration pattern.
498
613
  c.use :active_record, describes: :secondary_database do |second_db|
499
614
  second_db.service_name = 'secondary-db'
500
615
  end
501
616
 
502
617
  # Connection string with the following connection settings:
503
- # Adapter, user, host, port, database
618
+ # adapter, username, host, port, database
619
+ # Other fields are ignored.
504
620
  c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
505
621
 
506
- # Hash with following connection settings
507
- # Adapter, user, host, port, database
622
+ # Hash with following connection settings:
623
+ # adapter, username, host, port, database
624
+ # Other fields are ignored.
508
625
  c.use :active_record, describes: {
509
626
  adapter: 'mysql2',
510
627
  host: '127.0.0.1',
@@ -513,9 +630,34 @@ Datadog.configure do |c|
513
630
  username: 'root'
514
631
  },
515
632
  service_name: 'secondary-db'
633
+
634
+ # If using the `makara` gem, it's possible to match on connection `role`:
635
+ c.use :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
636
+ c.use :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
637
+ end
638
+ ```
639
+
640
+ You can also create configurations based on partial matching of database connection fields:
641
+
642
+ ```ruby
643
+ Datadog.configure do |c|
644
+ # Matches any connection on host `127.0.0.1`.
645
+ c.use :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
646
+
647
+ # Matches any `mysql2` connection.
648
+ c.use :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
649
+
650
+ # Matches any `mysql2` connection to the `reports` database.
651
+ #
652
+ # In case of multiple matching `describe` configurations, the latest one applies.
653
+ # In this case a connection with both adapter `mysql` and database `reports`
654
+ # will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
655
+ c.use :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
516
656
  end
517
657
  ```
518
658
 
659
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
660
+
519
661
  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
662
 
521
663
  ### Active Support
@@ -538,7 +680,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
538
680
 
539
681
  | Key | Description | Default |
540
682
  | ---| --- | --- |
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
683
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
543
684
 
544
685
  ### AWS
@@ -561,7 +702,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
561
702
 
562
703
  | Key | Description | Default |
563
704
  | --- | ----------- | ------- |
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
705
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
566
706
 
567
707
  ### Concurrent Ruby
@@ -590,6 +730,41 @@ Where `options` is an optional `Hash` that accepts the following parameters:
590
730
  | --- | ----------- | ------- |
591
731
  | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
592
732
 
733
+ ### Cucumber
734
+
735
+ Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
736
+
737
+ To activate your integration, use the `Datadog.configure` method:
738
+
739
+ ```ruby
740
+ require 'cucumber'
741
+ require 'ddtrace'
742
+
743
+ # Configure default Cucumber integration
744
+ Datadog.configure do |c|
745
+ c.use :cucumber, options
746
+ end
747
+
748
+ # Example of how to attach tags from scenario to active span
749
+ Around do |scenario, block|
750
+ active_span = Datadog.configuration[:cucumber][:tracer].active_span
751
+ unless active_span.nil?
752
+ scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
753
+ active_span.set_tag(*tag.name.split(':', 2))
754
+ end
755
+ end
756
+ block.call
757
+ end
758
+ ```
759
+
760
+ Where `options` is an optional `Hash` that accepts the following parameters:
761
+
762
+ | Key | Description | Default |
763
+ | --- | ----------- | ------- |
764
+ | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
765
+ | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
766
+ | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
767
+
593
768
  ### Dalli
594
769
 
595
770
  Dalli integration will trace all calls to your `memcached` server:
@@ -612,7 +787,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
612
787
 
613
788
  | Key | Description | Default |
614
789
  | --- | ----------- | ------- |
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
790
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
617
791
 
618
792
  ### DelayedJob
@@ -633,9 +807,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
633
807
 
634
808
  | Key | Description | Default |
635
809
  | --- | ----------- | ------- |
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
810
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
638
811
  | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
812
+ | `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
813
 
640
814
  ### Elasticsearch
641
815
 
@@ -658,7 +832,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
658
832
 
659
833
  | Key | Description | Default |
660
834
  | --- | ----------- | ------- |
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
835
  | `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
836
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
664
837
 
@@ -684,7 +857,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
684
857
 
685
858
  | Key | Description | Default |
686
859
  | --- | ----------- | ------- |
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
860
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
689
861
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
690
862
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -716,7 +888,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
716
888
 
717
889
  | Key | Description | Default |
718
890
  | --- | ----------- | ------- |
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
891
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
721
892
  | `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
893
  | `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 +950,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
779
950
 
780
951
  | Key | Description | Default |
781
952
  | --- | ----------- | ------- |
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
953
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
784
954
  | `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
955
  | `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 +983,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
813
983
 
814
984
  | Key | Description | Default |
815
985
  | --- | ----------- | ------- |
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
986
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
818
987
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
988
+ | `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
989
 
820
990
  ### GraphQL
821
991
 
@@ -837,7 +1007,6 @@ The `use :graphql` method accepts the following parameters. Additional options c
837
1007
 
838
1008
  | Key | Description | Default |
839
1009
  | --- | ----------- | ------- |
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
1010
  | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
842
1011
  | `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
1012
 
@@ -916,8 +1085,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
916
1085
 
917
1086
  | Key | Description | Default |
918
1087
  | --- | ----------- | ------- |
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
1088
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
1089
+ | `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
1090
 
922
1091
  **Configuring clients to use different settings**
923
1092
 
@@ -958,11 +1127,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
958
1127
 
959
1128
  | Key | Description | Default |
960
1129
  | --- | ----------- | ------- |
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
1130
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
963
1131
  | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
964
1132
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
965
1133
 
1134
+ ### httpclient
1135
+
1136
+ The httpclient integration will trace any HTTP call using the httpclient gem.
1137
+
1138
+ ```ruby
1139
+ require 'httpclient'
1140
+ require 'ddtrace'
1141
+ Datadog.configure do |c|
1142
+ c.use :httpclient, options
1143
+ # optionally, specify a different service name for hostnames matching a regex
1144
+ c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1145
+ httpclient.service_name = 'user.example.com'
1146
+ httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1147
+ end
1148
+ end
1149
+ ```
1150
+
1151
+ Where `options` is an optional `Hash` that accepts the following parameters:
1152
+
1153
+ | Key | Description | Default |
1154
+ | --- | ----------- | ------- |
1155
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1156
+ | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1157
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1158
+
1159
+ ### httpx
1160
+
1161
+ `httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
1162
+
1163
+ ```ruby
1164
+ require "ddtrace"
1165
+ require "httpx/adapters/datadog"
1166
+
1167
+ Datadog.configure do |c|
1168
+ c.use :httpx
1169
+
1170
+ # optionally, specify a different service name for hostnames matching a regex
1171
+ c.use :httpx, describes: /user-[^.]+\.example\.com/ do |http|
1172
+ http.service_name = 'user.example.com'
1173
+ http.split_by_domain = false # Only necessary if split_by_domain is true by default
1174
+ end
1175
+ end
1176
+ ```
1177
+
966
1178
  ### Kafka
967
1179
 
968
1180
  The Kafka integration provides tracing of the `ruby-kafka` gem:
@@ -983,7 +1195,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
983
1195
 
984
1196
  | Key | Description | Default |
985
1197
  | --- | ----------- | ------- |
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
1198
  | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
988
1199
  | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
989
1200
 
@@ -1012,10 +1223,40 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1012
1223
 
1013
1224
  | Key | Description | Default |
1014
1225
  | --- | ----------- | ------- |
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
1226
  | `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
1227
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
1018
1228
 
1229
+ **Configuring trace settings per connection**
1230
+
1231
+ You can configure trace settings per connection by using the `describes` option:
1232
+
1233
+ ```ruby
1234
+ # Provide a `:describes` option with a connection key.
1235
+ # Any of the following keys are acceptable and equivalent to one another.
1236
+ # If a block is provided, it yields a Settings object that
1237
+ # accepts any of the configuration options listed above.
1238
+
1239
+ Datadog.configure do |c|
1240
+ # Network connection string
1241
+ c.use :mongo, describes: '127.0.0.1:27017', service_name: 'mongo-primary'
1242
+
1243
+ # Network connection regular expression
1244
+ c.use :mongo, describes: /localhost.*/, service_name: 'mongo-secondary'
1245
+ end
1246
+
1247
+ client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
1248
+ collection = client[:people]
1249
+ collection.insert_one({ name: 'Steve' })
1250
+ # Traced call will belong to `mongo-primary` service
1251
+
1252
+ client = Mongo::Client.new([ 'localhost:27017' ], :database => 'artists')
1253
+ collection = client[:people]
1254
+ collection.insert_one({ name: 'Steve' })
1255
+ # Traced call will belong to `mongo-secondary` service
1256
+ ```
1257
+
1258
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1259
+
1019
1260
  ### MySQL2
1020
1261
 
1021
1262
  The MySQL2 integration traces any SQL command sent through `mysql2` gem.
@@ -1036,7 +1277,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1036
1277
 
1037
1278
  | Key | Description | Default |
1038
1279
  | --- | ----------- | ------- |
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
1280
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1041
1281
 
1042
1282
  ### Net/HTTP
@@ -1069,7 +1309,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1069
1309
 
1070
1310
  | Key | Description | Default |
1071
1311
  | --- | ----------- | ------- |
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
1312
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1074
1313
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1075
1314
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -1110,9 +1349,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1110
1349
 
1111
1350
  | Key | Description | Default |
1112
1351
  | --- | ----------- | ------- |
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
1352
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1115
1353
 
1354
+ ### Qless
1355
+
1356
+ The Qless integration uses lifecycle hooks to trace job executions.
1357
+
1358
+ To add tracing to a Qless job:
1359
+
1360
+ ```ruby
1361
+ require 'ddtrace'
1362
+
1363
+ Datadog.configure do |c|
1364
+ c.use :qless, options
1365
+ end
1366
+ ```
1367
+
1368
+ Where `options` is an optional `Hash` that accepts the following parameters:
1369
+
1370
+ | Key | Description | Default |
1371
+ | --- | ----------- | ------- |
1372
+ | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1373
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1374
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1375
+
1116
1376
  ### Que
1117
1377
 
1118
1378
  The Que integration is a middleware which will trace job executions.
@@ -1131,11 +1391,11 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1131
1391
 
1132
1392
  | Key | Description | Default |
1133
1393
  | --- | ----------- | ------- |
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
1394
  | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1136
1395
  | `service_name` | Service name used for `que` instrumentation | `'que'` |
1137
1396
  | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1138
1397
  | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1398
+ | `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
1399
 
1140
1400
  ### Racecar
1141
1401
 
@@ -1155,7 +1415,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1155
1415
 
1156
1416
  | Key | Description | Default |
1157
1417
  | --- | ----------- | ------- |
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
1418
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1160
1419
 
1161
1420
  ### Rack
@@ -1185,11 +1444,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1185
1444
 
1186
1445
  | Key | Description | Default |
1187
1446
  | --- | ----------- | ------- |
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
1447
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1190
1448
  | `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
1449
  | `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` |
1450
+ | `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
1451
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1194
1452
  | `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
1453
  | `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,12 +1506,12 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1248
1506
 
1249
1507
  | Key | Description | Default |
1250
1508
  | --- | ----------- | ------- |
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
1509
  | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1253
1510
  | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1254
1511
  | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
1255
1512
  | `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` |
1256
1513
  | `exception_controller` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | `nil` |
1514
+ | `job_service` | Service name used when tracing ActiveJob activity. | `<app_name>-active_job` |
1257
1515
  | `middleware` | Add the trace middleware to the Rails application. Set to `false` if you don't want the middleware to load. | `true` |
1258
1516
  | `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
1259
1517
  | `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
@@ -1264,12 +1522,12 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1264
1522
 
1265
1523
  | MRI Versions | JRuby Versions | Rails Versions |
1266
1524
  | ------------- | -------------- | -------------- |
1267
- | 2.0 | | 3.0 - 3.2 |
1268
1525
  | 2.1 | | 3.0 - 4.2 |
1269
1526
  | 2.2 - 2.3 | | 3.0 - 5.2 |
1270
1527
  | 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 |
1528
+ | 2.5 | | 4.2.8 - 6.1 |
1529
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1530
+ | 3.0 | | 6.1 |
1273
1531
 
1274
1532
  ### Rake
1275
1533
 
@@ -1297,7 +1555,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1297
1555
 
1298
1556
  | Key | Description | Default |
1299
1557
  | --- | ----------- | ------- |
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
1558
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1302
1559
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1303
1560
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
@@ -1357,8 +1614,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1357
1614
 
1358
1615
  | Key | Description | Default |
1359
1616
  | --- | ----------- | ------- |
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
1617
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1618
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1362
1619
 
1363
1620
  You can also set *per-instance* configuration as it follows:
1364
1621
 
@@ -1396,12 +1653,17 @@ Datadog.configure do |c|
1396
1653
  # The default configuration for any redis client
1397
1654
  c.use :redis, service_name: 'redis-default'
1398
1655
 
1399
- # The configuration matching a given unix socket
1656
+ # The configuration matching a given unix socket.
1400
1657
  c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1401
1658
 
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
1659
+ # For network connections, only these fields are considered during matching:
1660
+ # scheme, host, port, db
1661
+ # Other fields are ignored.
1662
+
1663
+ # Network connection string
1664
+ c.use :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
1665
+ c.use :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
1666
+ # Network client hash
1405
1667
  c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1406
1668
  # Only a subset of the connection hash
1407
1669
  c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
@@ -1409,6 +1671,8 @@ Datadog.configure do |c|
1409
1671
  end
1410
1672
  ```
1411
1673
 
1674
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1675
+
1412
1676
  ### Resque
1413
1677
 
1414
1678
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1416,16 +1680,11 @@ The Resque integration uses Resque hooks that wraps the `perform` method.
1416
1680
  To add tracing to a Resque job:
1417
1681
 
1418
1682
  ```ruby
1683
+ require 'resque'
1419
1684
  require 'ddtrace'
1420
1685
 
1421
- class MyJob
1422
- def self.perform(*args)
1423
- # do_something
1424
- end
1425
- end
1426
-
1427
1686
  Datadog.configure do |c|
1428
- c.use :resque, options
1687
+ c.use :resque, **options
1429
1688
  end
1430
1689
  ```
1431
1690
 
@@ -1433,9 +1692,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1433
1692
 
1434
1693
  | Key | Description | Default |
1435
1694
  | --- | ----------- | ------- |
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
1695
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1438
- | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1696
+ | `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? }` |
1697
+ | `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
1698
 
1440
1699
  ### Rest Client
1441
1700
 
@@ -1454,10 +1713,33 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1454
1713
 
1455
1714
  | Key | Description | Default |
1456
1715
  | --- | ----------- | ------- |
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
1716
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1459
1717
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1460
1718
 
1719
+ ### RSpec
1720
+
1721
+ RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1722
+
1723
+ To activate your integration, use the `Datadog.configure` method:
1724
+
1725
+ ```ruby
1726
+ require 'rspec'
1727
+ require 'ddtrace'
1728
+
1729
+ # Configure default RSpec integration
1730
+ Datadog.configure do |c|
1731
+ c.use :rspec, options
1732
+ end
1733
+ ```
1734
+
1735
+ Where `options` is an optional `Hash` that accepts the following parameters:
1736
+
1737
+ | Key | Description | Default |
1738
+ | --- | ----------- | ------- |
1739
+ | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1740
+ | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1741
+ | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1742
+
1461
1743
  ### Sequel
1462
1744
 
1463
1745
  The Sequel integration traces queries made to your database.
@@ -1488,11 +1770,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1488
1770
 
1489
1771
  | Key | Description | Default |
1490
1772
  | --- | ----------- | ------- |
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
1773
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1493
1774
 
1494
- Only Ruby 2.0+ is supported.
1495
-
1496
1775
  **Configuring databases to use different settings**
1497
1776
 
1498
1777
  If you use multiple databases with Sequel, you can give each of them different settings by configuring their respective `Sequel::Database` objects:
@@ -1524,8 +1803,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1524
1803
 
1525
1804
  | Key | Description | Default |
1526
1805
  | --- | ----------- | ------- |
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
1806
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1807
+ | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1808
+ | `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
1809
 
1530
1810
  ### Sidekiq
1531
1811
 
@@ -1545,10 +1825,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1545
1825
 
1546
1826
  | Key | Description | Default |
1547
1827
  | --- | ----------- | ------- |
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
1828
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1550
1829
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1551
1830
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1831
+ | `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
1832
 
1553
1833
  ### Sinatra
1554
1834
 
@@ -1608,7 +1888,6 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
1608
1888
 
1609
1889
  | Key | Description | Default |
1610
1890
  | --- | ----------- | ------- |
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
1891
  | `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
1892
  | `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
1893
  | `resource_script_names` | Prepend resource names with script name | `false` |
@@ -1632,10 +1911,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1632
1911
 
1633
1912
  | Key | Description | Default |
1634
1913
  | --- | ----------- | ------- |
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
1914
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1637
1915
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1638
1916
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1917
+ | `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
1918
 
1640
1919
  ### Sucker Punch
1641
1920
 
@@ -1656,7 +1935,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1656
1935
 
1657
1936
  | Key | Description | Default |
1658
1937
  | --- | ----------- | ------- |
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
1938
  | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1661
1939
 
1662
1940
  ## Advanced configuration
@@ -1672,13 +1950,20 @@ Datadog.configure do |c|
1672
1950
  c.tracer.enabled = true
1673
1951
  c.tracer.hostname = 'my-agent'
1674
1952
  c.tracer.port = 8126
1675
- c.tracer.partial_flush.enabled = false
1953
+
1954
+ # Ensure all traces are ingested by Datadog
1955
+ c.sampling.default_rate = 1.0 # Recommended
1956
+ c.sampling.rate_limit = 200
1957
+ # or provide a custom implementation (overrides c.sampling settings)
1676
1958
  c.tracer.sampler = Datadog::AllSampler.new
1677
1959
 
1678
- # OR for advanced use cases, you can specify your own tracer:
1960
+ # Breaks down very large traces into smaller batches
1961
+ c.tracer.partial_flush.enabled = false
1962
+
1963
+ # You can specify your own tracer
1679
1964
  c.tracer.instance = Datadog::Tracer.new
1680
1965
 
1681
- # To enable debug mode:
1966
+ # To enable debug mode
1682
1967
  c.diagnostics.debug = true
1683
1968
  end
1684
1969
  ```
@@ -1690,9 +1975,12 @@ Available options are:
1690
1975
  - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1691
1976
  - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1692
1977
  - `port`: set the port the trace agent is listening on.
1978
+ - `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.
1979
+ - `sampling.rate_limit`: maximum number of traces per second to sample. Defaults to 100 per second.
1693
1980
  - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1694
1981
  - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1695
1982
  - `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
1983
+ - `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
1984
 
1697
1985
  #### Custom logging
1698
1986
 
@@ -1746,13 +2034,22 @@ Other Environment Variables:
1746
2034
 
1747
2035
  - `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
2036
  - `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`.
2037
+ - `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
2038
  - `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
2039
 
1753
2040
  ### Sampling
1754
2041
 
1755
- `ddtrace` can perform trace sampling. While the trace agent already samples traces to reduce bandwidth usage, client sampling reduces the performance overhead.
2042
+ 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/).
2043
+
2044
+ We recommend setting the environment variable `DD_TRACE_SAMPLE_RATE=1.0` in all new applications using `ddtrace`.
2045
+
2046
+ 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/).
2047
+
2048
+ #### Application-side sampling
2049
+
2050
+ While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
2051
+
2052
+ This will **reduce visibility and is not recommended**. See [DD_TRACE_SAMPLE_RATE](#environment-variables) for the recommended sampling approach.
1756
2053
 
1757
2054
  `Datadog::RateSampler` samples a ratio of the traces. For example:
1758
2055
 
@@ -1910,12 +2207,14 @@ For more details on how to activate distributed tracing for integrations, see th
1910
2207
 
1911
2208
  - [Excon](#excon)
1912
2209
  - [Faraday](#faraday)
1913
- - [Rest Client](#restclient)
2210
+ - [Rest Client](#rest-client)
1914
2211
  - [Net/HTTP](#nethttp)
1915
2212
  - [Rack](#rack)
1916
2213
  - [Rails](#rails)
1917
2214
  - [Sinatra](#sinatra)
1918
- - [http.rb](#http-rb)
2215
+ - [http.rb](#httprb)
2216
+ - [httpclient](#httpclient)
2217
+ - [httpx](#httpx)
1919
2218
 
1920
2219
  **Using the HTTP propagator**
1921
2220
 
@@ -1944,9 +2243,7 @@ end
1944
2243
 
1945
2244
  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
2245
 
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:
2246
+ 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
2247
 
1951
2248
  ```
1952
2249
  # /etc/nginx/conf.d/ruby_service.conf
@@ -1960,9 +2257,7 @@ server {
1960
2257
  }
1961
2258
  ```
1962
2259
 
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.
2260
+ 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
2261
 
1967
2262
  ### Processing Pipeline
1968
2263
 
@@ -2035,7 +2330,7 @@ In many cases, such as logging, it may be useful to correlate trace IDs to other
2035
2330
 
2036
2331
  ##### Automatic
2037
2332
 
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`:
2333
+ 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
2334
 
2040
2335
  ```ruby
2041
2336
  # config/initializers/datadog.rb
@@ -2046,11 +2341,9 @@ Datadog.configure do |c|
2046
2341
  end
2047
2342
  ```
2048
2343
 
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
2344
  ##### Manual (Lograge)
2052
2345
 
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.
2346
+ 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
2347
 
2055
2348
  ```ruby
2056
2349
  config.lograge.custom_options = lambda do |event|
@@ -2137,7 +2430,9 @@ Datadog.tracer.trace('my.operation') { logger.warn('This is a traced operation.'
2137
2430
 
2138
2431
  ### Configuring the transport layer
2139
2432
 
2140
- By default, the tracer submits trace data using `Net::HTTP` to `127.0.0.1:8126`, the default location for the Datadog trace agent process. However, the tracer can be configured to send its trace data to alternative destinations, or by alternative protocols.
2433
+ By default, the tracer submits trace data using the Unix socket `/var/run/datadog/apm.socket`, if one is created by the Agent. Otherwise, it connects via HTTP to `127.0.0.1:8126`, the default TCP location the Agent listens on.
2434
+
2435
+ However, the tracer can be configured to send its trace data to alternative destinations, or by alternative protocols.
2141
2436
 
2142
2437
  Some basic settings, such as hostname and port, can be configured using [tracer settings](#tracer-settings).
2143
2438
 
@@ -2163,7 +2458,7 @@ To use, first configure your trace agent to listen by Unix socket, then configur
2163
2458
  ```ruby
2164
2459
  Datadog.configure do |c|
2165
2460
  c.tracer.transport_options = proc { |t|
2166
- # Provide filepath to trace agent Unix socket
2461
+ # Provide local path to trace agent Unix socket
2167
2462
  t.adapter :unix, '/tmp/ddagent/trace.sock'
2168
2463
  }
2169
2464
  end
@@ -2207,7 +2502,7 @@ The tracer and its integrations can produce some additional metrics that can pro
2207
2502
  To configure your application for metrics collection:
2208
2503
 
2209
2504
  1. [Configure your Datadog agent for StatsD](https://docs.datadoghq.com/developers/dogstatsd/#setup)
2210
- 2. Add `gem 'dogstatsd-ruby'` to your Gemfile
2505
+ 2. Add `gem 'dogstatsd-ruby', '~> 5.3'` to your Gemfile
2211
2506
 
2212
2507
  #### For application runtime
2213
2508
 
@@ -2236,11 +2531,13 @@ See the [Dogstatsd documentation](https://www.rubydoc.info/github/DataDog/dogsta
2236
2531
 
2237
2532
  The stats are VM specific and will include:
2238
2533
 
2239
- | Name | Type | Description |
2240
- | -------------------------- | ------- | -------------------------------------------------------- |
2241
- | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. |
2242
- | `runtime.ruby.thread_count` | `gauge` | Number of threads. |
2243
- | `runtime.ruby.gc.*`. | `gauge` | Garbage collection statistics: collected from `GC.stat`. |
2534
+ | Name | Type | Description | Available on |
2535
+ | -------------------------- | ------- | -------------------------------------------------------- | ------------ |
2536
+ | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. | CRuby |
2537
+ | `runtime.ruby.gc.*` | `gauge` | Garbage collection statistics: collected from `GC.stat`. | All runtimes |
2538
+ | `runtime.ruby.thread_count` | `gauge` | Number of threads. | All runtimes |
2539
+ | `runtime.ruby.global_constant_state` | `gauge` | Global constant cache generation. | CRuby |
2540
+ | `runtime.ruby.global_method_state` | `gauge` | [Global method cache generation.](https://tenderlovemaking.com/2015/12/23/inline-caching-in-mri.html) | [CRuby < 3.0.0](https://docs.ruby-lang.org/en/3.0.0/NEWS_md.html#label-Implementation+improvements) |
2244
2541
 
2245
2542
  In addition, all metrics include the following tags:
2246
2543
 
@@ -2277,3 +2574,53 @@ However, additional instrumentation provided by Datadog can be activated alongsi
2277
2574
  | `OpenTracing::FORMAT_TEXT_MAP` | Yes | |
2278
2575
  | `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
2576
  | `OpenTracing::FORMAT_BINARY` | No | |
2577
+
2578
+ ### Profiling
2579
+
2580
+ *Currently available as BETA feature.*
2581
+
2582
+ `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.
2583
+
2584
+ **Setup**
2585
+
2586
+ To get started with profiling, follow the [Enabling the Ruby Profiler](https://docs.datadoghq.com/tracing/profiler/enabling/ruby/) guide.
2587
+
2588
+ #### Troubleshooting
2589
+
2590
+ If you run into issues with profiling, please check the [Profiler Troubleshooting Guide](https://docs.datadoghq.com/tracing/profiler/profiler_troubleshooting/?code-lang=ruby).
2591
+
2592
+ #### Profiling Resque jobs
2593
+
2594
+ 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.
2595
+
2596
+ 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.
2597
+
2598
+ ## Known issues and suggested configurations
2599
+
2600
+ ### Payload too large
2601
+
2602
+ 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.
2603
+
2604
+ If traces are missing, enable [debug mode](#tracer-settings) to check if messages containing `"Dropping trace. Payload too large"` are logged.
2605
+
2606
+ 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.
2607
+
2608
+ 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.
2609
+
2610
+ ### Stack level too deep
2611
+
2612
+ 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.
2613
+
2614
+ 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.)
2615
+
2616
+ 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.
2617
+
2618
+ 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.
2619
+
2620
+ As the implementation of `alias_method` exists within those libraries, Datadog generally cannot fix them. However, some libraries have known workarounds:
2621
+
2622
+ * `rack-mini-profiler`: [Net::HTTP stack level too deep errors](https://github.com/MiniProfiler/rack-mini-profiler#nethttp-stack-level-too-deep-errors).
2623
+
2624
+ For libraries without a known workaround, consider removing the library using `alias` or `Module#alias_method` or separating libraries into different environments for testing.
2625
+
2626
+ For any further questions or to report an occurence of this issue, please [reach out to Datadog support](https://docs.datadoghq.com/help)