ddtrace 0.44.0 → 0.48.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (386) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +183 -15
  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-jruby-9.2-latest +88 -0
  12. data/.circleci/images/primary/{Dockerfile-jruby-9.2 → Dockerfile-jruby-9.2.0.0} +1 -5
  13. data/.circleci/images/primary/Dockerfile-truffleruby-21.0.0 +73 -0
  14. data/.github/workflows/create-next-milestone.yml +2 -2
  15. data/.gitlab-ci.yml +18 -18
  16. data/.rubocop.yml +269 -7
  17. data/.rubocop_todo.yml +438 -0
  18. data/.simplecov +6 -0
  19. data/Appraisals +87 -9
  20. data/CHANGELOG.md +238 -1
  21. data/Gemfile +63 -3
  22. data/LICENSE-3rdparty.csv +2 -0
  23. data/README.md +1 -0
  24. data/Rakefile +65 -25
  25. data/bin/ddtracerb +15 -0
  26. data/ddtrace.gemspec +9 -36
  27. data/docker-compose.yml +75 -7
  28. data/docs/DevelopmentGuide.md +28 -0
  29. data/docs/GettingStarted.md +162 -68
  30. data/docs/ProfilingDevelopment.md +88 -0
  31. data/integration/README.md +67 -0
  32. data/integration/apps/rack/.dockerignore +1 -0
  33. data/integration/apps/rack/.envrc.sample +1 -0
  34. data/integration/apps/rack/.gitignore +4 -0
  35. data/integration/apps/rack/.rspec +1 -0
  36. data/integration/apps/rack/Dockerfile +28 -0
  37. data/integration/apps/rack/Dockerfile-ci +11 -0
  38. data/integration/apps/rack/Gemfile +24 -0
  39. data/integration/apps/rack/README.md +93 -0
  40. data/integration/apps/rack/app/acme.rb +80 -0
  41. data/integration/apps/rack/app/datadog.rb +17 -0
  42. data/integration/apps/rack/bin/run +22 -0
  43. data/integration/apps/rack/bin/setup +17 -0
  44. data/integration/apps/rack/bin/test +24 -0
  45. data/integration/apps/rack/config.ru +6 -0
  46. data/integration/apps/rack/config/puma.rb +14 -0
  47. data/integration/apps/rack/config/unicorn.rb +23 -0
  48. data/integration/apps/rack/docker-compose.ci.yml +62 -0
  49. data/integration/apps/rack/docker-compose.yml +78 -0
  50. data/integration/apps/rack/script/build-images +38 -0
  51. data/integration/apps/rack/script/ci +50 -0
  52. data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
  53. data/integration/apps/rack/spec/spec_helper.rb +16 -0
  54. data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
  55. data/integration/apps/rails-five/.dockerignore +1 -0
  56. data/integration/apps/rails-five/.env +3 -0
  57. data/integration/apps/rails-five/.envrc.sample +1 -0
  58. data/integration/apps/rails-five/.gitignore +30 -0
  59. data/integration/apps/rails-five/Dockerfile +25 -0
  60. data/integration/apps/rails-five/Dockerfile-ci +11 -0
  61. data/integration/apps/rails-five/Gemfile +104 -0
  62. data/integration/apps/rails-five/README.md +94 -0
  63. data/integration/apps/rails-five/Rakefile +6 -0
  64. data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
  65. data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
  66. data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
  67. data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
  68. data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
  69. data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
  70. data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
  71. data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
  72. data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
  73. data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
  74. data/integration/apps/rails-five/app/models/application_record.rb +3 -0
  75. data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
  76. data/integration/apps/rails-five/app/models/test.rb +2 -0
  77. data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
  78. data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
  79. data/integration/apps/rails-five/bin/bundle +3 -0
  80. data/integration/apps/rails-five/bin/rails +9 -0
  81. data/integration/apps/rails-five/bin/rake +9 -0
  82. data/integration/apps/rails-five/bin/run +24 -0
  83. data/integration/apps/rails-five/bin/setup +27 -0
  84. data/integration/apps/rails-five/bin/spring +17 -0
  85. data/integration/apps/rails-five/bin/test +21 -0
  86. data/integration/apps/rails-five/bin/update +28 -0
  87. data/integration/apps/rails-five/config.ru +5 -0
  88. data/integration/apps/rails-five/config/application.rb +97 -0
  89. data/integration/apps/rails-five/config/boot.rb +4 -0
  90. data/integration/apps/rails-five/config/cable.yml +10 -0
  91. data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
  92. data/integration/apps/rails-five/config/database.yml +28 -0
  93. data/integration/apps/rails-five/config/environment.rb +5 -0
  94. data/integration/apps/rails-five/config/environments/development.rb +51 -0
  95. data/integration/apps/rails-five/config/environments/production.rb +82 -0
  96. data/integration/apps/rails-five/config/environments/test.rb +43 -0
  97. data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
  98. data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
  99. data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
  100. data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
  101. data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
  102. data/integration/apps/rails-five/config/locales/en.yml +33 -0
  103. data/integration/apps/rails-five/config/puma.rb +24 -0
  104. data/integration/apps/rails-five/config/routes.rb +11 -0
  105. data/integration/apps/rails-five/config/spring.rb +6 -0
  106. data/integration/apps/rails-five/config/unicorn.rb +29 -0
  107. data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
  108. data/integration/apps/rails-five/db/schema.rb +23 -0
  109. data/integration/apps/rails-five/db/seeds.rb +7 -0
  110. data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
  111. data/integration/apps/rails-five/docker-compose.yml +100 -0
  112. data/integration/apps/rails-five/lib/tasks/.keep +0 -0
  113. data/integration/apps/rails-five/log/.keep +0 -0
  114. data/integration/apps/rails-five/public/robots.txt +1 -0
  115. data/integration/apps/rails-five/script/build-images +35 -0
  116. data/integration/apps/rails-five/script/ci +50 -0
  117. data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
  118. data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
  119. data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
  120. data/integration/apps/rails-five/storage/.keep +0 -0
  121. data/integration/apps/rails-five/tmp/.keep +0 -0
  122. data/integration/apps/rails-five/vendor/.keep +0 -0
  123. data/integration/apps/ruby/.dockerignore +1 -0
  124. data/integration/apps/ruby/.envrc.sample +1 -0
  125. data/integration/apps/ruby/.gitignore +2 -0
  126. data/integration/apps/ruby/Dockerfile +25 -0
  127. data/integration/apps/ruby/Dockerfile-ci +11 -0
  128. data/integration/apps/ruby/Gemfile +11 -0
  129. data/integration/apps/ruby/README.md +70 -0
  130. data/integration/apps/ruby/agent.yaml +3 -0
  131. data/integration/apps/ruby/app/datadog.rb +13 -0
  132. data/integration/apps/ruby/app/fibonacci.rb +58 -0
  133. data/integration/apps/ruby/bin/run +20 -0
  134. data/integration/apps/ruby/bin/setup +17 -0
  135. data/integration/apps/ruby/bin/test +21 -0
  136. data/integration/apps/ruby/docker-compose.ci.yml +51 -0
  137. data/integration/apps/ruby/docker-compose.yml +63 -0
  138. data/integration/apps/ruby/script/build-images +38 -0
  139. data/integration/apps/ruby/script/ci +50 -0
  140. data/integration/images/agent/Dockerfile +2 -0
  141. data/integration/images/agent/agent.yaml +3 -0
  142. data/integration/images/include/datadog/analyzer.rb +71 -0
  143. data/integration/images/include/datadog/demo_env.rb +101 -0
  144. data/integration/images/include/http-health-check +33 -0
  145. data/integration/images/ruby/2.0/Dockerfile +54 -0
  146. data/integration/images/ruby/2.1/Dockerfile +54 -0
  147. data/integration/images/ruby/2.2/Dockerfile +54 -0
  148. data/integration/images/ruby/2.3/Dockerfile +70 -0
  149. data/integration/images/ruby/2.4/Dockerfile +54 -0
  150. data/integration/images/ruby/2.5/Dockerfile +54 -0
  151. data/integration/images/ruby/2.6/Dockerfile +54 -0
  152. data/integration/images/ruby/2.7/Dockerfile +54 -0
  153. data/integration/images/ruby/3.0/Dockerfile +54 -0
  154. data/integration/images/wrk/Dockerfile +33 -0
  155. data/integration/images/wrk/scripts/entrypoint.sh +17 -0
  156. data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
  157. data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
  158. data/integration/script/build-images +43 -0
  159. data/lib/ddtrace.rb +8 -5
  160. data/lib/ddtrace/analytics.rb +2 -0
  161. data/lib/ddtrace/auto_instrument.rb +3 -0
  162. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  163. data/lib/ddtrace/buffer.rb +4 -4
  164. data/lib/ddtrace/configuration.rb +121 -26
  165. data/lib/ddtrace/configuration/base.rb +1 -1
  166. data/lib/ddtrace/configuration/components.rb +87 -5
  167. data/lib/ddtrace/configuration/option_definition.rb +1 -3
  168. data/lib/ddtrace/configuration/options.rb +4 -7
  169. data/lib/ddtrace/configuration/settings.rb +48 -3
  170. data/lib/ddtrace/context.rb +5 -6
  171. data/lib/ddtrace/context_provider.rb +0 -1
  172. data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
  173. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  174. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
  175. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  176. data/lib/ddtrace/contrib/action_view/event.rb +1 -1
  177. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  178. data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
  179. data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +30 -0
  180. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +107 -18
  181. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  182. data/lib/ddtrace/contrib/active_record/utils.rb +57 -20
  183. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  184. data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -1
  185. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
  186. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
  187. data/lib/ddtrace/contrib/auto_instrument.rb +49 -0
  188. data/lib/ddtrace/contrib/aws/patcher.rb +1 -0
  189. data/lib/ddtrace/contrib/aws/services.rb +2 -0
  190. data/lib/ddtrace/contrib/configurable.rb +63 -39
  191. data/lib/ddtrace/contrib/configuration/resolver.rb +70 -5
  192. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +19 -20
  193. data/lib/ddtrace/contrib/configuration/settings.rb +7 -6
  194. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
  195. data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
  196. data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
  197. data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
  198. data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
  199. data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
  200. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -0
  201. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
  202. data/lib/ddtrace/contrib/ethon/easy_patch.rb +10 -9
  203. data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
  204. data/lib/ddtrace/contrib/extensions.rb +53 -3
  205. data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
  206. data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
  207. data/lib/ddtrace/contrib/grape/endpoint.rb +8 -15
  208. data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
  209. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
  210. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
  211. data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
  212. data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
  213. data/lib/ddtrace/contrib/http/instrumentation.rb +5 -5
  214. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  215. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  216. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +147 -0
  217. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  218. data/lib/ddtrace/contrib/httpclient/patcher.rb +38 -0
  219. data/lib/ddtrace/contrib/httprb/instrumentation.rb +14 -20
  220. data/lib/ddtrace/contrib/httprb/patcher.rb +5 -2
  221. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
  222. data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
  223. data/lib/ddtrace/contrib/patchable.rb +18 -7
  224. data/lib/ddtrace/contrib/patcher.rb +9 -6
  225. data/lib/ddtrace/contrib/presto/patcher.rb +5 -2
  226. data/lib/ddtrace/contrib/qless/qless_job.rb +1 -0
  227. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +1 -0
  228. data/lib/ddtrace/contrib/que/ext.rb +19 -19
  229. data/lib/ddtrace/contrib/que/tracer.rb +1 -1
  230. data/lib/ddtrace/contrib/racecar/event.rb +1 -0
  231. data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
  232. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  233. data/lib/ddtrace/contrib/rack/middlewares.rb +6 -11
  234. data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
  235. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  236. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  237. data/lib/ddtrace/contrib/rails/patcher.rb +6 -2
  238. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  239. data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
  240. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  241. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +11 -4
  242. data/lib/ddtrace/contrib/redis/quantize.rb +1 -0
  243. data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
  244. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
  245. data/lib/ddtrace/contrib/registry.rb +2 -2
  246. data/lib/ddtrace/contrib/resque/configuration/settings.rb +17 -1
  247. data/lib/ddtrace/contrib/resque/integration.rb +1 -1
  248. data/lib/ddtrace/contrib/resque/patcher.rb +4 -4
  249. data/lib/ddtrace/contrib/resque/resque_job.rb +24 -1
  250. data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
  251. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
  252. data/lib/ddtrace/contrib/rspec/example.rb +24 -10
  253. data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
  254. data/lib/ddtrace/contrib/rspec/integration.rb +6 -1
  255. data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
  256. data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
  257. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
  258. data/lib/ddtrace/contrib/shoryuken/tracer.rb +7 -4
  259. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -7
  260. data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
  261. data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
  262. data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
  263. data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
  264. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +3 -3
  265. data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
  266. data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
  267. data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
  268. data/lib/ddtrace/correlation.rb +1 -0
  269. data/lib/ddtrace/diagnostics/environment_logger.rb +3 -2
  270. data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
  271. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
  272. data/lib/ddtrace/error.rb +2 -0
  273. data/lib/ddtrace/ext/ci.rb +43 -10
  274. data/lib/ddtrace/ext/distributed.rb +1 -1
  275. data/lib/ddtrace/ext/git.rb +0 -1
  276. data/lib/ddtrace/ext/http.rb +1 -1
  277. data/lib/ddtrace/ext/profiling.rb +52 -0
  278. data/lib/ddtrace/ext/runtime.rb +3 -1
  279. data/lib/ddtrace/ext/transport.rb +1 -0
  280. data/lib/ddtrace/forced_tracing.rb +2 -0
  281. data/lib/ddtrace/logger.rb +1 -1
  282. data/lib/ddtrace/metrics.rb +14 -6
  283. data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
  284. data/lib/ddtrace/opentracer/span.rb +2 -6
  285. data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
  286. data/lib/ddtrace/patcher.rb +25 -4
  287. data/lib/ddtrace/pin.rb +8 -61
  288. data/lib/ddtrace/pipeline/span_filter.rb +1 -1
  289. data/lib/ddtrace/profiling.rb +54 -0
  290. data/lib/ddtrace/profiling/backtrace_location.rb +32 -0
  291. data/lib/ddtrace/profiling/buffer.rb +41 -0
  292. data/lib/ddtrace/profiling/collectors/stack.rb +253 -0
  293. data/lib/ddtrace/profiling/encoding/profile.rb +31 -0
  294. data/lib/ddtrace/profiling/event.rb +13 -0
  295. data/lib/ddtrace/profiling/events/stack.rb +102 -0
  296. data/lib/ddtrace/profiling/exporter.rb +23 -0
  297. data/lib/ddtrace/profiling/ext/cpu.rb +54 -0
  298. data/lib/ddtrace/profiling/ext/cthread.rb +134 -0
  299. data/lib/ddtrace/profiling/ext/forking.rb +97 -0
  300. data/lib/ddtrace/profiling/flush.rb +41 -0
  301. data/lib/ddtrace/profiling/pprof/builder.rb +121 -0
  302. data/lib/ddtrace/profiling/pprof/converter.rb +85 -0
  303. data/lib/ddtrace/profiling/pprof/message_set.rb +12 -0
  304. data/lib/ddtrace/profiling/pprof/payload.rb +18 -0
  305. data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
  306. data/lib/ddtrace/profiling/pprof/pprof_pb.rb +81 -0
  307. data/lib/ddtrace/profiling/pprof/stack_sample.rb +90 -0
  308. data/lib/ddtrace/profiling/pprof/string_table.rb +10 -0
  309. data/lib/ddtrace/profiling/pprof/template.rb +114 -0
  310. data/lib/ddtrace/profiling/preload.rb +3 -0
  311. data/lib/ddtrace/profiling/profiler.rb +28 -0
  312. data/lib/ddtrace/profiling/recorder.rb +87 -0
  313. data/lib/ddtrace/profiling/scheduler.rb +84 -0
  314. data/lib/ddtrace/profiling/tasks/setup.rb +77 -0
  315. data/lib/ddtrace/profiling/transport/client.rb +12 -0
  316. data/lib/ddtrace/profiling/transport/http.rb +122 -0
  317. data/lib/ddtrace/profiling/transport/http/api.rb +43 -0
  318. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +90 -0
  319. data/lib/ddtrace/profiling/transport/http/api/instance.rb +36 -0
  320. data/lib/ddtrace/profiling/transport/http/api/spec.rb +40 -0
  321. data/lib/ddtrace/profiling/transport/http/builder.rb +28 -0
  322. data/lib/ddtrace/profiling/transport/http/client.rb +33 -0
  323. data/lib/ddtrace/profiling/transport/http/response.rb +21 -0
  324. data/lib/ddtrace/profiling/transport/io.rb +30 -0
  325. data/lib/ddtrace/profiling/transport/io/client.rb +27 -0
  326. data/lib/ddtrace/profiling/transport/io/response.rb +16 -0
  327. data/lib/ddtrace/profiling/transport/parcel.rb +17 -0
  328. data/lib/ddtrace/profiling/transport/request.rb +15 -0
  329. data/lib/ddtrace/profiling/transport/response.rb +8 -0
  330. data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
  331. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  332. data/lib/ddtrace/quantization/http.rb +1 -0
  333. data/lib/ddtrace/runtime/cgroup.rb +2 -2
  334. data/lib/ddtrace/runtime/container.rb +32 -26
  335. data/lib/ddtrace/runtime/identity.rb +8 -0
  336. data/lib/ddtrace/sampler.rb +1 -1
  337. data/lib/ddtrace/sampling/rule_sampler.rb +4 -9
  338. data/lib/ddtrace/span.rb +7 -7
  339. data/lib/ddtrace/sync_writer.rb +12 -12
  340. data/lib/ddtrace/tasks/exec.rb +48 -0
  341. data/lib/ddtrace/tasks/help.rb +14 -0
  342. data/lib/ddtrace/tracer.rb +28 -5
  343. data/lib/ddtrace/transport/http.rb +15 -8
  344. data/lib/ddtrace/transport/http/adapters/net.rb +27 -8
  345. data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
  346. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
  347. data/lib/ddtrace/transport/http/builder.rb +7 -1
  348. data/lib/ddtrace/transport/http/env.rb +8 -0
  349. data/lib/ddtrace/transport/http/traces.rb +2 -3
  350. data/lib/ddtrace/transport/io.rb +1 -1
  351. data/lib/ddtrace/transport/io/client.rb +15 -8
  352. data/lib/ddtrace/transport/io/response.rb +1 -3
  353. data/lib/ddtrace/transport/io/traces.rb +6 -0
  354. data/lib/ddtrace/transport/parcel.rb +4 -0
  355. data/lib/ddtrace/transport/traces.rb +18 -1
  356. data/lib/ddtrace/utils/compression.rb +27 -0
  357. data/lib/ddtrace/utils/object_set.rb +41 -0
  358. data/lib/ddtrace/utils/only_once.rb +40 -0
  359. data/lib/ddtrace/utils/sequence.rb +17 -0
  360. data/lib/ddtrace/utils/string_table.rb +45 -0
  361. data/lib/ddtrace/utils/time.rb +32 -1
  362. data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
  363. data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
  364. data/lib/ddtrace/vendor/multipart-post/multipart.rb +12 -0
  365. data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +8 -0
  366. data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +116 -0
  367. data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +57 -0
  368. data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +135 -0
  369. data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +9 -0
  370. data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +32 -0
  371. data/lib/ddtrace/version.rb +3 -1
  372. data/lib/ddtrace/workers.rb +5 -0
  373. data/lib/ddtrace/workers/async.rb +11 -3
  374. data/lib/ddtrace/workers/loop.rb +17 -3
  375. data/lib/ddtrace/workers/polling.rb +1 -0
  376. data/lib/ddtrace/workers/queue.rb +1 -0
  377. data/lib/ddtrace/workers/runtime_metrics.rb +14 -1
  378. data/lib/ddtrace/workers/trace_writer.rb +10 -10
  379. data/lib/ddtrace/writer.rb +7 -4
  380. metadata +213 -379
  381. data/lib/ddtrace/augmentation.rb +0 -13
  382. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  383. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  384. data/lib/ddtrace/augmentation/shim.rb +0 -102
  385. data/lib/ddtrace/contrib/rspec/example_group.rb +0 -61
  386. 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,43 +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 'pimpmychangelog', '>= 0.1.2'
54
- spec.add_development_dependency 'appraisal', '~> 2.2'
55
- spec.add_development_dependency 'yard', '~> 0.9'
56
- spec.add_development_dependency 'webmock', '>= 3.10.0'
57
- spec.add_development_dependency 'builder'
58
- spec.add_development_dependency 'climate_control', '~> 0.2.0'
35
+ if RUBY_VERSION >= '2.2.0'
36
+ spec.add_dependency 'msgpack'
37
+ else
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'
40
+ end
59
41
 
60
- # locking transitive dependency of webmock
61
- spec.add_development_dependency 'addressable', '~> 2.4.0'
62
- spec.add_development_dependency 'benchmark-ips', '~> 2.8'
63
- spec.add_development_dependency 'benchmark-memory', '~> 0.1'
64
- spec.add_development_dependency 'memory_profiler', '~> 0.9'
65
- spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
66
- spec.add_development_dependency 'pry', '~> 0.12.2'
67
- spec.add_development_dependency 'pry-nav', '~> 0.3.0'
68
- spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9' if RUBY_PLATFORM != 'java'
69
- spec.add_development_dependency 'simplecov', '~> 0.17'
70
- spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
42
+ # Used by the profiler
43
+ spec.add_dependency 'ffi', '~> 1.0'
71
44
  end
data/docker-compose.yml CHANGED
@@ -277,8 +277,8 @@ services:
277
277
  - bundle-3.0:/usr/local/bundle
278
278
  - gemfiles-3.0:/app/gemfiles
279
279
  # JRuby
280
- tracer-jruby-9.2:
281
- 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
282
  command: /bin/bash
283
283
  depends_on:
284
284
  - ddagent
@@ -306,8 +306,71 @@ services:
306
306
  tty: true
307
307
  volumes:
308
308
  - .:/app
309
- - bundle-jruby-9.2:/usr/local/bundle
310
- - gemfiles-jruby-9.2:/app/gemfiles
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
345
+ command: /bin/bash
346
+ depends_on:
347
+ - ddagent
348
+ - elasticsearch
349
+ - memcached
350
+ - mongodb
351
+ - mysql
352
+ - postgres
353
+ - presto
354
+ - redis
355
+ env_file: ./.env
356
+ environment:
357
+ - BUNDLE_GEMFILE=/app/Gemfile
358
+ - DD_AGENT_HOST=ddagent
359
+ - TEST_DATADOG_INTEGRATION=1
360
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
361
+ - TEST_MEMCACHED_HOST=memcached
362
+ - TEST_MONGODB_HOST=mongodb
363
+ - TEST_MYSQL_HOST=mysql
364
+ - TEST_POSTGRES_HOST=postgres
365
+ - TEST_PRESTO_HOST=presto
366
+ - TEST_PRESTO_PORT=8080
367
+ - TEST_REDIS_HOST=redis
368
+ stdin_open: true
369
+ tty: true
370
+ volumes:
371
+ - .:/app
372
+ - bundle-truffleruby-21.0.0:/usr/local/bundle
373
+ - gemfiles-truffleruby-21.0.0:/app/gemfiles
311
374
  ddagent:
312
375
  image: datadog/agent
313
376
  environment:
@@ -366,7 +429,8 @@ services:
366
429
  ports:
367
430
  - "${TEST_POSTGRES_PORT}:5432"
368
431
  presto:
369
- 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
370
434
  expose:
371
435
  - "8080"
372
436
  ports:
@@ -387,7 +451,9 @@ volumes:
387
451
  bundle-2.6:
388
452
  bundle-2.7:
389
453
  bundle-3.0:
390
- bundle-jruby-9.2:
454
+ bundle-jruby-9.2.0.0:
455
+ bundle-jruby-9.2-latest:
456
+ bundle-truffleruby-21.0.0:
391
457
  gemfiles-2.0:
392
458
  gemfiles-2.1:
393
459
  gemfiles-2.2:
@@ -397,4 +463,6 @@ volumes:
397
463
  gemfiles-2.6:
398
464
  gemfiles-2.7:
399
465
  gemfiles-3.0:
400
- gemfiles-jruby-9.2:
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,6 +45,8 @@ 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)
@@ -69,7 +71,9 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
69
71
  - [Tracer settings](#tracer-settings)
70
72
  - [Custom logging](#custom-logging)
71
73
  - [Environment and tags](#environment-and-tags)
74
+ - [Environment variables](#environment-variables)
72
75
  - [Sampling](#sampling)
76
+ - [Application-side sampling](#application-side-sampling)
73
77
  - [Priority sampling](#priority-sampling)
74
78
  - [Distributed tracing](#distributed-tracing)
75
79
  - [HTTP request queuing](#http-request-queuing)
@@ -96,7 +100,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
96
100
  | | | 2.3 | Full | Latest |
97
101
  | | | 2.2 | Full | Latest |
98
102
  | | | 2.1 | Full | Latest |
99
- | | | 2.0 | Full | Latest |
103
+ | | | 2.0 | Deprecated | < 0.50.0 |
100
104
  | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
101
105
  | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
102
106
  | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
@@ -144,6 +148,21 @@ Install and configure the Datadog Agent to receive traces from your now instrume
144
148
 
145
149
  ### Quickstart for Rails applications
146
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
+
147
166
  1. Add the `ddtrace` gem to your Gemfile:
148
167
 
149
168
  ```ruby
@@ -165,6 +184,25 @@ Install and configure the Datadog Agent to receive traces from your now instrume
165
184
 
166
185
  ### Quickstart for Ruby applications
167
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
+
168
206
  1. Install the gem with `gem install ddtrace`
169
207
  2. Add a configuration block to your Ruby application:
170
208
 
@@ -362,7 +400,10 @@ For a list of available integrations, and their configuration options, please re
362
400
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
363
401
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
364
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)* |
365
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)* |
366
407
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
367
408
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
368
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)* |
@@ -402,7 +443,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
402
443
 
403
444
  | Key | Description | Default |
404
445
  | --- | ----------- | ------- |
405
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
406
446
  | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
407
447
 
408
448
  ### Action View
@@ -422,7 +462,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
422
462
 
423
463
  | Key | Description | Default |
424
464
  | ---| --- | --- |
425
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
426
465
  | `service_name` | Service name used for rendering instrumentation. | `action_view` |
427
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/'` |
428
467
 
@@ -444,7 +483,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
444
483
 
445
484
  | Key | Description | Default |
446
485
  | --- | ----------- | ------- |
447
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
448
486
  | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
449
487
 
450
488
  ### Action Pack
@@ -464,7 +502,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
464
502
 
465
503
  | Key | Description | Default |
466
504
  | ---| --- | --- |
467
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
468
505
  | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
469
506
 
470
507
  ### Active Record
@@ -492,7 +529,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
492
529
 
493
530
  | Key | Description | Default |
494
531
  | ---| --- | --- |
495
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
496
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'`) |
497
533
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
498
534
 
@@ -510,17 +546,20 @@ Datadog.configure do |c|
510
546
  # Symbol matching your database connection in config/database.yml
511
547
  # Only available if you are using Rails with ActiveRecord.
512
548
  c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
513
-
549
+
550
+ # Block configuration pattern.
514
551
  c.use :active_record, describes: :secondary_database do |second_db|
515
552
  second_db.service_name = 'secondary-db'
516
553
  end
517
554
 
518
555
  # Connection string with the following connection settings:
519
- # Adapter, user, host, port, database
556
+ # adapter, username, host, port, database
557
+ # Other fields are ignored.
520
558
  c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
521
559
 
522
- # Hash with following connection settings
523
- # Adapter, user, host, port, database
560
+ # Hash with following connection settings:
561
+ # adapter, username, host, port, database
562
+ # Other fields are ignored.
524
563
  c.use :active_record, describes: {
525
564
  adapter: 'mysql2',
526
565
  host: '127.0.0.1',
@@ -529,9 +568,34 @@ Datadog.configure do |c|
529
568
  username: 'root'
530
569
  },
531
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'
532
594
  end
533
595
  ```
534
596
 
597
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
598
+
535
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.
536
600
 
537
601
  ### Active Support
@@ -554,7 +618,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
554
618
 
555
619
  | Key | Description | Default |
556
620
  | ---| --- | --- |
557
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
558
621
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
559
622
 
560
623
  ### AWS
@@ -577,7 +640,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
577
640
 
578
641
  | Key | Description | Default |
579
642
  | --- | ----------- | ------- |
580
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
581
643
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
582
644
 
583
645
  ### Concurrent Ruby
@@ -637,7 +699,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
637
699
 
638
700
  | Key | Description | Default |
639
701
  | --- | ----------- | ------- |
640
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
641
702
  | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
642
703
  | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
643
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'` |
@@ -664,7 +725,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
664
725
 
665
726
  | Key | Description | Default |
666
727
  | --- | ----------- | ------- |
667
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
668
728
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
669
729
 
670
730
  ### DelayedJob
@@ -685,7 +745,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
685
745
 
686
746
  | Key | Description | Default |
687
747
  | --- | ----------- | ------- |
688
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
689
748
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
690
749
  | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
691
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? }` |
@@ -711,7 +770,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
711
770
 
712
771
  | Key | Description | Default |
713
772
  | --- | ----------- | ------- |
714
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
715
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. | `{}` |
716
774
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
717
775
 
@@ -737,7 +795,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
737
795
 
738
796
  | Key | Description | Default |
739
797
  | --- | ----------- | ------- |
740
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
741
798
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
742
799
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
743
800
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -769,7 +826,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
769
826
 
770
827
  | Key | Description | Default |
771
828
  | --- | ----------- | ------- |
772
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
773
829
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
774
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` |
775
831
  | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
@@ -832,7 +888,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
832
888
 
833
889
  | Key | Description | Default |
834
890
  | --- | ----------- | ------- |
835
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
836
891
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
837
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` |
838
893
  | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
@@ -866,7 +921,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
866
921
 
867
922
  | Key | Description | Default |
868
923
  | --- | ----------- | ------- |
869
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
870
924
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
871
925
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
872
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` |
@@ -891,7 +945,6 @@ The `use :graphql` method accepts the following parameters. Additional options c
891
945
 
892
946
  | Key | Description | Default |
893
947
  | --- | ----------- | ------- |
894
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
895
948
  | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
896
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. | `[]` |
897
950
 
@@ -970,7 +1023,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
970
1023
 
971
1024
  | Key | Description | Default |
972
1025
  | --- | ----------- | ------- |
973
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
974
1026
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
975
1027
 
976
1028
  **Configuring clients to use different settings**
@@ -1012,11 +1064,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1012
1064
 
1013
1065
  | Key | Description | Default |
1014
1066
  | --- | ----------- | ------- |
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
1067
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1017
1068
  | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
1018
1069
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1019
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
+
1020
1115
  ### Kafka
1021
1116
 
1022
1117
  The Kafka integration provides tracing of the `ruby-kafka` gem:
@@ -1037,7 +1132,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1037
1132
 
1038
1133
  | Key | Description | Default |
1039
1134
  | --- | ----------- | ------- |
1040
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1041
1135
  | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
1042
1136
  | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1043
1137
 
@@ -1066,7 +1160,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1066
1160
 
1067
1161
  | Key | Description | Default |
1068
1162
  | --- | ----------- | ------- |
1069
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1070
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] }` |
1071
1164
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
1072
1165
 
@@ -1090,7 +1183,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1090
1183
 
1091
1184
  | Key | Description | Default |
1092
1185
  | --- | ----------- | ------- |
1093
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1094
1186
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1095
1187
 
1096
1188
  ### Net/HTTP
@@ -1123,7 +1215,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1123
1215
 
1124
1216
  | Key | Description | Default |
1125
1217
  | --- | ----------- | ------- |
1126
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1127
1218
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1128
1219
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1129
1220
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
@@ -1164,7 +1255,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1164
1255
 
1165
1256
  | Key | Description | Default |
1166
1257
  | --- | ----------- | ------- |
1167
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1168
1258
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1169
1259
 
1170
1260
  ### Qless
@@ -1185,7 +1275,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1185
1275
 
1186
1276
  | Key | Description | Default |
1187
1277
  | --- | ----------- | ------- |
1188
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1189
1278
  | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1190
1279
  | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1191
1280
  | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
@@ -1208,7 +1297,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1208
1297
 
1209
1298
  | Key | Description | Default |
1210
1299
  | --- | ----------- | ------- |
1211
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1212
1300
  | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1213
1301
  | `service_name` | Service name used for `que` instrumentation | `'que'` |
1214
1302
  | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
@@ -1233,7 +1321,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1233
1321
 
1234
1322
  | Key | Description | Default |
1235
1323
  | --- | ----------- | ------- |
1236
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1237
1324
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1238
1325
 
1239
1326
  ### Rack
@@ -1263,7 +1350,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1263
1350
 
1264
1351
  | Key | Description | Default |
1265
1352
  | --- | ----------- | ------- |
1266
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1267
1353
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1268
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` |
1269
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'] }` |
@@ -1326,7 +1412,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1326
1412
 
1327
1413
  | Key | Description | Default |
1328
1414
  | --- | ----------- | ------- |
1329
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `nil` |
1330
1415
  | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1331
1416
  | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1332
1417
  | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
@@ -1376,7 +1461,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1376
1461
 
1377
1462
  | Key | Description | Default |
1378
1463
  | --- | ----------- | ------- |
1379
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1380
1464
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1381
1465
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1382
1466
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
@@ -1436,7 +1520,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1436
1520
 
1437
1521
  | Key | Description | Default |
1438
1522
  | --- | ----------- | ------- |
1439
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1440
1523
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1441
1524
  | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1442
1525
 
@@ -1476,12 +1559,17 @@ Datadog.configure do |c|
1476
1559
  # The default configuration for any redis client
1477
1560
  c.use :redis, service_name: 'redis-default'
1478
1561
 
1479
- # The configuration matching a given unix socket
1562
+ # The configuration matching a given unix socket.
1480
1563
  c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1481
1564
 
1482
- # Connection string
1483
- c.use :redis, describes: { url: 'redis://127.0.0.1:6379/0' }, service_name: 'redis-connection-string'
1484
- # 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
1485
1573
  c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1486
1574
  # Only a subset of the connection hash
1487
1575
  c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
@@ -1489,6 +1577,8 @@ Datadog.configure do |c|
1489
1577
  end
1490
1578
  ```
1491
1579
 
1580
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1581
+
1492
1582
  ### Resque
1493
1583
 
1494
1584
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1496,16 +1586,11 @@ The Resque integration uses Resque hooks that wraps the `perform` method.
1496
1586
  To add tracing to a Resque job:
1497
1587
 
1498
1588
  ```ruby
1589
+ require 'resque'
1499
1590
  require 'ddtrace'
1500
1591
 
1501
- class MyJob
1502
- def self.perform(*args)
1503
- # do_something
1504
- end
1505
- end
1506
-
1507
1592
  Datadog.configure do |c|
1508
- c.use :resque, options
1593
+ c.use :resque, **options
1509
1594
  end
1510
1595
  ```
1511
1596
 
@@ -1513,10 +1598,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1513
1598
 
1514
1599
  | Key | Description | Default |
1515
1600
  | --- | ----------- | ------- |
1516
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1517
1601
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1518
- | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1519
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` |
1520
1604
 
1521
1605
  ### Rest Client
1522
1606
 
@@ -1535,7 +1619,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1535
1619
 
1536
1620
  | Key | Description | Default |
1537
1621
  | --- | ----------- | ------- |
1538
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1539
1622
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1540
1623
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1541
1624
 
@@ -1559,7 +1642,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1559
1642
 
1560
1643
  | Key | Description | Default |
1561
1644
  | --- | ----------- | ------- |
1562
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
1563
1645
  | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1564
1646
  | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1565
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'` |
@@ -1594,7 +1676,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1594
1676
 
1595
1677
  | Key | Description | Default |
1596
1678
  | --- | ----------- | ------- |
1597
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1598
1679
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1599
1680
 
1600
1681
  Only Ruby 2.0+ is supported.
@@ -1630,8 +1711,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1630
1711
 
1631
1712
  | Key | Description | Default |
1632
1713
  | --- | ----------- | ------- |
1633
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1634
1714
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1715
+ | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1635
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? }` |
1636
1717
 
1637
1718
  ### Sidekiq
@@ -1652,7 +1733,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1652
1733
 
1653
1734
  | Key | Description | Default |
1654
1735
  | --- | ----------- | ------- |
1655
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1656
1736
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1657
1737
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1658
1738
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
@@ -1716,7 +1796,6 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
1716
1796
 
1717
1797
  | Key | Description | Default |
1718
1798
  | --- | ----------- | ------- |
1719
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1720
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` |
1721
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'] }` |
1722
1801
  | `resource_script_names` | Prepend resource names with script name | `false` |
@@ -1740,7 +1819,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1740
1819
 
1741
1820
  | Key | Description | Default |
1742
1821
  | --- | ----------- | ------- |
1743
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1744
1822
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1745
1823
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1746
1824
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
@@ -1765,7 +1843,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1765
1843
 
1766
1844
  | Key | Description | Default |
1767
1845
  | --- | ----------- | ------- |
1768
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1769
1846
  | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1770
1847
 
1771
1848
  ## Advanced configuration
@@ -1781,13 +1858,20 @@ Datadog.configure do |c|
1781
1858
  c.tracer.enabled = true
1782
1859
  c.tracer.hostname = 'my-agent'
1783
1860
  c.tracer.port = 8126
1784
- 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)
1785
1866
  c.tracer.sampler = Datadog::AllSampler.new
1786
1867
 
1787
- # 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
1788
1872
  c.tracer.instance = Datadog::Tracer.new
1789
1873
 
1790
- # To enable debug mode:
1874
+ # To enable debug mode
1791
1875
  c.diagnostics.debug = true
1792
1876
  end
1793
1877
  ```
@@ -1799,9 +1883,12 @@ Available options are:
1799
1883
  - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1800
1884
  - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1801
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.
1802
1888
  - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1803
1889
  - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1804
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 }`.
1805
1892
 
1806
1893
  #### Custom logging
1807
1894
 
@@ -1855,13 +1942,22 @@ Other Environment Variables:
1855
1942
 
1856
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`.
1857
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.
1858
- - `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`.
1859
- - `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.
1860
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`.
1861
1947
 
1862
1948
  ### Sampling
1863
1949
 
1864
- `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.
1865
1961
 
1866
1962
  `Datadog::RateSampler` samples a ratio of the traces. For example:
1867
1963
 
@@ -2025,6 +2121,8 @@ For more details on how to activate distributed tracing for integrations, see th
2025
2121
  - [Rails](#rails)
2026
2122
  - [Sinatra](#sinatra)
2027
2123
  - [http.rb](#http-rb)
2124
+ - [httpclient](#httpclient)
2125
+ - [httpx](#httpx)
2028
2126
 
2029
2127
  **Using the HTTP propagator**
2030
2128
 
@@ -2053,9 +2151,7 @@ end
2053
2151
 
2054
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.
2055
2153
 
2056
- This functionality is **experimental** and deactivated by default.
2057
-
2058
- 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:
2059
2155
 
2060
2156
  ```
2061
2157
  # /etc/nginx/conf.d/ruby_service.conf
@@ -2069,9 +2165,7 @@ server {
2069
2165
  }
2070
2166
  ```
2071
2167
 
2072
- Then you must enable the request queuing feature in the integration handling the request.
2073
-
2074
- 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.
2075
2169
 
2076
2170
  ### Processing Pipeline
2077
2171