ddtrace 0.43.0 → 0.48.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +278 -139
  3. data/.circleci/images/primary/Dockerfile-2.0.0 +11 -1
  4. data/.circleci/images/primary/Dockerfile-2.1.10 +11 -1
  5. data/.circleci/images/primary/Dockerfile-2.2.10 +11 -1
  6. data/.circleci/images/primary/Dockerfile-2.3.8 +10 -0
  7. data/.circleci/images/primary/Dockerfile-2.4.6 +10 -0
  8. data/.circleci/images/primary/Dockerfile-2.5.6 +10 -0
  9. data/.circleci/images/primary/Dockerfile-2.6.4 +10 -0
  10. data/.circleci/images/primary/Dockerfile-2.7.0 +10 -0
  11. data/.circleci/images/primary/Dockerfile-3.0.0 +73 -0
  12. data/.circleci/images/primary/Dockerfile-jruby-9.2-latest +88 -0
  13. data/.circleci/images/primary/{Dockerfile-jruby-9.2 → Dockerfile-jruby-9.2.0.0} +1 -5
  14. data/.circleci/images/primary/Dockerfile-truffleruby-21.0.0 +73 -0
  15. data/.github/workflows/add-milestone-to-pull-requests.yml +1 -1
  16. data/.github/workflows/create-next-milestone.yml +2 -2
  17. data/.gitlab-ci.yml +18 -18
  18. data/.rubocop.yml +269 -7
  19. data/.rubocop_todo.yml +438 -0
  20. data/.simplecov +10 -1
  21. data/Appraisals +285 -15
  22. data/CHANGELOG.md +1243 -377
  23. data/Gemfile +65 -3
  24. data/LICENSE-3rdparty.csv +2 -0
  25. data/README.md +1 -0
  26. data/Rakefile +186 -29
  27. data/bin/ddtracerb +15 -0
  28. data/ddtrace.gemspec +7 -37
  29. data/docker-compose.yml +105 -7
  30. data/docs/DevelopmentGuide.md +28 -0
  31. data/docs/GettingStarted.md +208 -75
  32. data/docs/ProfilingDevelopment.md +88 -0
  33. data/integration/README.md +67 -0
  34. data/integration/apps/rack/.dockerignore +1 -0
  35. data/integration/apps/rack/.envrc.sample +1 -0
  36. data/integration/apps/rack/.gitignore +4 -0
  37. data/integration/apps/rack/.rspec +1 -0
  38. data/integration/apps/rack/Dockerfile +28 -0
  39. data/integration/apps/rack/Dockerfile-ci +11 -0
  40. data/integration/apps/rack/Gemfile +24 -0
  41. data/integration/apps/rack/README.md +93 -0
  42. data/integration/apps/rack/app/acme.rb +80 -0
  43. data/integration/apps/rack/app/datadog.rb +17 -0
  44. data/integration/apps/rack/bin/run +22 -0
  45. data/integration/apps/rack/bin/setup +17 -0
  46. data/integration/apps/rack/bin/test +24 -0
  47. data/integration/apps/rack/config.ru +6 -0
  48. data/integration/apps/rack/config/puma.rb +14 -0
  49. data/integration/apps/rack/config/unicorn.rb +23 -0
  50. data/integration/apps/rack/docker-compose.ci.yml +62 -0
  51. data/integration/apps/rack/docker-compose.yml +78 -0
  52. data/integration/apps/rack/script/build-images +38 -0
  53. data/integration/apps/rack/script/ci +50 -0
  54. data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
  55. data/integration/apps/rack/spec/spec_helper.rb +16 -0
  56. data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
  57. data/integration/apps/rails-five/.dockerignore +1 -0
  58. data/integration/apps/rails-five/.env +3 -0
  59. data/integration/apps/rails-five/.envrc.sample +1 -0
  60. data/integration/apps/rails-five/.gitignore +30 -0
  61. data/integration/apps/rails-five/Dockerfile +25 -0
  62. data/integration/apps/rails-five/Dockerfile-ci +11 -0
  63. data/integration/apps/rails-five/Gemfile +104 -0
  64. data/integration/apps/rails-five/README.md +94 -0
  65. data/integration/apps/rails-five/Rakefile +6 -0
  66. data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
  67. data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
  68. data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
  69. data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
  70. data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
  71. data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
  72. data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
  73. data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
  74. data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
  75. data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
  76. data/integration/apps/rails-five/app/models/application_record.rb +3 -0
  77. data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
  78. data/integration/apps/rails-five/app/models/test.rb +2 -0
  79. data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
  80. data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
  81. data/integration/apps/rails-five/bin/bundle +3 -0
  82. data/integration/apps/rails-five/bin/rails +9 -0
  83. data/integration/apps/rails-five/bin/rake +9 -0
  84. data/integration/apps/rails-five/bin/run +24 -0
  85. data/integration/apps/rails-five/bin/setup +27 -0
  86. data/integration/apps/rails-five/bin/spring +17 -0
  87. data/integration/apps/rails-five/bin/test +21 -0
  88. data/integration/apps/rails-five/bin/update +28 -0
  89. data/integration/apps/rails-five/config.ru +5 -0
  90. data/integration/apps/rails-five/config/application.rb +97 -0
  91. data/integration/apps/rails-five/config/boot.rb +4 -0
  92. data/integration/apps/rails-five/config/cable.yml +10 -0
  93. data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
  94. data/integration/apps/rails-five/config/database.yml +28 -0
  95. data/integration/apps/rails-five/config/environment.rb +5 -0
  96. data/integration/apps/rails-five/config/environments/development.rb +51 -0
  97. data/integration/apps/rails-five/config/environments/production.rb +82 -0
  98. data/integration/apps/rails-five/config/environments/test.rb +43 -0
  99. data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
  100. data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
  101. data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
  102. data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
  103. data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
  104. data/integration/apps/rails-five/config/locales/en.yml +33 -0
  105. data/integration/apps/rails-five/config/puma.rb +24 -0
  106. data/integration/apps/rails-five/config/routes.rb +11 -0
  107. data/integration/apps/rails-five/config/spring.rb +6 -0
  108. data/integration/apps/rails-five/config/unicorn.rb +29 -0
  109. data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
  110. data/integration/apps/rails-five/db/schema.rb +23 -0
  111. data/integration/apps/rails-five/db/seeds.rb +7 -0
  112. data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
  113. data/integration/apps/rails-five/docker-compose.yml +100 -0
  114. data/integration/apps/rails-five/lib/tasks/.keep +0 -0
  115. data/integration/apps/rails-five/log/.keep +0 -0
  116. data/integration/apps/rails-five/public/robots.txt +1 -0
  117. data/integration/apps/rails-five/script/build-images +35 -0
  118. data/integration/apps/rails-five/script/ci +50 -0
  119. data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
  120. data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
  121. data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
  122. data/integration/apps/rails-five/storage/.keep +0 -0
  123. data/integration/apps/rails-five/tmp/.keep +0 -0
  124. data/integration/apps/rails-five/vendor/.keep +0 -0
  125. data/integration/apps/ruby/.dockerignore +1 -0
  126. data/integration/apps/ruby/.envrc.sample +1 -0
  127. data/integration/apps/ruby/.gitignore +2 -0
  128. data/integration/apps/ruby/Dockerfile +25 -0
  129. data/integration/apps/ruby/Dockerfile-ci +11 -0
  130. data/integration/apps/ruby/Gemfile +11 -0
  131. data/integration/apps/ruby/README.md +70 -0
  132. data/integration/apps/ruby/agent.yaml +3 -0
  133. data/integration/apps/ruby/app/datadog.rb +13 -0
  134. data/integration/apps/ruby/app/fibonacci.rb +58 -0
  135. data/integration/apps/ruby/bin/run +20 -0
  136. data/integration/apps/ruby/bin/setup +17 -0
  137. data/integration/apps/ruby/bin/test +21 -0
  138. data/integration/apps/ruby/docker-compose.ci.yml +51 -0
  139. data/integration/apps/ruby/docker-compose.yml +63 -0
  140. data/integration/apps/ruby/script/build-images +38 -0
  141. data/integration/apps/ruby/script/ci +50 -0
  142. data/integration/images/agent/Dockerfile +2 -0
  143. data/integration/images/agent/agent.yaml +3 -0
  144. data/integration/images/include/datadog/analyzer.rb +71 -0
  145. data/integration/images/include/datadog/demo_env.rb +101 -0
  146. data/integration/images/include/http-health-check +33 -0
  147. data/integration/images/ruby/2.0/Dockerfile +54 -0
  148. data/integration/images/ruby/2.1/Dockerfile +54 -0
  149. data/integration/images/ruby/2.2/Dockerfile +54 -0
  150. data/integration/images/ruby/2.3/Dockerfile +70 -0
  151. data/integration/images/ruby/2.4/Dockerfile +54 -0
  152. data/integration/images/ruby/2.5/Dockerfile +54 -0
  153. data/integration/images/ruby/2.6/Dockerfile +54 -0
  154. data/integration/images/ruby/2.7/Dockerfile +54 -0
  155. data/integration/images/ruby/3.0/Dockerfile +54 -0
  156. data/integration/images/wrk/Dockerfile +33 -0
  157. data/integration/images/wrk/scripts/entrypoint.sh +17 -0
  158. data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
  159. data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
  160. data/integration/script/build-images +43 -0
  161. data/lib/ddtrace.rb +9 -5
  162. data/lib/ddtrace/analytics.rb +2 -0
  163. data/lib/ddtrace/auto_instrument.rb +3 -0
  164. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  165. data/lib/ddtrace/buffer.rb +4 -4
  166. data/lib/ddtrace/configuration.rb +121 -26
  167. data/lib/ddtrace/configuration/base.rb +1 -1
  168. data/lib/ddtrace/configuration/components.rb +87 -5
  169. data/lib/ddtrace/configuration/option_definition.rb +1 -3
  170. data/lib/ddtrace/configuration/options.rb +4 -7
  171. data/lib/ddtrace/configuration/settings.rb +48 -3
  172. data/lib/ddtrace/context.rb +5 -6
  173. data/lib/ddtrace/context_provider.rb +0 -1
  174. data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
  175. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  176. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
  177. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  178. data/lib/ddtrace/contrib/action_view/event.rb +1 -5
  179. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  180. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  181. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  182. data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
  183. data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +30 -0
  184. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +107 -18
  185. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  186. data/lib/ddtrace/contrib/active_record/utils.rb +68 -21
  187. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  188. data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -1
  189. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
  190. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
  191. data/lib/ddtrace/contrib/auto_instrument.rb +49 -0
  192. data/lib/ddtrace/contrib/aws/patcher.rb +1 -0
  193. data/lib/ddtrace/contrib/aws/services.rb +3 -0
  194. data/lib/ddtrace/contrib/configurable.rb +63 -39
  195. data/lib/ddtrace/contrib/configuration/resolver.rb +70 -5
  196. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +20 -19
  197. data/lib/ddtrace/contrib/configuration/settings.rb +7 -6
  198. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
  199. data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
  200. data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
  201. data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
  202. data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
  203. data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
  204. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -0
  205. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
  206. data/lib/ddtrace/contrib/ethon/easy_patch.rb +11 -10
  207. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  208. data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
  209. data/lib/ddtrace/contrib/extensions.rb +53 -3
  210. data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
  211. data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
  212. data/lib/ddtrace/contrib/grape/endpoint.rb +37 -26
  213. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  214. data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
  215. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
  216. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
  217. data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
  218. data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
  219. data/lib/ddtrace/contrib/http/instrumentation.rb +5 -5
  220. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  221. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  222. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +147 -0
  223. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  224. data/lib/ddtrace/contrib/httpclient/patcher.rb +38 -0
  225. data/lib/ddtrace/contrib/httprb/instrumentation.rb +15 -21
  226. data/lib/ddtrace/contrib/httprb/patcher.rb +5 -2
  227. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
  228. data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
  229. data/lib/ddtrace/contrib/patchable.rb +18 -7
  230. data/lib/ddtrace/contrib/patcher.rb +9 -6
  231. data/lib/ddtrace/contrib/presto/patcher.rb +5 -2
  232. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  233. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  234. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  235. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  236. data/lib/ddtrace/contrib/qless/qless_job.rb +73 -0
  237. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +33 -0
  238. data/lib/ddtrace/contrib/que/ext.rb +19 -19
  239. data/lib/ddtrace/contrib/que/tracer.rb +1 -1
  240. data/lib/ddtrace/contrib/racecar/event.rb +1 -0
  241. data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
  242. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  243. data/lib/ddtrace/contrib/rack/middlewares.rb +6 -11
  244. data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
  245. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  246. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  247. data/lib/ddtrace/contrib/rails/patcher.rb +6 -2
  248. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  249. data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
  250. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  251. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +14 -5
  252. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  253. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  254. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  255. data/lib/ddtrace/contrib/redis/quantize.rb +28 -0
  256. data/lib/ddtrace/contrib/redis/tags.rb +5 -1
  257. data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
  258. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
  259. data/lib/ddtrace/contrib/registry.rb +2 -2
  260. data/lib/ddtrace/contrib/resque/configuration/settings.rb +17 -1
  261. data/lib/ddtrace/contrib/resque/integration.rb +1 -1
  262. data/lib/ddtrace/contrib/resque/patcher.rb +4 -4
  263. data/lib/ddtrace/contrib/resque/resque_job.rb +24 -1
  264. data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
  265. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
  266. data/lib/ddtrace/contrib/rspec/example.rb +24 -10
  267. data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
  268. data/lib/ddtrace/contrib/rspec/integration.rb +6 -1
  269. data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
  270. data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
  271. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
  272. data/lib/ddtrace/contrib/shoryuken/tracer.rb +7 -4
  273. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -7
  274. data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
  275. data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
  276. data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
  277. data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
  278. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +5 -5
  279. data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
  280. data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
  281. data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
  282. data/lib/ddtrace/correlation.rb +1 -0
  283. data/lib/ddtrace/diagnostics/environment_logger.rb +3 -2
  284. data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
  285. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
  286. data/lib/ddtrace/error.rb +2 -0
  287. data/lib/ddtrace/ext/ci.rb +43 -11
  288. data/lib/ddtrace/ext/distributed.rb +1 -1
  289. data/lib/ddtrace/ext/git.rb +0 -1
  290. data/lib/ddtrace/ext/http.rb +1 -1
  291. data/lib/ddtrace/ext/profiling.rb +52 -0
  292. data/lib/ddtrace/ext/runtime.rb +3 -1
  293. data/lib/ddtrace/ext/transport.rb +1 -0
  294. data/lib/ddtrace/forced_tracing.rb +2 -0
  295. data/lib/ddtrace/logger.rb +1 -1
  296. data/lib/ddtrace/metrics.rb +14 -6
  297. data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
  298. data/lib/ddtrace/opentracer/span.rb +2 -6
  299. data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
  300. data/lib/ddtrace/patcher.rb +25 -4
  301. data/lib/ddtrace/pin.rb +8 -61
  302. data/lib/ddtrace/pipeline/span_filter.rb +1 -1
  303. data/lib/ddtrace/profiling.rb +54 -0
  304. data/lib/ddtrace/profiling/backtrace_location.rb +32 -0
  305. data/lib/ddtrace/profiling/buffer.rb +41 -0
  306. data/lib/ddtrace/profiling/collectors/stack.rb +253 -0
  307. data/lib/ddtrace/profiling/encoding/profile.rb +31 -0
  308. data/lib/ddtrace/profiling/event.rb +13 -0
  309. data/lib/ddtrace/profiling/events/stack.rb +102 -0
  310. data/lib/ddtrace/profiling/exporter.rb +23 -0
  311. data/lib/ddtrace/profiling/ext/cpu.rb +54 -0
  312. data/lib/ddtrace/profiling/ext/cthread.rb +134 -0
  313. data/lib/ddtrace/profiling/ext/forking.rb +97 -0
  314. data/lib/ddtrace/profiling/flush.rb +41 -0
  315. data/lib/ddtrace/profiling/pprof/builder.rb +121 -0
  316. data/lib/ddtrace/profiling/pprof/converter.rb +85 -0
  317. data/lib/ddtrace/profiling/pprof/message_set.rb +12 -0
  318. data/lib/ddtrace/profiling/pprof/payload.rb +18 -0
  319. data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
  320. data/lib/ddtrace/profiling/pprof/pprof_pb.rb +81 -0
  321. data/lib/ddtrace/profiling/pprof/stack_sample.rb +90 -0
  322. data/lib/ddtrace/profiling/pprof/string_table.rb +10 -0
  323. data/lib/ddtrace/profiling/pprof/template.rb +114 -0
  324. data/lib/ddtrace/profiling/preload.rb +3 -0
  325. data/lib/ddtrace/profiling/profiler.rb +28 -0
  326. data/lib/ddtrace/profiling/recorder.rb +87 -0
  327. data/lib/ddtrace/profiling/scheduler.rb +84 -0
  328. data/lib/ddtrace/profiling/tasks/setup.rb +77 -0
  329. data/lib/ddtrace/profiling/transport/client.rb +12 -0
  330. data/lib/ddtrace/profiling/transport/http.rb +122 -0
  331. data/lib/ddtrace/profiling/transport/http/api.rb +43 -0
  332. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +90 -0
  333. data/lib/ddtrace/profiling/transport/http/api/instance.rb +36 -0
  334. data/lib/ddtrace/profiling/transport/http/api/spec.rb +40 -0
  335. data/lib/ddtrace/profiling/transport/http/builder.rb +28 -0
  336. data/lib/ddtrace/profiling/transport/http/client.rb +33 -0
  337. data/lib/ddtrace/profiling/transport/http/response.rb +21 -0
  338. data/lib/ddtrace/profiling/transport/io.rb +30 -0
  339. data/lib/ddtrace/profiling/transport/io/client.rb +27 -0
  340. data/lib/ddtrace/profiling/transport/io/response.rb +16 -0
  341. data/lib/ddtrace/profiling/transport/parcel.rb +17 -0
  342. data/lib/ddtrace/profiling/transport/request.rb +15 -0
  343. data/lib/ddtrace/profiling/transport/response.rb +8 -0
  344. data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
  345. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  346. data/lib/ddtrace/quantization/http.rb +1 -0
  347. data/lib/ddtrace/runtime/cgroup.rb +2 -2
  348. data/lib/ddtrace/runtime/container.rb +32 -26
  349. data/lib/ddtrace/runtime/identity.rb +8 -0
  350. data/lib/ddtrace/sampler.rb +1 -1
  351. data/lib/ddtrace/sampling/rule_sampler.rb +4 -9
  352. data/lib/ddtrace/span.rb +7 -7
  353. data/lib/ddtrace/sync_writer.rb +12 -12
  354. data/lib/ddtrace/tasks/exec.rb +48 -0
  355. data/lib/ddtrace/tasks/help.rb +14 -0
  356. data/lib/ddtrace/tracer.rb +28 -5
  357. data/lib/ddtrace/transport/http.rb +15 -8
  358. data/lib/ddtrace/transport/http/adapters/net.rb +27 -8
  359. data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
  360. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
  361. data/lib/ddtrace/transport/http/builder.rb +7 -1
  362. data/lib/ddtrace/transport/http/env.rb +8 -0
  363. data/lib/ddtrace/transport/http/traces.rb +2 -3
  364. data/lib/ddtrace/transport/io.rb +1 -1
  365. data/lib/ddtrace/transport/io/client.rb +15 -8
  366. data/lib/ddtrace/transport/io/response.rb +1 -3
  367. data/lib/ddtrace/transport/io/traces.rb +6 -0
  368. data/lib/ddtrace/transport/parcel.rb +4 -0
  369. data/lib/ddtrace/transport/traces.rb +18 -1
  370. data/lib/ddtrace/utils/compression.rb +27 -0
  371. data/lib/ddtrace/utils/object_set.rb +41 -0
  372. data/lib/ddtrace/utils/only_once.rb +40 -0
  373. data/lib/ddtrace/utils/sequence.rb +17 -0
  374. data/lib/ddtrace/utils/string_table.rb +45 -0
  375. data/lib/ddtrace/utils/time.rb +32 -1
  376. data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
  377. data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
  378. data/lib/ddtrace/vendor/multipart-post/multipart.rb +12 -0
  379. data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +8 -0
  380. data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +116 -0
  381. data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +57 -0
  382. data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +135 -0
  383. data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +9 -0
  384. data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +32 -0
  385. data/lib/ddtrace/version.rb +3 -1
  386. data/lib/ddtrace/workers.rb +5 -0
  387. data/lib/ddtrace/workers/async.rb +11 -3
  388. data/lib/ddtrace/workers/loop.rb +17 -3
  389. data/lib/ddtrace/workers/polling.rb +1 -0
  390. data/lib/ddtrace/workers/queue.rb +1 -0
  391. data/lib/ddtrace/workers/runtime_metrics.rb +21 -4
  392. data/lib/ddtrace/workers/trace_writer.rb +10 -10
  393. data/lib/ddtrace/writer.rb +7 -4
  394. metadata +224 -342
  395. data/lib/ddtrace/augmentation.rb +0 -13
  396. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  397. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  398. data/lib/ddtrace/augmentation/shim.rb +0 -102
  399. data/lib/ddtrace/contrib/rspec/example_group.rb +0 -61
  400. data/lib/ddtrace/monkey.rb +0 -58
data/bin/ddtracerb ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require 'ddtrace/tasks/exec'
3
+ require 'ddtrace/tasks/help'
4
+
5
+ command = ARGV.shift
6
+
7
+ case command
8
+ when 'exec'
9
+ Datadog::Tasks::Exec.new(ARGV).run
10
+ when 'help', '--help'
11
+ Datadog::Tasks::Help.new.run
12
+ else
13
+ puts "Command '#{command}' is not valid for ddtrace."
14
+ Datadog::Tasks::Help.new.run
15
+ end
data/ddtrace.gemspec CHANGED
@@ -29,46 +29,16 @@ Gem::Specification.new do |spec|
29
29
  end
30
30
 
31
31
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
- spec.bindir = 'exe'
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.executables = ['ddtracerb']
34
33
  spec.require_paths = ['lib']
35
34
 
36
- spec.add_dependency 'msgpack'
37
-
38
- # Optional extensions
39
- # TODO: Move this to Appraisals?
40
- spec.add_development_dependency 'dogstatsd-ruby', '>= 3.3.0'
41
- spec.add_development_dependency 'opentracing', '>= 0.4.1'
42
-
43
- # Development dependencies
44
- spec.add_development_dependency 'concurrent-ruby' # Leave it open as we also have it as an integration and want Appraisal to control the version under test.
45
- spec.add_development_dependency 'rake', '>= 10.5'
46
- spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
47
- spec.add_development_dependency 'rspec', '~> 3.0'
48
- spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
49
- spec.add_development_dependency 'ruby-prof', '~> 1.4' if RUBY_PLATFORM != 'java' && RUBY_VERSION >= '2.4.0'
50
- spec.add_development_dependency 'minitest', '= 5.10.1'
51
- spec.add_development_dependency 'minitest-around', '0.5.0'
52
- spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
53
- spec.add_development_dependency 'appraisal', '~> 2.2'
54
- spec.add_development_dependency 'yard', '~> 0.9'
55
- spec.add_development_dependency 'webmock', '~> 2.0'
56
- spec.add_development_dependency 'builder'
57
- if RUBY_PLATFORM != 'java'
58
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
35
+ if RUBY_VERSION >= '2.2.0'
36
+ spec.add_dependency 'msgpack'
59
37
  else
60
- spec.add_development_dependency 'jdbc-sqlite3', '~> 3'
38
+ # msgpack 1.4 fails for Ruby 2.0 and 2.1: https://github.com/msgpack/msgpack-ruby/issues/205
39
+ spec.add_dependency 'msgpack', '< 1.4'
61
40
  end
62
- spec.add_development_dependency 'climate_control', '~> 0.2.0'
63
41
 
64
- # locking transitive dependency of webmock
65
- spec.add_development_dependency 'addressable', '~> 2.4.0'
66
- spec.add_development_dependency 'benchmark-ips', '~> 2.8'
67
- spec.add_development_dependency 'benchmark-memory', '~> 0.1'
68
- spec.add_development_dependency 'memory_profiler', '~> 0.9'
69
- spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
70
- spec.add_development_dependency 'pry', '~> 0.10.4'
71
- spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
72
- spec.add_development_dependency 'simplecov', '~> 0.17'
73
- spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
42
+ # Used by the profiler
43
+ spec.add_dependency 'ffi', '~> 1.0'
74
44
  end
data/docker-compose.yml CHANGED
@@ -248,9 +248,100 @@ services:
248
248
  - .:/app
249
249
  - bundle-2.7:/usr/local/bundle
250
250
  - gemfiles-2.7:/app/gemfiles
251
+ tracer-3.0:
252
+ image: marcotc/docker-library:ddtrace_rb_3.0.0
253
+ command: /bin/bash
254
+ depends_on:
255
+ - ddagent
256
+ - elasticsearch
257
+ - memcached
258
+ - mongodb
259
+ - mysql
260
+ - postgres
261
+ - redis
262
+ env_file: ./.env
263
+ environment:
264
+ - BUNDLE_GEMFILE=/app/Gemfile
265
+ - DD_AGENT_HOST=ddagent
266
+ - TEST_DATADOG_INTEGRATION=1
267
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
268
+ - TEST_MEMCACHED_HOST=memcached
269
+ - TEST_MONGODB_HOST=mongodb
270
+ - TEST_MYSQL_HOST=mysql
271
+ - TEST_POSTGRES_HOST=postgres
272
+ - TEST_REDIS_HOST=redis
273
+ stdin_open: true
274
+ tty: true
275
+ volumes:
276
+ - .:/app
277
+ - bundle-3.0:/usr/local/bundle
278
+ - gemfiles-3.0:/app/gemfiles
251
279
  # JRuby
252
- tracer-jruby-9.2:
253
- image: marcotc/docker-library:ddtrace_rb_jruby_9_2
280
+ tracer-jruby-9.2.0.0:
281
+ image: marcotc/docker-library:ddtrace_rb_jruby_9_2_0_0
282
+ command: /bin/bash
283
+ depends_on:
284
+ - ddagent
285
+ - elasticsearch
286
+ - memcached
287
+ - mongodb
288
+ - mysql
289
+ - postgres
290
+ - presto
291
+ - redis
292
+ env_file: ./.env
293
+ environment:
294
+ - BUNDLE_GEMFILE=/app/Gemfile
295
+ - DD_AGENT_HOST=ddagent
296
+ - TEST_DATADOG_INTEGRATION=1
297
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
298
+ - TEST_MEMCACHED_HOST=memcached
299
+ - TEST_MONGODB_HOST=mongodb
300
+ - TEST_MYSQL_HOST=mysql
301
+ - TEST_POSTGRES_HOST=postgres
302
+ - TEST_PRESTO_HOST=presto
303
+ - TEST_PRESTO_PORT=8080
304
+ - TEST_REDIS_HOST=redis
305
+ stdin_open: true
306
+ tty: true
307
+ volumes:
308
+ - .:/app
309
+ - bundle-jruby-9.2.0.0:/usr/local/bundle
310
+ - gemfiles-jruby-9.2.0.0:/app/gemfiles
311
+ tracer-jruby-9.2-latest:
312
+ image: marcotc/docker-library:ddtrace_rb_jruby_9_2_11_1
313
+ command: /bin/bash
314
+ depends_on:
315
+ - ddagent
316
+ - elasticsearch
317
+ - memcached
318
+ - mongodb
319
+ - mysql
320
+ - postgres
321
+ - presto
322
+ - redis
323
+ env_file: ./.env
324
+ environment:
325
+ - BUNDLE_GEMFILE=/app/Gemfile
326
+ - DD_AGENT_HOST=ddagent
327
+ - TEST_DATADOG_INTEGRATION=1
328
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
329
+ - TEST_MEMCACHED_HOST=memcached
330
+ - TEST_MONGODB_HOST=mongodb
331
+ - TEST_MYSQL_HOST=mysql
332
+ - TEST_POSTGRES_HOST=postgres
333
+ - TEST_PRESTO_HOST=presto
334
+ - TEST_PRESTO_PORT=8080
335
+ - TEST_REDIS_HOST=redis
336
+ stdin_open: true
337
+ tty: true
338
+ volumes:
339
+ - .:/app
340
+ - bundle-jruby-9.2-latest:/usr/local/bundle
341
+ - gemfiles-jruby-9.2-latest:/app/gemfiles
342
+ # TruffleRuby
343
+ tracer-truffleruby-21.0.0:
344
+ image: ivoanjo/docker-library:ddtrace_rb_truffleruby_21_0_0
254
345
  command: /bin/bash
255
346
  depends_on:
256
347
  - ddagent
@@ -278,8 +369,8 @@ services:
278
369
  tty: true
279
370
  volumes:
280
371
  - .:/app
281
- - bundle-jruby-9.2:/usr/local/bundle
282
- - gemfiles-jruby-9.2:/app/gemfiles
372
+ - bundle-truffleruby-21.0.0:/usr/local/bundle
373
+ - gemfiles-truffleruby-21.0.0:/app/gemfiles
283
374
  ddagent:
284
375
  image: datadog/agent
285
376
  environment:
@@ -338,7 +429,8 @@ services:
338
429
  ports:
339
430
  - "${TEST_POSTGRES_PORT}:5432"
340
431
  presto:
341
- image: prestosql/presto
432
+ # Move to trinodb/trino after https://github.com/treasure-data/presto-client-ruby/issues/64 is resolved.
433
+ image: starburstdata/presto:332-e.9
342
434
  expose:
343
435
  - "8080"
344
436
  ports:
@@ -358,7 +450,10 @@ volumes:
358
450
  bundle-2.5:
359
451
  bundle-2.6:
360
452
  bundle-2.7:
361
- bundle-jruby-9.2:
453
+ bundle-3.0:
454
+ bundle-jruby-9.2.0.0:
455
+ bundle-jruby-9.2-latest:
456
+ bundle-truffleruby-21.0.0:
362
457
  gemfiles-2.0:
363
458
  gemfiles-2.1:
364
459
  gemfiles-2.2:
@@ -367,4 +462,7 @@ volumes:
367
462
  gemfiles-2.5:
368
463
  gemfiles-2.6:
369
464
  gemfiles-2.7:
370
- gemfiles-jruby-9.2:
465
+ gemfiles-3.0:
466
+ gemfiles-jruby-9.2.0.0:
467
+ gemfiles-jruby-9.2-latest:
468
+ gemfiles-truffleruby-21.0.0:
@@ -114,6 +114,34 @@ Because you are likely not running all tests locally, your report will contain p
114
114
  You *must* check the CI step `coverage` for the complete test coverage report, ensuring coverage is not
115
115
  decreased.
116
116
 
117
+ **Ensuring tests don't leak resources**
118
+
119
+ Tests execution can create resources that are hard to track: threads, sockets, files, etc. Because these resources can come
120
+ from the both the test setup as well as the code under test, making sure all resources are properly disposed is important
121
+ to prevent the application from inadvertently creating cumulative resources during its execution.
122
+
123
+ When running tests that utilize threads, you might see an error message similar to this one:
124
+
125
+ ```
126
+ Test leaked 1 thread: "Datadog::Workers::AsyncTransport integration tests"
127
+ Ensure all threads are terminated when test finishes:
128
+ 1: #<Thread:0x00007fcbc99863d0 /Users/marco.costa/work/dd-trace-rb/spec/spec_helper.rb:145 sleep> (Thread)
129
+ Thread Creation Site:
130
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'new'
131
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'block (4 levels) in <top (required)>'
132
+ Thread Backtrace:
133
+ ./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'sleep'
134
+ .dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'block (5 levels) in <top (required)>'
135
+ ./dd-trace-rb/spec/spec_helper.rb:147:in 'block in initialize'
136
+ ```
137
+
138
+ This means that this test did not finish all threads by the time the test had finished. In this case, the thread
139
+ creation can be traced to `workers_integration_spec.rb:245:in 'new'`. The thread itself is sleeping at `workers_integration_spec.rb:262:in 'sleep'`.
140
+
141
+ The actionable in this case would be to ensure that the thread created in `workers_integration_spec.rb:245` is properly terminated by invoking `Thread#join` during the test tear down, which will wait for the thread to finish before returning.
142
+
143
+ Depending on the situation, the thread in question might need to be forced to terminate. It's recommended to have a mechanism in place to terminate it (a shared variable that changes value when the thread should exit), but as a last resort, `Thread#terminate` forces the thread to finish. Keep in mind that regardless of the termination method, `Thread#join` must be called to ensure that the thread has completely finished its shutdown process.
144
+
117
145
  ### Checking code quality
118
146
 
119
147
  **Linting**
@@ -45,10 +45,13 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
45
45
  - [GraphQL](#graphql)
46
46
  - [gRPC](#grpc)
47
47
  - [http.rb](#http-rb)
48
+ - [httpclient](#httpclient)
49
+ - [httpx](#httpx)
48
50
  - [MongoDB](#mongodb)
49
51
  - [MySQL2](#mysql2)
50
52
  - [Net/HTTP](#net-http)
51
53
  - [Presto](#presto)
54
+ - [Qless](#qless)
52
55
  - [Que](#que)
53
56
  - [Racecar](#racecar)
54
57
  - [Rack](#rack)
@@ -57,6 +60,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
57
60
  - [Redis](#redis)
58
61
  - [Rest Client](#rest-client)
59
62
  - [Resque](#resque)
63
+ - [RSpec](#rspec)
60
64
  - [Shoryuken](#shoryuken)
61
65
  - [Sequel](#sequel)
62
66
  - [Sidekiq](#sidekiq)
@@ -67,7 +71,9 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
67
71
  - [Tracer settings](#tracer-settings)
68
72
  - [Custom logging](#custom-logging)
69
73
  - [Environment and tags](#environment-and-tags)
74
+ - [Environment variables](#environment-variables)
70
75
  - [Sampling](#sampling)
76
+ - [Application-side sampling](#application-side-sampling)
71
77
  - [Priority sampling](#priority-sampling)
72
78
  - [Distributed tracing](#distributed-tracing)
73
79
  - [HTTP request queuing](#http-request-queuing)
@@ -86,14 +92,15 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
86
92
 
87
93
  | Type | Documentation | Version | Support type | Gem version support |
88
94
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
89
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
95
+ | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
96
+ | | | 2.7 | Full | Latest |
90
97
  | | | 2.6 | Full | Latest |
91
98
  | | | 2.5 | Full | Latest |
92
99
  | | | 2.4 | Full | Latest |
93
100
  | | | 2.3 | Full | Latest |
94
101
  | | | 2.2 | Full | Latest |
95
102
  | | | 2.1 | Full | Latest |
96
- | | | 2.0 | Full | Latest |
103
+ | | | 2.0 | Deprecated | < 0.50.0 |
97
104
  | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
98
105
  | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
99
106
  | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
@@ -124,14 +131,38 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
124
131
 
125
132
  The following steps will help you quickly start tracing your Ruby application.
126
133
 
127
- ### Setup the Datadog Agent
134
+ ### Configure the Datadog Agent for APM
128
135
 
129
136
  Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
130
137
 
131
- [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/).
138
+ 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.
139
+
140
+ #### Containers
141
+
142
+ 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).
143
+
144
+ 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:
145
+
146
+ 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`.
147
+
132
148
 
133
149
  ### Quickstart for Rails applications
134
150
 
151
+ #### Automatic instrumentation
152
+
153
+ 1. Add the `ddtrace` gem to your Gemfile:
154
+
155
+ ```ruby
156
+ source 'https://rubygems.org'
157
+ gem 'ddtrace', require: 'ddtrace/auto_instrument'
158
+ ```
159
+
160
+ 2. Install the gem with `bundle install`
161
+
162
+ 3. You can configure, override, or disable any specific integration settings by also adding a [Rails Manual Configuration](#rails-manual-configuration) file.
163
+
164
+ #### Manual instrumentation
165
+
135
166
  1. Add the `ddtrace` gem to your Gemfile:
136
167
 
137
168
  ```ruby
@@ -153,6 +184,25 @@ Before downloading tracing on your application, install the Datadog Agent. The R
153
184
 
154
185
  ### Quickstart for Ruby applications
155
186
 
187
+ #### Automatic instrumentation
188
+
189
+ 1. Install the gem with `gem install ddtrace`
190
+ 2. Requiring any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
191
+ 3. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
192
+
193
+ ```ruby
194
+ # Example frameworks and libraries
195
+ require 'sinatra'
196
+ require 'faraday'
197
+ require 'redis'
198
+
199
+ require 'ddtrace/auto_instrument'
200
+ ```
201
+
202
+ You can configure, override, or disable any specific integration settings by also adding a [Ruby Manual Configuration Block](#ruby-manual-configuration).
203
+
204
+ #### Manual instrumentation
205
+
156
206
  1. Install the gem with `gem install ddtrace`
157
207
  2. Add a configuration block to your Ruby application:
158
208
 
@@ -227,7 +277,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
227
277
  | `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. |
228
278
  | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
229
279
  | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
230
- | `start_time` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
280
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
231
281
  | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
232
282
  | `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? }` |
233
283
 
@@ -350,11 +400,15 @@ For a list of available integrations, and their configuration options, please re
350
400
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
351
401
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
352
402
  | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
403
+ | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
404
+ | httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
353
405
  | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
406
+ | Makara (through Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
354
407
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
355
408
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
356
409
  | 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)* |
357
410
  | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
411
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
358
412
  | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
359
413
  | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
360
414
  | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
@@ -363,6 +417,7 @@ For a list of available integrations, and their configuration options, please re
363
417
  | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
364
418
  | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
365
419
  | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
420
+ | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
366
421
  | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
367
422
  | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
368
423
  | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
@@ -388,7 +443,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
388
443
 
389
444
  | Key | Description | Default |
390
445
  | --- | ----------- | ------- |
391
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
392
446
  | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
393
447
 
394
448
  ### Action View
@@ -408,7 +462,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
408
462
 
409
463
  | Key | Description | Default |
410
464
  | ---| --- | --- |
411
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
412
465
  | `service_name` | Service name used for rendering instrumentation. | `action_view` |
413
466
  | `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/'` |
414
467
 
@@ -430,7 +483,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
430
483
 
431
484
  | Key | Description | Default |
432
485
  | --- | ----------- | ------- |
433
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
434
486
  | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
435
487
 
436
488
  ### Action Pack
@@ -450,7 +502,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
450
502
 
451
503
  | Key | Description | Default |
452
504
  | ---| --- | --- |
453
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
454
505
  | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
455
506
 
456
507
  ### Active Record
@@ -478,7 +529,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
478
529
 
479
530
  | Key | Description | Default |
480
531
  | ---| --- | --- |
481
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
482
532
  | `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'`) |
483
533
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
484
534
 
@@ -496,17 +546,20 @@ Datadog.configure do |c|
496
546
  # Symbol matching your database connection in config/database.yml
497
547
  # Only available if you are using Rails with ActiveRecord.
498
548
  c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
499
-
549
+
550
+ # Block configuration pattern.
500
551
  c.use :active_record, describes: :secondary_database do |second_db|
501
552
  second_db.service_name = 'secondary-db'
502
553
  end
503
554
 
504
555
  # Connection string with the following connection settings:
505
- # Adapter, user, host, port, database
556
+ # adapter, username, host, port, database
557
+ # Other fields are ignored.
506
558
  c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
507
559
 
508
- # Hash with following connection settings
509
- # Adapter, user, host, port, database
560
+ # Hash with following connection settings:
561
+ # adapter, username, host, port, database
562
+ # Other fields are ignored.
510
563
  c.use :active_record, describes: {
511
564
  adapter: 'mysql2',
512
565
  host: '127.0.0.1',
@@ -515,9 +568,34 @@ Datadog.configure do |c|
515
568
  username: 'root'
516
569
  },
517
570
  service_name: 'secondary-db'
571
+
572
+ # If using the `makara` gem, it's possible to match on connection `role`:
573
+ c.use :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
574
+ c.use :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
575
+ end
576
+ ```
577
+
578
+ You can also create configurations based on partial matching of database connection fields:
579
+
580
+ ```ruby
581
+ Datadog.configure do |c|
582
+ # Matches any connection on host `127.0.0.1`.
583
+ c.use :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
584
+
585
+ # Matches any `mysql2` connection.
586
+ c.use :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
587
+
588
+ # Matches any `mysql2` connection to the `reports` database.
589
+ #
590
+ # In case of multiple matching `describe` configurations, the latest one applies.
591
+ # In this case a connection with both adapter `mysql` and database `reports`
592
+ # will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
593
+ c.use :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
518
594
  end
519
595
  ```
520
596
 
597
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
598
+
521
599
  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.
522
600
 
523
601
  ### Active Support
@@ -540,7 +618,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
540
618
 
541
619
  | Key | Description | Default |
542
620
  | ---| --- | --- |
543
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
544
621
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
545
622
 
546
623
  ### AWS
@@ -563,7 +640,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
563
640
 
564
641
  | Key | Description | Default |
565
642
  | --- | ----------- | ------- |
566
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
567
643
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
568
644
 
569
645
  ### Concurrent Ruby
@@ -623,7 +699,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
623
699
 
624
700
  | Key | Description | Default |
625
701
  | --- | ----------- | ------- |
626
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
627
702
  | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
628
703
  | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
629
704
  | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
@@ -650,7 +725,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
650
725
 
651
726
  | Key | Description | Default |
652
727
  | --- | ----------- | ------- |
653
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
654
728
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
655
729
 
656
730
  ### DelayedJob
@@ -671,7 +745,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
671
745
 
672
746
  | Key | Description | Default |
673
747
  | --- | ----------- | ------- |
674
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
675
748
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
676
749
  | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
677
750
  | `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? }` |
@@ -697,7 +770,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
697
770
 
698
771
  | Key | Description | Default |
699
772
  | --- | ----------- | ------- |
700
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
701
773
  | `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. | `{}` |
702
774
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
703
775
 
@@ -723,7 +795,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
723
795
 
724
796
  | Key | Description | Default |
725
797
  | --- | ----------- | ------- |
726
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
727
798
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
728
799
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
729
800
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -755,7 +826,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
755
826
 
756
827
  | Key | Description | Default |
757
828
  | --- | ----------- | ------- |
758
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
759
829
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
760
830
  | `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` |
761
831
  | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
@@ -818,7 +888,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
818
888
 
819
889
  | Key | Description | Default |
820
890
  | --- | ----------- | ------- |
821
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
822
891
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
823
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` |
824
893
  | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
@@ -852,7 +921,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
852
921
 
853
922
  | Key | Description | Default |
854
923
  | --- | ----------- | ------- |
855
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
856
924
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
857
925
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
858
926
  | `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` |
@@ -877,7 +945,6 @@ The `use :graphql` method accepts the following parameters. Additional options c
877
945
 
878
946
  | Key | Description | Default |
879
947
  | --- | ----------- | ------- |
880
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
881
948
  | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
882
949
  | `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. | `[]` |
883
950
 
@@ -956,7 +1023,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
956
1023
 
957
1024
  | Key | Description | Default |
958
1025
  | --- | ----------- | ------- |
959
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
960
1026
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
961
1027
 
962
1028
  **Configuring clients to use different settings**
@@ -998,11 +1064,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
998
1064
 
999
1065
  | Key | Description | Default |
1000
1066
  | --- | ----------- | ------- |
1001
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1002
1067
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1003
1068
  | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
1004
1069
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1005
1070
 
1071
+ ### httpclient
1072
+
1073
+ The httpclient integration will trace any HTTP call using the httpclient gem.
1074
+
1075
+ ```ruby
1076
+ require 'httpclient'
1077
+ require 'ddtrace'
1078
+ Datadog.configure do |c|
1079
+ c.use :httpclient, options
1080
+ # optionally, specify a different service name for hostnames matching a regex
1081
+ c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1082
+ httpclient.service_name = 'user.example.com'
1083
+ httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1084
+ end
1085
+ end
1086
+ ```
1087
+
1088
+ Where `options` is an optional `Hash` that accepts the following parameters:
1089
+
1090
+ | Key | Description | Default |
1091
+ | --- | ----------- | ------- |
1092
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1093
+ | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1094
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1095
+
1096
+ ### httpx
1097
+
1098
+ `httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
1099
+
1100
+ ```ruby
1101
+ require "ddtrace"
1102
+ require "httpx/adapters/datadog"
1103
+
1104
+ Datadog.configure do |c|
1105
+ c.use :httpx
1106
+
1107
+ # optionally, specify a different service name for hostnames matching a regex
1108
+ c.use :httpx, describes: /user-[^.]+\.example\.com/ do |http|
1109
+ http.service_name = 'user.example.com'
1110
+ http.split_by_domain = false # Only necessary if split_by_domain is true by default
1111
+ end
1112
+ end
1113
+ ```
1114
+
1006
1115
  ### Kafka
1007
1116
 
1008
1117
  The Kafka integration provides tracing of the `ruby-kafka` gem:
@@ -1023,7 +1132,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1023
1132
 
1024
1133
  | Key | Description | Default |
1025
1134
  | --- | ----------- | ------- |
1026
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1027
1135
  | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
1028
1136
  | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1029
1137
 
@@ -1052,7 +1160,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1052
1160
 
1053
1161
  | Key | Description | Default |
1054
1162
  | --- | ----------- | ------- |
1055
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1056
1163
  | `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] }` |
1057
1164
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
1058
1165
 
@@ -1076,7 +1183,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1076
1183
 
1077
1184
  | Key | Description | Default |
1078
1185
  | --- | ----------- | ------- |
1079
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1080
1186
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1081
1187
 
1082
1188
  ### Net/HTTP
@@ -1109,7 +1215,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1109
1215
 
1110
1216
  | Key | Description | Default |
1111
1217
  | --- | ----------- | ------- |
1112
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1113
1218
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1114
1219
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1115
1220
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -1150,9 +1255,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1150
1255
 
1151
1256
  | Key | Description | Default |
1152
1257
  | --- | ----------- | ------- |
1153
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1154
1258
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1155
1259
 
1260
+ ### Qless
1261
+
1262
+ The Qless integration uses lifecycle hooks to trace job executions.
1263
+
1264
+ To add tracing to a Qless job:
1265
+
1266
+ ```ruby
1267
+ require 'ddtrace'
1268
+
1269
+ Datadog.configure do |c|
1270
+ c.use :qless, options
1271
+ end
1272
+ ```
1273
+
1274
+ Where `options` is an optional `Hash` that accepts the following parameters:
1275
+
1276
+ | Key | Description | Default |
1277
+ | --- | ----------- | ------- |
1278
+ | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1279
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1280
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1281
+
1156
1282
  ### Que
1157
1283
 
1158
1284
  The Que integration is a middleware which will trace job executions.
@@ -1171,7 +1297,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1171
1297
 
1172
1298
  | Key | Description | Default |
1173
1299
  | --- | ----------- | ------- |
1174
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1175
1300
  | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1176
1301
  | `service_name` | Service name used for `que` instrumentation | `'que'` |
1177
1302
  | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
@@ -1196,7 +1321,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1196
1321
 
1197
1322
  | Key | Description | Default |
1198
1323
  | --- | ----------- | ------- |
1199
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1200
1324
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1201
1325
 
1202
1326
  ### Rack
@@ -1226,11 +1350,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1226
1350
 
1227
1351
  | Key | Description | Default |
1228
1352
  | --- | ----------- | ------- |
1229
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1230
1353
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1231
1354
  | `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` |
1232
1355
  | `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'] }` |
1233
- | `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` |
1356
+ | `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` |
1234
1357
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1235
1358
  | `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. | `{}` |
1236
1359
  | `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` |
@@ -1289,7 +1412,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1289
1412
 
1290
1413
  | Key | Description | Default |
1291
1414
  | --- | ----------- | ------- |
1292
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `nil` |
1293
1415
  | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1294
1416
  | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1295
1417
  | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
@@ -1309,8 +1431,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1309
1431
  | 2.1 | | 3.0 - 4.2 |
1310
1432
  | 2.2 - 2.3 | | 3.0 - 5.2 |
1311
1433
  | 2.4 | | 4.2.8 - 5.2 |
1312
- | 2.5 | | 4.2.8 - 6.0 |
1313
- | 2.6 - 2.7 | 9.2 | 5.0 - 6.0 |
1434
+ | 2.5 | | 4.2.8 - 6.1 |
1435
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1436
+ | 3.0 | | 6.1 |
1314
1437
 
1315
1438
  ### Rake
1316
1439
 
@@ -1338,7 +1461,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1338
1461
 
1339
1462
  | Key | Description | Default |
1340
1463
  | --- | ----------- | ------- |
1341
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1342
1464
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1343
1465
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1344
1466
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
@@ -1398,8 +1520,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1398
1520
 
1399
1521
  | Key | Description | Default |
1400
1522
  | --- | ----------- | ------- |
1401
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1402
1523
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1524
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1403
1525
 
1404
1526
  You can also set *per-instance* configuration as it follows:
1405
1527
 
@@ -1437,12 +1559,17 @@ Datadog.configure do |c|
1437
1559
  # The default configuration for any redis client
1438
1560
  c.use :redis, service_name: 'redis-default'
1439
1561
 
1440
- # The configuration matching a given unix socket
1562
+ # The configuration matching a given unix socket.
1441
1563
  c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1442
1564
 
1443
- # Connection string
1444
- c.use :redis, describes: { url: 'redis://127.0.0.1:6379/0' }, service_name: 'redis-connection-string'
1445
- # Client host, port, db, scheme
1565
+ # For network connections, only these fields are considered during matching:
1566
+ # scheme, host, port, db
1567
+ # Other fields are ignored.
1568
+
1569
+ # Network connection string
1570
+ c.use :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
1571
+ c.use :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
1572
+ # Network client hash
1446
1573
  c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1447
1574
  # Only a subset of the connection hash
1448
1575
  c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
@@ -1450,6 +1577,8 @@ Datadog.configure do |c|
1450
1577
  end
1451
1578
  ```
1452
1579
 
1580
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1581
+
1453
1582
  ### Resque
1454
1583
 
1455
1584
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1457,16 +1586,11 @@ The Resque integration uses Resque hooks that wraps the `perform` method.
1457
1586
  To add tracing to a Resque job:
1458
1587
 
1459
1588
  ```ruby
1589
+ require 'resque'
1460
1590
  require 'ddtrace'
1461
1591
 
1462
- class MyJob
1463
- def self.perform(*args)
1464
- # do_something
1465
- end
1466
- end
1467
-
1468
1592
  Datadog.configure do |c|
1469
- c.use :resque, options
1593
+ c.use :resque, **options
1470
1594
  end
1471
1595
  ```
1472
1596
 
@@ -1474,10 +1598,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1474
1598
 
1475
1599
  | Key | Description | Default |
1476
1600
  | --- | ----------- | ------- |
1477
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1478
1601
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1479
- | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1480
1602
  | `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? }` |
1603
+ | `workers` | **[DEPRECATED]** Limits instrumented worker classes to only the ones specified in an array (e.g. `[MyJob]`). If not provided, instruments all workers. | `nil` |
1481
1604
 
1482
1605
  ### Rest Client
1483
1606
 
@@ -1496,11 +1619,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1496
1619
 
1497
1620
  | Key | Description | Default |
1498
1621
  | --- | ----------- | ------- |
1499
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1500
1622
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1501
1623
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1502
1624
 
1503
- ## RSpec
1625
+ ### RSpec
1504
1626
 
1505
1627
  RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1506
1628
 
@@ -1520,7 +1642,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1520
1642
 
1521
1643
  | Key | Description | Default |
1522
1644
  | --- | ----------- | ------- |
1523
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
1524
1645
  | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1525
1646
  | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1526
1647
  | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
@@ -1555,7 +1676,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1555
1676
 
1556
1677
  | Key | Description | Default |
1557
1678
  | --- | ----------- | ------- |
1558
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1559
1679
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1560
1680
 
1561
1681
  Only Ruby 2.0+ is supported.
@@ -1591,8 +1711,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1591
1711
 
1592
1712
  | Key | Description | Default |
1593
1713
  | --- | ----------- | ------- |
1594
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1595
1714
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1715
+ | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1596
1716
  | `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? }` |
1597
1717
 
1598
1718
  ### Sidekiq
@@ -1613,7 +1733,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1613
1733
 
1614
1734
  | Key | Description | Default |
1615
1735
  | --- | ----------- | ------- |
1616
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1617
1736
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1618
1737
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1619
1738
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
@@ -1677,7 +1796,6 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
1677
1796
 
1678
1797
  | Key | Description | Default |
1679
1798
  | --- | ----------- | ------- |
1680
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1681
1799
  | `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` |
1682
1800
  | `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'] }` |
1683
1801
  | `resource_script_names` | Prepend resource names with script name | `false` |
@@ -1701,7 +1819,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1701
1819
 
1702
1820
  | Key | Description | Default |
1703
1821
  | --- | ----------- | ------- |
1704
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1705
1822
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1706
1823
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1707
1824
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
@@ -1726,7 +1843,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1726
1843
 
1727
1844
  | Key | Description | Default |
1728
1845
  | --- | ----------- | ------- |
1729
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1730
1846
  | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1731
1847
 
1732
1848
  ## Advanced configuration
@@ -1742,13 +1858,20 @@ Datadog.configure do |c|
1742
1858
  c.tracer.enabled = true
1743
1859
  c.tracer.hostname = 'my-agent'
1744
1860
  c.tracer.port = 8126
1745
- c.tracer.partial_flush.enabled = false
1861
+
1862
+ # Ensure all traces are ingested by Datadog
1863
+ c.sampling.default_rate = 1.0 # Recommended
1864
+ c.sampling.rate_limit = 200
1865
+ # or provide a custom implementation (overrides c.sampling settings)
1746
1866
  c.tracer.sampler = Datadog::AllSampler.new
1747
1867
 
1748
- # OR for advanced use cases, you can specify your own tracer:
1868
+ # Breaks down very large traces into smaller batches
1869
+ c.tracer.partial_flush.enabled = false
1870
+
1871
+ # You can specify your own tracer
1749
1872
  c.tracer.instance = Datadog::Tracer.new
1750
1873
 
1751
- # To enable debug mode:
1874
+ # To enable debug mode
1752
1875
  c.diagnostics.debug = true
1753
1876
  end
1754
1877
  ```
@@ -1760,9 +1883,12 @@ Available options are:
1760
1883
  - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1761
1884
  - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1762
1885
  - `port`: set the port the trace agent is listening on.
1886
+ - `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.
1887
+ - `sampling.rate_limit`: maximum number of traces per second to sample. Defaults to 100 per second.
1763
1888
  - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1764
1889
  - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1765
1890
  - `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
1891
+ - `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 }`.
1766
1892
 
1767
1893
  #### Custom logging
1768
1894
 
@@ -1816,13 +1942,22 @@ Other Environment Variables:
1816
1942
 
1817
1943
  - `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`.
1818
1944
  - `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.
1819
- - `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`.
1820
- - `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`.
1945
+ - `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.
1821
1946
  - `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`.
1822
1947
 
1823
1948
  ### Sampling
1824
1949
 
1825
- `ddtrace` can perform trace sampling. While the trace agent already samples traces to reduce bandwidth usage, client sampling reduces the performance overhead.
1950
+ 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/).
1951
+
1952
+ We recommend setting the environment variable `DD_TRACE_SAMPLE_RATE=1.0` in all new applications using `ddtrace`.
1953
+
1954
+ 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/).
1955
+
1956
+ #### Application-side sampling
1957
+
1958
+ While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
1959
+
1960
+ This will **reduce visibility and is not recommended**. See [DD_TRACE_SAMPLE_RATE](#environment-variables) for the recommended sampling approach.
1826
1961
 
1827
1962
  `Datadog::RateSampler` samples a ratio of the traces. For example:
1828
1963
 
@@ -1986,6 +2121,8 @@ For more details on how to activate distributed tracing for integrations, see th
1986
2121
  - [Rails](#rails)
1987
2122
  - [Sinatra](#sinatra)
1988
2123
  - [http.rb](#http-rb)
2124
+ - [httpclient](#httpclient)
2125
+ - [httpx](#httpx)
1989
2126
 
1990
2127
  **Using the HTTP propagator**
1991
2128
 
@@ -2014,9 +2151,7 @@ end
2014
2151
 
2015
2152
  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.
2016
2153
 
2017
- This functionality is **experimental** and deactivated by default.
2018
-
2019
- 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:
2154
+ 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:
2020
2155
 
2021
2156
  ```
2022
2157
  # /etc/nginx/conf.d/ruby_service.conf
@@ -2030,9 +2165,7 @@ server {
2030
2165
  }
2031
2166
  ```
2032
2167
 
2033
- Then you must enable the request queuing feature in the integration handling the request.
2034
-
2035
- For Rack-based applications, see the [documentation](#rack) for details for enabling this feature.
2168
+ 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.
2036
2169
 
2037
2170
  ### Processing Pipeline
2038
2171