ls-trace 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +419 -544
  3. data/.circleci/images/primary/Dockerfile-2.7.0 +73 -0
  4. data/.circleci/images/primary/Dockerfile-jruby-9.2 +77 -0
  5. data/.env +2 -0
  6. data/.gitignore +2 -0
  7. data/.gitlab-ci.yml +27 -0
  8. data/.rubocop.yml +8 -0
  9. data/.simplecov +38 -0
  10. data/Appraisals +299 -48
  11. data/CHANGELOG.md +3 -4
  12. data/LICENSE +4 -22
  13. data/LICENSE.Apache +200 -0
  14. data/LICENSE.BSD3 +24 -0
  15. data/NOTICE +4 -0
  16. data/README.md +4 -3
  17. data/Rakefile +561 -405
  18. data/ddtrace.gemspec +13 -4
  19. data/docker-compose.yml +96 -2
  20. data/docs/DevelopmentGuide.md +17 -1
  21. data/docs/GettingStarted.md +433 -138
  22. data/lib/ddtrace.rb +15 -0
  23. data/lib/ddtrace/analytics.rb +7 -0
  24. data/lib/ddtrace/buffer.rb +9 -9
  25. data/lib/ddtrace/chunker.rb +34 -0
  26. data/lib/ddtrace/configuration.rb +59 -5
  27. data/lib/ddtrace/configuration/base.rb +4 -2
  28. data/lib/ddtrace/configuration/components.rb +151 -0
  29. data/lib/ddtrace/configuration/option.rb +12 -3
  30. data/lib/ddtrace/configuration/option_definition.rb +1 -5
  31. data/lib/ddtrace/configuration/options.rb +6 -1
  32. data/lib/ddtrace/configuration/pin_setup.rb +3 -2
  33. data/lib/ddtrace/configuration/settings.rb +214 -40
  34. data/lib/ddtrace/context.rb +84 -63
  35. data/lib/ddtrace/context_flush.rb +51 -114
  36. data/lib/ddtrace/context_provider.rb +50 -0
  37. data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +30 -0
  38. data/lib/ddtrace/contrib/action_cable/event.rb +65 -0
  39. data/lib/ddtrace/contrib/action_cable/events.rb +33 -0
  40. data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +49 -0
  41. data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +55 -0
  42. data/lib/ddtrace/contrib/action_cable/events/transmit.rb +50 -0
  43. data/lib/ddtrace/contrib/action_cable/ext.rb +26 -0
  44. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +31 -0
  45. data/lib/ddtrace/contrib/action_cable/integration.rb +38 -0
  46. data/lib/ddtrace/contrib/action_cable/patcher.rb +27 -0
  47. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +6 -2
  48. data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +3 -15
  49. data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +7 -2
  50. data/lib/ddtrace/contrib/action_pack/ext.rb +5 -2
  51. data/lib/ddtrace/contrib/action_pack/integration.rb +5 -3
  52. data/lib/ddtrace/contrib/action_pack/patcher.rb +3 -9
  53. data/lib/ddtrace/contrib/action_view/configuration/settings.rb +7 -2
  54. data/lib/ddtrace/contrib/action_view/event.rb +39 -0
  55. data/lib/ddtrace/contrib/action_view/events.rb +30 -0
  56. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +45 -0
  57. data/lib/ddtrace/contrib/action_view/events/render_template.rb +48 -0
  58. data/lib/ddtrace/contrib/action_view/ext.rb +5 -2
  59. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +9 -13
  60. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +16 -16
  61. data/lib/ddtrace/contrib/action_view/integration.rb +5 -3
  62. data/lib/ddtrace/contrib/action_view/patcher.rb +19 -25
  63. data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +7 -2
  64. data/lib/ddtrace/contrib/active_model_serializers/event.rb +3 -0
  65. data/lib/ddtrace/contrib/active_model_serializers/ext.rb +5 -2
  66. data/lib/ddtrace/contrib/active_model_serializers/integration.rb +6 -5
  67. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +3 -10
  68. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +4 -5
  69. data/lib/ddtrace/contrib/active_record/configuration/settings.rb +7 -2
  70. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +4 -1
  71. data/lib/ddtrace/contrib/active_record/events/sql.rb +1 -1
  72. data/lib/ddtrace/contrib/active_record/ext.rb +5 -2
  73. data/lib/ddtrace/contrib/active_record/integration.rb +5 -3
  74. data/lib/ddtrace/contrib/active_record/patcher.rb +3 -9
  75. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +2 -2
  76. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +10 -24
  77. data/lib/ddtrace/contrib/active_support/cache/redis.rb +1 -1
  78. data/lib/ddtrace/contrib/active_support/configuration/settings.rb +7 -2
  79. data/lib/ddtrace/contrib/active_support/ext.rb +5 -2
  80. data/lib/ddtrace/contrib/active_support/integration.rb +5 -3
  81. data/lib/ddtrace/contrib/active_support/notifications/event.rb +3 -1
  82. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +3 -3
  83. data/lib/ddtrace/contrib/active_support/patcher.rb +3 -9
  84. data/lib/ddtrace/contrib/analytics.rb +5 -1
  85. data/lib/ddtrace/contrib/aws/configuration/settings.rb +7 -2
  86. data/lib/ddtrace/contrib/aws/ext.rb +5 -2
  87. data/lib/ddtrace/contrib/aws/integration.rb +8 -2
  88. data/lib/ddtrace/contrib/aws/patcher.rb +15 -15
  89. data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +5 -0
  90. data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +9 -3
  91. data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +1 -0
  92. data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +8 -2
  93. data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +4 -11
  94. data/lib/ddtrace/contrib/configurable.rb +30 -13
  95. data/lib/ddtrace/contrib/configuration/resolver.rb +7 -3
  96. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +39 -0
  97. data/lib/ddtrace/contrib/configuration/settings.rb +20 -1
  98. data/lib/ddtrace/contrib/dalli/configuration/settings.rb +7 -2
  99. data/lib/ddtrace/contrib/dalli/ext.rb +5 -2
  100. data/lib/ddtrace/contrib/dalli/integration.rb +5 -3
  101. data/lib/ddtrace/contrib/dalli/patcher.rb +6 -16
  102. data/lib/ddtrace/contrib/dalli/quantize.rb +1 -1
  103. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +7 -2
  104. data/lib/ddtrace/contrib/delayed_job/ext.rb +5 -2
  105. data/lib/ddtrace/contrib/delayed_job/integration.rb +8 -2
  106. data/lib/ddtrace/contrib/delayed_job/patcher.rb +4 -10
  107. data/lib/ddtrace/contrib/delayed_job/plugin.rb +4 -0
  108. data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +7 -2
  109. data/lib/ddtrace/contrib/elasticsearch/ext.rb +5 -2
  110. data/lib/ddtrace/contrib/elasticsearch/integration.rb +5 -3
  111. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +10 -17
  112. data/lib/ddtrace/contrib/ethon/configuration/settings.rb +8 -2
  113. data/lib/ddtrace/contrib/ethon/easy_patch.rb +22 -13
  114. data/lib/ddtrace/contrib/ethon/ext.rb +5 -2
  115. data/lib/ddtrace/contrib/ethon/integration.rb +14 -2
  116. data/lib/ddtrace/contrib/ethon/patcher.rb +7 -9
  117. data/lib/ddtrace/contrib/excon/configuration/settings.rb +7 -2
  118. data/lib/ddtrace/contrib/excon/ext.rb +5 -2
  119. data/lib/ddtrace/contrib/excon/integration.rb +13 -2
  120. data/lib/ddtrace/contrib/excon/middleware.rb +15 -12
  121. data/lib/ddtrace/contrib/excon/patcher.rb +4 -11
  122. data/lib/ddtrace/contrib/extensions.rb +39 -5
  123. data/lib/ddtrace/contrib/faraday/configuration/settings.rb +7 -2
  124. data/lib/ddtrace/contrib/faraday/connection.rb +18 -0
  125. data/lib/ddtrace/contrib/faraday/ext.rb +5 -2
  126. data/lib/ddtrace/contrib/faraday/integration.rb +10 -3
  127. data/lib/ddtrace/contrib/faraday/middleware.rb +24 -34
  128. data/lib/ddtrace/contrib/faraday/patcher.rb +26 -19
  129. data/lib/ddtrace/contrib/grape/configuration/settings.rb +7 -3
  130. data/lib/ddtrace/contrib/grape/endpoint.rb +14 -5
  131. data/lib/ddtrace/contrib/grape/ext.rb +5 -2
  132. data/lib/ddtrace/contrib/grape/integration.rb +6 -3
  133. data/lib/ddtrace/contrib/grape/patcher.rb +9 -15
  134. data/lib/ddtrace/contrib/graphql/configuration/settings.rb +7 -2
  135. data/lib/ddtrace/contrib/graphql/ext.rb +5 -2
  136. data/lib/ddtrace/contrib/graphql/integration.rb +6 -5
  137. data/lib/ddtrace/contrib/graphql/patcher.rb +11 -14
  138. data/lib/ddtrace/contrib/grpc/configuration/settings.rb +7 -2
  139. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +1 -1
  140. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +2 -4
  141. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +5 -2
  142. data/lib/ddtrace/contrib/grpc/ext.rb +5 -2
  143. data/lib/ddtrace/contrib/grpc/integration.rb +5 -3
  144. data/lib/ddtrace/contrib/grpc/patcher.rb +9 -19
  145. data/lib/ddtrace/contrib/http/circuit_breaker.rb +8 -32
  146. data/lib/ddtrace/contrib/http/configuration/settings.rb +8 -2
  147. data/lib/ddtrace/contrib/http/ext.rb +5 -2
  148. data/lib/ddtrace/contrib/http/instrumentation.rb +89 -28
  149. data/lib/ddtrace/contrib/http/integration.rb +13 -0
  150. data/lib/ddtrace/contrib/http/patcher.rb +3 -9
  151. data/lib/ddtrace/contrib/http_annotation_helper.rb +10 -0
  152. data/lib/ddtrace/contrib/httprb/configuration/settings.rb +32 -0
  153. data/lib/ddtrace/contrib/httprb/ext.rb +17 -0
  154. data/lib/ddtrace/contrib/httprb/instrumentation.rb +160 -0
  155. data/lib/ddtrace/contrib/httprb/integration.rb +43 -0
  156. data/lib/ddtrace/contrib/httprb/patcher.rb +35 -0
  157. data/lib/ddtrace/contrib/kafka/configuration/settings.rb +30 -0
  158. data/lib/ddtrace/contrib/kafka/consumer_event.rb +14 -0
  159. data/lib/ddtrace/contrib/kafka/consumer_group_event.rb +14 -0
  160. data/lib/ddtrace/contrib/kafka/event.rb +51 -0
  161. data/lib/ddtrace/contrib/kafka/events.rb +44 -0
  162. data/lib/ddtrace/contrib/kafka/events/connection/request.rb +34 -0
  163. data/lib/ddtrace/contrib/kafka/events/consumer/process_batch.rb +41 -0
  164. data/lib/ddtrace/contrib/kafka/events/consumer/process_message.rb +39 -0
  165. data/lib/ddtrace/contrib/kafka/events/consumer_group/heartbeat.rb +39 -0
  166. data/lib/ddtrace/contrib/kafka/events/consumer_group/join_group.rb +29 -0
  167. data/lib/ddtrace/contrib/kafka/events/consumer_group/leave_group.rb +29 -0
  168. data/lib/ddtrace/contrib/kafka/events/consumer_group/sync_group.rb +29 -0
  169. data/lib/ddtrace/contrib/kafka/events/produce_operation/send_messages.rb +32 -0
  170. data/lib/ddtrace/contrib/kafka/events/producer/deliver_messages.rb +35 -0
  171. data/lib/ddtrace/contrib/kafka/ext.rb +41 -0
  172. data/lib/ddtrace/contrib/kafka/integration.rb +39 -0
  173. data/lib/ddtrace/contrib/kafka/patcher.rb +26 -0
  174. data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +7 -2
  175. data/lib/ddtrace/contrib/mongodb/ext.rb +5 -2
  176. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +1 -2
  177. data/lib/ddtrace/contrib/mongodb/integration.rb +5 -3
  178. data/lib/ddtrace/contrib/mongodb/patcher.rb +5 -11
  179. data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -2
  180. data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +7 -2
  181. data/lib/ddtrace/contrib/mysql2/ext.rb +5 -2
  182. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +1 -1
  183. data/lib/ddtrace/contrib/mysql2/integration.rb +8 -2
  184. data/lib/ddtrace/contrib/mysql2/patcher.rb +3 -9
  185. data/lib/ddtrace/contrib/patchable.rb +21 -4
  186. data/lib/ddtrace/contrib/patcher.rb +44 -10
  187. data/lib/ddtrace/contrib/presto/configuration/settings.rb +30 -0
  188. data/lib/ddtrace/contrib/presto/ext.rb +28 -0
  189. data/lib/ddtrace/contrib/presto/instrumentation.rb +107 -0
  190. data/lib/ddtrace/contrib/presto/integration.rb +38 -0
  191. data/lib/ddtrace/contrib/presto/patcher.rb +30 -0
  192. data/lib/ddtrace/contrib/que/configuration/settings.rb +42 -0
  193. data/lib/ddtrace/contrib/que/ext.rb +30 -0
  194. data/lib/ddtrace/contrib/que/integration.rb +42 -0
  195. data/lib/ddtrace/contrib/que/patcher.rb +24 -0
  196. data/lib/ddtrace/contrib/que/tracer.rb +56 -0
  197. data/lib/ddtrace/contrib/racecar/configuration/settings.rb +7 -2
  198. data/lib/ddtrace/contrib/racecar/event.rb +4 -0
  199. data/lib/ddtrace/contrib/racecar/events.rb +2 -0
  200. data/lib/ddtrace/contrib/racecar/events/consume.rb +27 -0
  201. data/lib/ddtrace/contrib/racecar/ext.rb +6 -2
  202. data/lib/ddtrace/contrib/racecar/integration.rb +6 -3
  203. data/lib/ddtrace/contrib/racecar/patcher.rb +4 -10
  204. data/lib/ddtrace/contrib/rack/configuration/settings.rb +7 -2
  205. data/lib/ddtrace/contrib/rack/ext.rb +5 -2
  206. data/lib/ddtrace/contrib/rack/integration.rb +8 -2
  207. data/lib/ddtrace/contrib/rack/middlewares.rb +23 -14
  208. data/lib/ddtrace/contrib/rack/patcher.rb +57 -22
  209. data/lib/ddtrace/contrib/rack/request_queue.rb +1 -1
  210. data/lib/ddtrace/contrib/rails/configuration/settings.rb +23 -10
  211. data/lib/ddtrace/contrib/rails/ext.rb +7 -2
  212. data/lib/ddtrace/contrib/rails/framework.rb +59 -35
  213. data/lib/ddtrace/contrib/rails/integration.rb +12 -5
  214. data/lib/ddtrace/contrib/rails/log_injection.rb +81 -0
  215. data/lib/ddtrace/contrib/rails/middlewares.rb +7 -2
  216. data/lib/ddtrace/contrib/rails/patcher.rb +19 -8
  217. data/lib/ddtrace/contrib/rake/configuration/settings.rb +7 -3
  218. data/lib/ddtrace/contrib/rake/ext.rb +5 -2
  219. data/lib/ddtrace/contrib/rake/instrumentation.rb +6 -2
  220. data/lib/ddtrace/contrib/rake/integration.rb +8 -2
  221. data/lib/ddtrace/contrib/rake/patcher.rb +4 -10
  222. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +36 -0
  223. data/lib/ddtrace/contrib/redis/configuration/settings.rb +7 -2
  224. data/lib/ddtrace/contrib/redis/ext.rb +5 -2
  225. data/lib/ddtrace/contrib/redis/integration.rb +9 -3
  226. data/lib/ddtrace/contrib/redis/patcher.rb +20 -17
  227. data/lib/ddtrace/contrib/redis/quantize.rb +1 -1
  228. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +159 -0
  229. data/lib/ddtrace/contrib/resque/configuration/settings.rb +7 -2
  230. data/lib/ddtrace/contrib/resque/ext.rb +5 -2
  231. data/lib/ddtrace/contrib/resque/integration.rb +12 -2
  232. data/lib/ddtrace/contrib/resque/patcher.rb +4 -10
  233. data/lib/ddtrace/contrib/resque/resque_job.rb +6 -2
  234. data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +7 -2
  235. data/lib/ddtrace/contrib/rest_client/ext.rb +5 -2
  236. data/lib/ddtrace/contrib/rest_client/integration.rb +9 -2
  237. data/lib/ddtrace/contrib/rest_client/patcher.rb +5 -7
  238. data/lib/ddtrace/contrib/rest_client/request_patch.rb +2 -2
  239. data/lib/ddtrace/contrib/sequel/configuration/settings.rb +7 -2
  240. data/lib/ddtrace/contrib/sequel/database.rb +1 -1
  241. data/lib/ddtrace/contrib/sequel/ext.rb +5 -2
  242. data/lib/ddtrace/contrib/sequel/integration.rb +8 -2
  243. data/lib/ddtrace/contrib/sequel/patcher.rb +4 -10
  244. data/lib/ddtrace/contrib/sequel/utils.rb +19 -1
  245. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +7 -2
  246. data/lib/ddtrace/contrib/shoryuken/ext.rb +5 -2
  247. data/lib/ddtrace/contrib/shoryuken/integration.rb +11 -7
  248. data/lib/ddtrace/contrib/shoryuken/patcher.rb +4 -10
  249. data/lib/ddtrace/contrib/shoryuken/tracer.rb +4 -0
  250. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +12 -2
  251. data/lib/ddtrace/contrib/sidekiq/ext.rb +8 -2
  252. data/lib/ddtrace/contrib/sidekiq/integration.rb +5 -3
  253. data/lib/ddtrace/contrib/sidekiq/patcher.rb +19 -18
  254. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +12 -3
  255. data/lib/ddtrace/contrib/sidekiq/tracing.rb +19 -2
  256. data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +7 -2
  257. data/lib/ddtrace/contrib/sinatra/env.rb +25 -4
  258. data/lib/ddtrace/contrib/sinatra/ext.rb +11 -2
  259. data/lib/ddtrace/contrib/sinatra/integration.rb +5 -3
  260. data/lib/ddtrace/contrib/sinatra/patcher.rb +5 -10
  261. data/lib/ddtrace/contrib/sinatra/tracer.rb +79 -34
  262. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +48 -15
  263. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +32 -0
  264. data/lib/ddtrace/contrib/sneakers/ext.rb +22 -0
  265. data/lib/ddtrace/contrib/sneakers/integration.rb +41 -0
  266. data/lib/ddtrace/contrib/sneakers/patcher.rb +24 -0
  267. data/lib/ddtrace/contrib/sneakers/tracer.rb +58 -0
  268. data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +7 -2
  269. data/lib/ddtrace/contrib/sucker_punch/ext.rb +5 -2
  270. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +14 -0
  271. data/lib/ddtrace/contrib/sucker_punch/integration.rb +5 -3
  272. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +8 -14
  273. data/lib/ddtrace/correlation.rb +15 -5
  274. data/lib/ddtrace/diagnostics/environment_logger.rb +278 -0
  275. data/lib/ddtrace/diagnostics/health.rb +11 -8
  276. data/lib/ddtrace/encoding.rb +15 -11
  277. data/lib/ddtrace/environment.rb +21 -3
  278. data/lib/ddtrace/event.rb +52 -0
  279. data/lib/ddtrace/ext/analytics.rb +1 -0
  280. data/lib/ddtrace/ext/correlation.rb +11 -0
  281. data/lib/ddtrace/ext/diagnostics.rb +11 -0
  282. data/lib/ddtrace/ext/environment.rb +16 -0
  283. data/lib/ddtrace/ext/forced_tracing.rb +1 -1
  284. data/lib/ddtrace/ext/sampling.rb +16 -0
  285. data/lib/ddtrace/ext/transport.rb +1 -0
  286. data/lib/ddtrace/logger.rb +4 -3
  287. data/lib/ddtrace/metrics.rb +12 -5
  288. data/lib/ddtrace/monkey.rb +1 -1
  289. data/lib/ddtrace/opentelemetry/extensions.rb +13 -0
  290. data/lib/ddtrace/opentelemetry/span.rb +33 -0
  291. data/lib/ddtrace/opentracer/global_tracer.rb +1 -1
  292. data/lib/ddtrace/pin.rb +40 -16
  293. data/lib/ddtrace/pipeline.rb +1 -1
  294. data/lib/ddtrace/pipeline/span_filter.rb +15 -15
  295. data/lib/ddtrace/propagation/http_propagator.rb +2 -2
  296. data/lib/ddtrace/runtime/cgroup.rb +1 -1
  297. data/lib/ddtrace/runtime/container.rb +1 -1
  298. data/lib/ddtrace/runtime/metrics.rb +23 -6
  299. data/lib/ddtrace/sampler.rb +126 -29
  300. data/lib/ddtrace/sampling.rb +2 -0
  301. data/lib/ddtrace/sampling/matcher.rb +57 -0
  302. data/lib/ddtrace/sampling/rate_limiter.rb +127 -0
  303. data/lib/ddtrace/sampling/rule.rb +61 -0
  304. data/lib/ddtrace/sampling/rule_sampler.rb +125 -0
  305. data/lib/ddtrace/span.rb +54 -7
  306. data/lib/ddtrace/sync_writer.rb +13 -8
  307. data/lib/ddtrace/tracer.rb +72 -92
  308. data/lib/ddtrace/transport/http.rb +16 -1
  309. data/lib/ddtrace/transport/http/adapters/net.rb +8 -0
  310. data/lib/ddtrace/transport/http/adapters/test.rb +6 -0
  311. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +4 -0
  312. data/lib/ddtrace/transport/http/api/instance.rb +4 -0
  313. data/lib/ddtrace/transport/http/builder.rb +3 -5
  314. data/lib/ddtrace/transport/http/client.rb +7 -64
  315. data/lib/ddtrace/transport/http/response.rb +1 -1
  316. data/lib/ddtrace/transport/http/statistics.rb +1 -1
  317. data/lib/ddtrace/transport/http/traces.rb +10 -7
  318. data/lib/ddtrace/transport/io.rb +26 -0
  319. data/lib/ddtrace/transport/io/client.rb +76 -0
  320. data/lib/ddtrace/transport/io/response.rb +25 -0
  321. data/lib/ddtrace/transport/io/traces.rb +91 -0
  322. data/lib/ddtrace/transport/response.rb +11 -0
  323. data/lib/ddtrace/transport/statistics.rb +2 -2
  324. data/lib/ddtrace/transport/traces.rb +160 -10
  325. data/lib/ddtrace/utils.rb +1 -1
  326. data/lib/ddtrace/version.rb +2 -2
  327. data/lib/ddtrace/worker.rb +20 -0
  328. data/lib/ddtrace/workers.rb +5 -13
  329. data/lib/ddtrace/workers/async.rb +165 -0
  330. data/lib/ddtrace/workers/loop.rb +105 -0
  331. data/lib/ddtrace/workers/polling.rb +48 -0
  332. data/lib/ddtrace/workers/queue.rb +39 -0
  333. data/lib/ddtrace/workers/runtime_metrics.rb +47 -0
  334. data/lib/ddtrace/workers/trace_writer.rb +202 -0
  335. data/lib/ddtrace/writer.rb +56 -38
  336. metadata +185 -25
  337. data/lib/ddtrace/provider.rb +0 -21
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.required_ruby_version = ">= #{Datadog::VERSION::MINIMUM_RUBY_VERSION}"
11
11
  spec.authors = ['lightstep']
12
12
  spec.email = ['support@lightstep.com']
13
-
13
+ spec.required_rubygems_version = '>= 2.0.0'
14
14
  spec.summary = 'LightStep fork of dd-trace for tracing code for your Ruby applications'
15
15
  spec.description = <<-EOS.gsub(/^[\s]+/, '')
16
16
  ls-trace is LightStep's fork of Datadog’s tracing client for Ruby. It
@@ -46,18 +46,27 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'rspec', '~> 3.0'
47
47
  spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
48
48
  spec.add_development_dependency 'minitest', '= 5.10.1'
49
+ spec.add_development_dependency 'minitest-around', '0.5.0'
50
+ spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
49
51
  spec.add_development_dependency 'appraisal', '~> 2.2'
50
52
  spec.add_development_dependency 'yard', '~> 0.9'
51
53
  spec.add_development_dependency 'webmock', '~> 2.0'
52
54
  spec.add_development_dependency 'builder'
53
- spec.add_development_dependency 'ruby-prof'
54
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
55
+ if RUBY_PLATFORM != 'java'
56
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
57
+ else
58
+ spec.add_development_dependency 'jdbc-sqlite3', '~> 3'
59
+ end
55
60
  spec.add_development_dependency 'climate_control', '~> 0.2.0'
56
61
 
57
62
  # locking transitive dependency of webmock
58
63
  spec.add_development_dependency 'addressable', '~> 2.4.0'
64
+ spec.add_development_dependency 'benchmark-ips', '~> 2.8'
65
+ spec.add_development_dependency 'benchmark-memory', '~> 0.1'
66
+ spec.add_development_dependency 'memory_profiler', '~> 0.9'
59
67
  spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
60
68
  spec.add_development_dependency 'pry', '~> 0.10.4'
61
69
  spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
62
- spec.add_development_dependency 'warning' if RUBY_VERSION >= '2.5.0'
70
+ spec.add_development_dependency 'simplecov', '~> 0.17'
71
+ spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
63
72
  end
@@ -1,5 +1,6 @@
1
1
  version: '3.2'
2
2
  services:
3
+ # MRI
3
4
  tracer-2.0:
4
5
  image: palazzem/docker-library:ddtrace_rb_2_0_0
5
6
  command: /bin/bash
@@ -10,6 +11,7 @@ services:
10
11
  - mongodb
11
12
  - mysql
12
13
  - postgres
14
+ - presto
13
15
  - redis
14
16
  env_file: ./.env
15
17
  environment:
@@ -21,6 +23,7 @@ services:
21
23
  - TEST_MONGODB_HOST=mongodb
22
24
  - TEST_MYSQL_HOST=mysql
23
25
  - TEST_POSTGRES_HOST=postgres
26
+ - TEST_PRESTO_HOST=presto
24
27
  - TEST_REDIS_HOST=redis
25
28
  stdin_open: true
26
29
  tty: true
@@ -38,6 +41,7 @@ services:
38
41
  - mongodb
39
42
  - mysql
40
43
  - postgres
44
+ - presto
41
45
  - redis
42
46
  env_file: ./.env
43
47
  environment:
@@ -49,6 +53,8 @@ services:
49
53
  - TEST_MONGODB_HOST=mongodb
50
54
  - TEST_MYSQL_HOST=mysql
51
55
  - TEST_POSTGRES_HOST=postgres
56
+ - TEST_PRESTO_HOST=presto
57
+ - TEST_PRESTO_PORT=8080
52
58
  - TEST_REDIS_HOST=redis
53
59
  stdin_open: true
54
60
  tty: true
@@ -66,6 +72,7 @@ services:
66
72
  - mongodb
67
73
  - mysql
68
74
  - postgres
75
+ - presto
69
76
  - redis
70
77
  env_file: ./.env
71
78
  environment:
@@ -77,6 +84,8 @@ services:
77
84
  - TEST_MONGODB_HOST=mongodb
78
85
  - TEST_MYSQL_HOST=mysql
79
86
  - TEST_POSTGRES_HOST=postgres
87
+ - TEST_PRESTO_HOST=presto
88
+ - TEST_PRESTO_PORT=8080
80
89
  - TEST_REDIS_HOST=redis
81
90
  stdin_open: true
82
91
  tty: true
@@ -94,6 +103,7 @@ services:
94
103
  - mongodb
95
104
  - mysql
96
105
  - postgres
106
+ - presto
97
107
  - redis
98
108
  env_file: ./.env
99
109
  environment:
@@ -105,6 +115,8 @@ services:
105
115
  - TEST_MONGODB_HOST=mongodb
106
116
  - TEST_MYSQL_HOST=mysql
107
117
  - TEST_POSTGRES_HOST=postgres
118
+ - TEST_PRESTO_HOST=presto
119
+ - TEST_PRESTO_PORT=8080
108
120
  - TEST_REDIS_HOST=redis
109
121
  stdin_open: true
110
122
  tty: true
@@ -122,6 +134,7 @@ services:
122
134
  - mongodb
123
135
  - mysql
124
136
  - postgres
137
+ - presto
125
138
  - redis
126
139
  env_file: ./.env
127
140
  environment:
@@ -133,6 +146,8 @@ services:
133
146
  - TEST_MONGODB_HOST=mongodb
134
147
  - TEST_MYSQL_HOST=mysql
135
148
  - TEST_POSTGRES_HOST=postgres
149
+ - TEST_PRESTO_HOST=presto
150
+ - TEST_PRESTO_PORT=8080
136
151
  - TEST_REDIS_HOST=redis
137
152
  stdin_open: true
138
153
  tty: true
@@ -150,6 +165,7 @@ services:
150
165
  - mongodb
151
166
  - mysql
152
167
  - postgres
168
+ - presto
153
169
  - redis
154
170
  env_file: ./.env
155
171
  environment:
@@ -161,6 +177,8 @@ services:
161
177
  - TEST_MONGODB_HOST=mongodb
162
178
  - TEST_MYSQL_HOST=mysql
163
179
  - TEST_POSTGRES_HOST=postgres
180
+ - TEST_PRESTO_HOST=presto
181
+ - TEST_PRESTO_PORT=8080
164
182
  - TEST_REDIS_HOST=redis
165
183
  stdin_open: true
166
184
  tty: true
@@ -178,6 +196,7 @@ services:
178
196
  - mongodb
179
197
  - mysql
180
198
  - postgres
199
+ - presto
181
200
  - redis
182
201
  env_file: ./.env
183
202
  environment:
@@ -189,6 +208,8 @@ services:
189
208
  - TEST_MONGODB_HOST=mongodb
190
209
  - TEST_MYSQL_HOST=mysql
191
210
  - TEST_POSTGRES_HOST=postgres
211
+ - TEST_PRESTO_HOST=presto
212
+ - TEST_PRESTO_PORT=8080
192
213
  - TEST_REDIS_HOST=redis
193
214
  stdin_open: true
194
215
  tty: true
@@ -196,12 +217,75 @@ services:
196
217
  - .:/app
197
218
  - bundle-2.6:/usr/local/bundle
198
219
  - gemfiles-2.6:/app/gemfiles
220
+ tracer-2.7:
221
+ image: marcotc/docker-library:ddtrace_rb_2_7_0
222
+ command: /bin/bash
223
+ depends_on:
224
+ - ddagent
225
+ - elasticsearch
226
+ - memcached
227
+ - mongodb
228
+ - mysql
229
+ - postgres
230
+ - presto
231
+ - redis
232
+ env_file: ./.env
233
+ environment:
234
+ - BUNDLE_GEMFILE=/app/Gemfile
235
+ - DD_AGENT_HOST=ddagent
236
+ - TEST_DATADOG_INTEGRATION=1
237
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
238
+ - TEST_MEMCACHED_HOST=memcached
239
+ - TEST_MONGODB_HOST=mongodb
240
+ - TEST_MYSQL_HOST=mysql
241
+ - TEST_POSTGRES_HOST=postgres
242
+ - TEST_PRESTO_HOST=presto
243
+ - TEST_PRESTO_PORT=8080
244
+ - TEST_REDIS_HOST=redis
245
+ stdin_open: true
246
+ tty: true
247
+ volumes:
248
+ - .:/app
249
+ - bundle-2.7:/usr/local/bundle
250
+ - gemfiles-2.7:/app/gemfiles
251
+ # JRuby
252
+ tracer-jruby-9.2:
253
+ image: marcotc/docker-library:ddtrace_rb_jruby_9_2
254
+ command: /bin/bash
255
+ depends_on:
256
+ - ddagent
257
+ - elasticsearch
258
+ - memcached
259
+ - mongodb
260
+ - mysql
261
+ - postgres
262
+ - presto
263
+ - redis
264
+ env_file: ./.env
265
+ environment:
266
+ - BUNDLE_GEMFILE=/app/Gemfile
267
+ - DD_AGENT_HOST=ddagent
268
+ - TEST_DATADOG_INTEGRATION=1
269
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
270
+ - TEST_MEMCACHED_HOST=memcached
271
+ - TEST_MONGODB_HOST=mongodb
272
+ - TEST_MYSQL_HOST=mysql
273
+ - TEST_POSTGRES_HOST=postgres
274
+ - TEST_PRESTO_HOST=presto
275
+ - TEST_PRESTO_PORT=8080
276
+ - TEST_REDIS_HOST=redis
277
+ stdin_open: true
278
+ tty: true
279
+ volumes:
280
+ - .:/app
281
+ - bundle-jruby-9.2:/usr/local/bundle
282
+ - gemfiles-jruby-9.2:/app/gemfiles
199
283
  ddagent:
200
- image: datadog/docker-dd-agent
284
+ image: datadog/agent
201
285
  environment:
202
286
  - DD_APM_ENABLED=true
203
287
  - DD_BIND_HOST=0.0.0.0
204
- - DD_API_KEY=invalid_key_but_this_is_fine
288
+ - DD_API_KEY=00000000000000000000000000000000
205
289
  expose:
206
290
  - "8125/udp"
207
291
  - "8126"
@@ -253,6 +337,12 @@ services:
253
337
  - "5432"
254
338
  ports:
255
339
  - "${TEST_POSTGRES_PORT}:5432"
340
+ presto:
341
+ image: prestosql/presto
342
+ expose:
343
+ - "8080"
344
+ ports:
345
+ - "${TEST_PRESTO_PORT}:8080"
256
346
  redis:
257
347
  image: redis:3.0
258
348
  expose:
@@ -267,6 +357,8 @@ volumes:
267
357
  bundle-2.4:
268
358
  bundle-2.5:
269
359
  bundle-2.6:
360
+ bundle-2.7:
361
+ bundle-jruby-9.2:
270
362
  gemfiles-2.0:
271
363
  gemfiles-2.1:
272
364
  gemfiles-2.2:
@@ -274,3 +366,5 @@ volumes:
274
366
  gemfiles-2.4:
275
367
  gemfiles-2.5:
276
368
  gemfiles-2.6:
369
+ gemfiles-2.7:
370
+ gemfiles-jruby-9.2:
@@ -98,6 +98,22 @@ $ bundle exec appraisal contrib rake spec:redis'[--seed,1234]'
98
98
 
99
99
  This can be useful for replicating conditions from CI or isolating certain tests.
100
100
 
101
+ **Checking test coverage**
102
+
103
+ You can check test code coverage by creating a report _after_ running a test suite:
104
+ ```
105
+ # Run the desired test suite
106
+ $ bundle exec appraisal contrib rake spec:redis
107
+ # Generate report for the suite executed
108
+ $ bundle exec rake coverage:report
109
+ ```
110
+
111
+ A webpage will be generated at `coverage/report/index.html` with the resulting report.
112
+
113
+ Because you are likely not running all tests locally, your report will contain partial coverage results.
114
+ You *must* check the CI step `coverage` for the complete test coverage report, ensuring coverage is not
115
+ decreased.
116
+
101
117
  ### Checking code quality
102
118
 
103
119
  **Linting**
@@ -183,7 +199,7 @@ Then pass an adapter instance to the tracer configuration:
183
199
 
184
200
  ```ruby
185
201
  Datadog.configure do |c|
186
- c.tracer transport_options: proc { |t|
202
+ c.tracer.transport_options = proc { |t|
187
203
  # By name
188
204
  t.adapter :custom
189
205
 
@@ -26,6 +26,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
26
26
  - [Quickstart for OpenTracing](#quickstart-for-opentracing)
27
27
  - [Manual instrumentation](#manual-instrumentation)
28
28
  - [Integration instrumentation](#integration-instrumentation)
29
+ - [Action Cable](#action-cable)
29
30
  - [Action View](#action-view)
30
31
  - [Active Model Serializers](#active-model-serializers)
31
32
  - [Action Pack](#action-pack)
@@ -35,16 +36,19 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
35
36
  - [Concurrent Ruby](#concurrent-ruby)
36
37
  - [Dalli](#dalli)
37
38
  - [DelayedJob](#delayedjob)
38
- - [Elastic Search](#elastic-search)
39
+ - [Elasticsearch](#elasticsearch)
39
40
  - [Ethon & Typhoeus](#ethon)
40
41
  - [Excon](#excon)
41
42
  - [Faraday](#faraday)
42
43
  - [Grape](#grape)
43
44
  - [GraphQL](#graphql)
44
45
  - [gRPC](#grpc)
46
+ - [http.rb](#http-rb)
45
47
  - [MongoDB](#mongodb)
46
48
  - [MySQL2](#mysql2)
47
- - [Net/HTTP](#nethttp)
49
+ - [Net/HTTP](#net-http)
50
+ - [Presto](#presto)
51
+ - [Que](#que)
48
52
  - [Racecar](#racecar)
49
53
  - [Rack](#rack)
50
54
  - [Rails](#rails)
@@ -56,6 +60,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
56
60
  - [Sequel](#sequel)
57
61
  - [Sidekiq](#sidekiq)
58
62
  - [Sinatra](#sinatra)
63
+ - [Sneakers](#sneakers)
59
64
  - [Sucker Punch](#sucker-punch)
60
65
  - [Advanced configuration](#advanced-configuration)
61
66
  - [Tracer settings](#tracer-settings)
@@ -80,16 +85,17 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
80
85
 
81
86
  | Type | Documentation | Version | Support type | Gem version support |
82
87
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
83
- | MRI | https://www.ruby-lang.org/ | 2.6 | Full | Latest |
88
+ | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
89
+ | | | 2.6 | Full | Latest |
84
90
  | | | 2.5 | Full | Latest |
85
91
  | | | 2.4 | Full | Latest |
86
92
  | | | 2.3 | Full | Latest |
87
93
  | | | 2.2 | Full | Latest |
88
94
  | | | 2.1 | Full | Latest |
89
95
  | | | 2.0 | Full | Latest |
90
- | | | 1.9.3 | Maintenance (until August 6th, 2020) | < 0.27.0 |
91
- | | | 1.9.1 | Maintenance (until August 6th, 2020) | < 0.27.0 |
92
- | JRuby | http://jruby.org/ | 9.1.5 | Alpha | Latest |
96
+ | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
97
+ | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
98
+ | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
93
99
 
94
100
  **Supported web servers**:
95
101
 
@@ -322,39 +328,66 @@ end
322
328
 
323
329
  For a list of available integrations, and their configuration options, please refer to the following:
324
330
 
325
- | Name | Key | Versions Supported | How to configure | Gem source |
326
- | ------------------------ | -------------------------- | ------------------------ | ----------------------------------- | ------------------------------------------------------------------------------ |
327
- | Action View | `action_view` | `>= 3.2` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
328
- | Active Model Serializers | `active_model_serializers` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
329
- | Action Pack | `action_pack` | `>= 3.2` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
330
- | Active Record | `active_record` | `>= 3.2` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
331
- | Active Support | `active_support` | `>= 3.2` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
332
- | AWS | `aws` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
333
- | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
334
- | Dalli | `dalli` | `>= 2.7` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
335
- | DelayedJob | `delayed_job` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
336
- | Elastic Search | `elasticsearch` | `>= 6.0` | *[Link](#elastic-search)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
337
- | Ethon | `ethon` | `>= 0.11.0` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
338
- | Excon | `excon` | `>= 0.62` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
339
- | Faraday | `faraday` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
340
- | Grape | `grape` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
341
- | GraphQL | `graphql` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
342
- | gRPC | `grpc` | `>= 1.10` | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
343
- | MongoDB | `mongo` | `>= 2.0` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
344
- | MySQL2 | `mysql2` | `>= 0.3.21` | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
345
- | Net/HTTP | `http` | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
346
- | Racecar | `racecar` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
347
- | Rack | `rack` | `>= 1.4.7` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
348
- | Rails | `rails` | `>= 3.2` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
349
- | Rake | `rake` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
350
- | Redis | `redis` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
351
- | Resque | `resque` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
352
- | Rest Client | `rest-client` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
353
- | Sequel | `sequel` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
354
- | Shoryuken | `shoryuken` | `>= 4.0.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
355
- | Sidekiq | `sidekiq` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
356
- | Sinatra | `sinatra` | `>= 1.4.5` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
357
- | Sucker Punch | `sucker_punch` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
331
+ | Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
332
+ | ------------------------ | -------------------------- | ------------------------ | --------------------------| ----------------------------------- | ------------------------------------------------------------------------------ |
333
+ | Action Cable | `action_cable` | `>= 5.0` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
334
+ | Action View | `action_view` | `>= 3.0` | `>= 3.0` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
335
+ | Active Model Serializers | `active_model_serializers` | `>= 0.9` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
336
+ | Action Pack | `action_pack` | `>= 3.0` | `>= 3.0` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
337
+ | Active Record | `active_record` | `>= 3.0` | `>= 3.0` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
338
+ | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
339
+ | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
340
+ | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
341
+ | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
342
+ | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
343
+ | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
344
+ | Ethon | `ethon` | `>= 0.11` | `>= 0.11` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
345
+ | Excon | `excon` | `>= 0.50` | `>= 0.50` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
346
+ | Faraday | `faraday` | `>= 0.14` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
347
+ | Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
348
+ | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
349
+ | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
350
+ | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
351
+ | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
352
+ | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
353
+ | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
354
+ | Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
355
+ | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
356
+ | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
357
+ | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
358
+ | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
359
+ | Rails | `rails` | `>= 3.0` | `>= 3.0` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
360
+ | Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
361
+ | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
362
+ | Resque | `resque` | `>= 1.0, < 2.0` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
363
+ | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
364
+ | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
365
+ | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
366
+ | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
367
+ | Sinatra | `sinatra` | `>= 1.4` | `>= 1.4` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
368
+ | Sneakers | `sneakers` | `>= 2.12.0` | `>= 2.12.0` | *[Link](#sneakers)* | *[Link](https://github.com/jondot/sneakers)* |
369
+ | Sucker Punch | `sucker_punch` | `>= 2.0` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
370
+
371
+ ### Action Cable
372
+
373
+ The Action Cable integration traces broadcast messages and channel actions.
374
+
375
+ You can enable it through `Datadog.configure`:
376
+
377
+ ```ruby
378
+ require 'ddtrace'
379
+
380
+ Datadog.configure do |c|
381
+ c.use :action_cable, options
382
+ end
383
+ ```
384
+
385
+ Where `options` is an optional `Hash` that accepts the following parameters:
386
+
387
+ | Key | Description | Default |
388
+ | --- | ----------- | ------- |
389
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
390
+ | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
358
391
 
359
392
  ### Action View
360
393
 
@@ -375,7 +408,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
375
408
  | ---| --- | --- |
376
409
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
377
410
  | `service_name` | Service name used for rendering instrumentation. | `action_view` |
378
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
379
411
  | `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/'` |
380
412
 
381
413
  ### Active Model Serializers
@@ -398,7 +430,6 @@ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
398
430
  | --- | ----------- | ------- |
399
431
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
400
432
  | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
401
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
402
433
 
403
434
  ### Action Pack
404
435
 
@@ -419,7 +450,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
419
450
  | ---| --- | --- |
420
451
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
421
452
  | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
422
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
423
453
 
424
454
  ### Active Record
425
455
 
@@ -447,9 +477,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
447
477
  | Key | Description | Default |
448
478
  | ---| --- | --- |
449
479
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
450
- | `orm_service_name` | Service name used for the Ruby ORM portion of `active_record` instrumentation. Overrides service name for ORM spans if explicitly set, which otherwise inherit their service from their parent. | `'active_record'` |
480
+ | `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'`) |
451
481
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
452
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
453
482
 
454
483
  **Configuring trace settings per database**
455
484
 
@@ -511,7 +540,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
511
540
  | ---| --- | --- |
512
541
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
513
542
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
514
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
515
543
 
516
544
  ### AWS
517
545
 
@@ -535,7 +563,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
535
563
  | --- | ----------- | ------- |
536
564
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
537
565
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
538
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
539
566
 
540
567
  ### Concurrent Ruby
541
568
 
@@ -562,7 +589,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
562
589
  | Key | Description | Default |
563
590
  | --- | ----------- | ------- |
564
591
  | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
565
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
566
592
 
567
593
  ### Dalli
568
594
 
@@ -588,7 +614,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
588
614
  | --- | ----------- | ------- |
589
615
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
590
616
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
591
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
592
617
 
593
618
  ### DelayedJob
594
619
 
@@ -610,9 +635,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
610
635
  | --- | ----------- | ------- |
611
636
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
612
637
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
613
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
614
638
 
615
- ### Elastic Search
639
+ ### Elasticsearch
616
640
 
617
641
  The Elasticsearch integration will trace any call to `perform_request` in the `Client` object:
618
642
 
@@ -624,7 +648,7 @@ Datadog.configure do |c|
624
648
  c.use :elasticsearch, options
625
649
  end
626
650
 
627
- # Perform a query to ElasticSearch
651
+ # Perform a query to Elasticsearch
628
652
  client = Elasticsearch::Client.new url: 'http://127.0.0.1:9200'
629
653
  response = client.perform_request 'GET', '_cluster/health'
630
654
  ```
@@ -636,7 +660,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
636
660
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
637
661
  | `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. | `{}` |
638
662
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
639
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
640
663
 
641
664
  ### Ethon
642
665
 
@@ -647,6 +670,12 @@ require 'ddtrace'
647
670
 
648
671
  Datadog.configure do |c|
649
672
  c.use :ethon, options
673
+
674
+ # optionally, specify a different service name for hostnames matching a regex
675
+ c.use :ethon, describes: /user-[^.]+\.example\.com/ do |ethon|
676
+ ethon.service_name = 'user.example.com'
677
+ ethon.split_by_domain = false # Only necessary if split_by_domain is true by default
678
+ end
650
679
  end
651
680
  ```
652
681
 
@@ -657,7 +686,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
657
686
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
658
687
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
659
688
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
660
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
689
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
661
690
 
662
691
  ### Excon
663
692
 
@@ -670,6 +699,12 @@ require 'ddtrace'
670
699
  # Configure default Excon tracing behavior
671
700
  Datadog.configure do |c|
672
701
  c.use :excon, options
702
+
703
+ # optionally, specify a different service name for hostnames matching a regex
704
+ c.use :excon, describes: /user-[^.]+\.example\.com/ do |excon|
705
+ excon.service_name = 'user.example.com'
706
+ excon.split_by_domain = false # Only necessary if split_by_domain is true by default
707
+ end
673
708
  end
674
709
 
675
710
  connection = Excon.new('https://example.com')
@@ -685,7 +720,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
685
720
  | `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` |
686
721
  | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
687
722
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
688
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
689
723
 
690
724
  **Configuring connections to use different settings**
691
725
 
@@ -723,9 +757,15 @@ require 'ddtrace'
723
757
  # Configure default Faraday tracing behavior
724
758
  Datadog.configure do |c|
725
759
  c.use :faraday, options
760
+
761
+ # optionally, specify a different service name for hostnames matching a regex
762
+ c.use :faraday, describes: /user-[^.]+\.example\.com/ do |faraday|
763
+ faraday.service_name = 'user.example.com'
764
+ faraday.split_by_domain = false # Only necessary if split_by_domain is true by default
765
+ end
726
766
  end
727
767
 
728
- # Configure Faraday tracing behavior for single connection
768
+ # In case you want to override the global configuration for a certain client instance
729
769
  connection = Faraday.new('https://example.com') do |builder|
730
770
  builder.use(:ddtrace, options)
731
771
  builder.adapter Faraday.default_adapter
@@ -743,7 +783,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
743
783
  | `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` |
744
784
  | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
745
785
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
746
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
747
786
 
748
787
  ### Grape
749
788
 
@@ -776,7 +815,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
776
815
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
777
816
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
778
817
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
779
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
780
818
 
781
819
  ### GraphQL
782
820
 
@@ -801,13 +839,23 @@ The `use :graphql` method accepts the following parameters. Additional options c
801
839
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
802
840
  | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
803
841
  | `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. | `[]` |
804
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
805
842
 
806
843
  **Manually configuring GraphQL schemas**
807
844
 
808
845
  If you prefer to individually configure the tracer settings for a schema (e.g. you have multiple schemas with different service names), in the schema definition, you can add the following [using the GraphQL API](http://graphql-ruby.org/queries/tracing.html):
809
846
 
810
847
  ```ruby
848
+ # Class-based schema
849
+ class YourSchema < GraphQL::Schema
850
+ use(
851
+ GraphQL::Tracing::DataDogTracing,
852
+ service: 'graphql'
853
+ )
854
+ end
855
+ ```
856
+
857
+ ```ruby
858
+ # .define-style schema
811
859
  YourSchema = GraphQL::Schema.define do
812
860
  use(
813
861
  GraphQL::Tracing::DataDogTracing,
@@ -819,6 +867,15 @@ end
819
867
  Or you can modify an already defined schema:
820
868
 
821
869
  ```ruby
870
+ # Class-based schema
871
+ YourSchema.use(
872
+ GraphQL::Tracing::DataDogTracing,
873
+ service: 'graphql'
874
+ )
875
+ ```
876
+
877
+ ```ruby
878
+ # .define-style schema
822
879
  YourSchema.define do
823
880
  use(
824
881
  GraphQL::Tracing::DataDogTracing,
@@ -860,7 +917,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
860
917
  | --- | ----------- | ------- |
861
918
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
862
919
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
863
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
864
920
 
865
921
  **Configuring clients to use different settings**
866
922
 
@@ -880,6 +936,56 @@ alternate_client = Demo::Echo::Service.rpc_stub_class.new(
880
936
 
881
937
  The integration will ensure that the `configured_interceptor` establishes a unique tracing setup for that client instance.
882
938
 
939
+ ### http.rb
940
+
941
+ The http.rb integration will trace any HTTP call using the Http.rb gem.
942
+
943
+ ```ruby
944
+ require 'http'
945
+ require 'ddtrace'
946
+ Datadog.configure do |c|
947
+ c.use :httprb, options
948
+ # optionally, specify a different service name for hostnames matching a regex
949
+ c.use :httprb, describes: /user-[^.]+\.example\.com/ do |httprb|
950
+ httprb.service_name = 'user.example.com'
951
+ httprb.split_by_domain = false # Only necessary if split_by_domain is true by default
952
+ end
953
+ end
954
+ ```
955
+
956
+ Where `options` is an optional `Hash` that accepts the following parameters:
957
+
958
+ | Key | Description | Default |
959
+ | --- | ----------- | ------- |
960
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
961
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
962
+ | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
963
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
964
+
965
+ ### Kafka
966
+
967
+ The Kafka integration provides tracing of the `ruby-kafka` gem:
968
+
969
+ You can enable it through `Datadog.configure`:
970
+
971
+ ```ruby
972
+ require 'active_support/notifications' # required to enable 'ruby-kafka' instrumentation
973
+ require 'kafka'
974
+ require 'ddtrace'
975
+
976
+ Datadog.configure do |c|
977
+ c.use :kafka, options
978
+ end
979
+ ```
980
+
981
+ Where `options` is an optional `Hash` that accepts the following parameters:
982
+
983
+ | Key | Description | Default |
984
+ | --- | ----------- | ------- |
985
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
986
+ | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
987
+ | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
988
+
883
989
  ### MongoDB
884
990
 
885
991
  The integration traces any `Command` that is sent from the [MongoDB Ruby Driver](https://github.com/mongodb/mongo-ruby-driver) to a MongoDB cluster. By extension, Object Document Mappers (ODM) such as Mongoid are automatically instrumented if they use the official Ruby driver. To activate the integration, simply:
@@ -908,7 +1014,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
908
1014
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
909
1015
  | `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] }` |
910
1016
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
911
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
912
1017
 
913
1018
  ### MySQL2
914
1019
 
@@ -932,7 +1037,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
932
1037
  | --- | ----------- | ------- |
933
1038
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
934
1039
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
935
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
936
1040
 
937
1041
  ### Net/HTTP
938
1042
 
@@ -944,6 +1048,12 @@ require 'ddtrace'
944
1048
 
945
1049
  Datadog.configure do |c|
946
1050
  c.use :http, options
1051
+
1052
+ # optionally, specify a different service name for hostnames matching a regex
1053
+ c.use :http, describes: /user-[^.]+\.example\.com/ do |http|
1054
+ http.service_name = 'user.example.com'
1055
+ http.split_by_domain = false # Only necessary if split_by_domain is true by default
1056
+ end
947
1057
  end
948
1058
 
949
1059
  Net::HTTP.start('127.0.0.1', 8080) do |http|
@@ -961,7 +1071,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
961
1071
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
962
1072
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
963
1073
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
964
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1074
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
965
1075
 
966
1076
  If you wish to configure each connection object individually, you may use the `Datadog.configure` as it follows:
967
1077
 
@@ -970,6 +1080,62 @@ client = Net::HTTP.new(host, port)
970
1080
  Datadog.configure(client, options)
971
1081
  ```
972
1082
 
1083
+ ### Presto
1084
+
1085
+ The Presto integration traces any SQL command sent through `presto-client` gem.
1086
+
1087
+ ```ruby
1088
+ require 'presto-client'
1089
+ require 'ddtrace'
1090
+
1091
+ Datadog.configure do |c|
1092
+ c.use :presto, options
1093
+ end
1094
+
1095
+ client = Presto::Client.new(
1096
+ server: "localhost:8880",
1097
+ ssl: {verify: false},
1098
+ catalog: "native",
1099
+ schema: "default",
1100
+ time_zone: "US/Pacific",
1101
+ language: "English",
1102
+ http_debug: true,
1103
+ )
1104
+
1105
+ client.run("select * from system.nodes")
1106
+ ```
1107
+
1108
+ Where `options` is an optional `Hash` that accepts the following parameters:
1109
+
1110
+ | Key | Description | Default |
1111
+ | --- | ----------- | ------- |
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
+ | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1114
+
1115
+ ### Que
1116
+
1117
+ The Que integration is a middleware which will trace job executions.
1118
+
1119
+ You can enable it through `Datadog.configure`:
1120
+
1121
+ ```ruby
1122
+ require 'ddtrace'
1123
+
1124
+ Datadog.configure do |c|
1125
+ c.use :que, options
1126
+ end
1127
+ ```
1128
+
1129
+ Where `options` is an optional `Hash` that accepts the following parameters:
1130
+
1131
+ | Key | Description | Default |
1132
+ | --- | ----------- | ------- |
1133
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1134
+ | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1135
+ | `service_name` | Service name used for `que` instrumentation | `'que'` |
1136
+ | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1137
+ | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1138
+
973
1139
  ### Racecar
974
1140
 
975
1141
  The Racecar integration provides tracing for Racecar jobs.
@@ -990,7 +1156,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
990
1156
  | --- | ----------- | ------- |
991
1157
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
992
1158
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
993
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
994
1159
 
995
1160
  ### Rack
996
1161
 
@@ -1031,10 +1196,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1031
1196
  | `quantize.fragment` | Defines behavior for URL fragments. Removes fragments by default. May be `:show` to show URL fragments. Option must be nested inside the `quantize` option. | `nil` |
1032
1197
  | `request_queuing` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | `false` |
1033
1198
  | `service_name` | Service name used for `rack` instrumentation | `'rack'` |
1034
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1035
1199
  | `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
1036
1200
 
1037
-
1038
1201
  **Configuring URL quantization behavior**
1039
1202
 
1040
1203
  ```ruby
@@ -1094,18 +1257,18 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1094
1257
  | `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
1095
1258
  | `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
1096
1259
  | `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/'` |
1097
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1260
+ | `log_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. | `false` |
1098
1261
 
1099
1262
  **Supported versions**
1100
1263
 
1101
- | Ruby Versions | Supported Rails Versions |
1102
- | ------------- | ------------------------ |
1103
- | 2.0 | 3.0 - 3.2 |
1104
- | 2.1 | 3.0 - 4.2 |
1105
- | 2.2 - 2.3 | 3.0 - 5.2 |
1106
- | 2.4 | 4.2.8 - 5.2 |
1107
- | 2.5 | 4.2.8 - 6.0 |
1108
- | 2.6 | 5.0 - 6.0 |
1264
+ | MRI Versions | JRuby Versions | Rails Versions |
1265
+ | ------------- | -------------- | -------------- |
1266
+ | 2.0 | | 3.0 - 3.2 |
1267
+ | 2.1 | | 3.0 - 4.2 |
1268
+ | 2.2 - 2.3 | | 3.0 - 5.2 |
1269
+ | 2.4 | | 4.2.8 - 5.2 |
1270
+ | 2.5 | | 4.2.8 - 6.0 |
1271
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.0 |
1109
1272
 
1110
1273
  ### Rake
1111
1274
 
@@ -1137,7 +1300,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1137
1300
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1138
1301
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1139
1302
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
1140
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1141
1303
 
1142
1304
  **Configuring task quantization behavior**
1143
1305
 
@@ -1196,11 +1358,17 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1196
1358
  | --- | ----------- | ------- |
1197
1359
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1198
1360
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1199
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1200
1361
 
1201
1362
  You can also set *per-instance* configuration as it follows:
1202
1363
 
1203
1364
  ```ruby
1365
+ require 'redis'
1366
+ require 'ddtrace'
1367
+
1368
+ Datadog.configure do |c|
1369
+ c.use :redis # Enabling integration instrumentation is still required
1370
+ end
1371
+
1204
1372
  customer_cache = Redis.new
1205
1373
  invoice_cache = Redis.new
1206
1374
 
@@ -1213,6 +1381,33 @@ customer_cache.get(...)
1213
1381
  invoice_cache.get(...)
1214
1382
  ```
1215
1383
 
1384
+ **Configuring trace settings per connection**
1385
+
1386
+ You can configure trace settings per connection by using the `describes` option:
1387
+
1388
+ ```ruby
1389
+ # Provide a `:describes` option with a connection key.
1390
+ # Any of the following keys are acceptable and equivalent to one another.
1391
+ # If a block is provided, it yields a Settings object that
1392
+ # accepts any of the configuration options listed above.
1393
+
1394
+ Datadog.configure do |c|
1395
+ # The default configuration for any redis client
1396
+ c.use :redis, service_name: 'redis-default'
1397
+
1398
+ # The configuration matching a given unix socket
1399
+ c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1400
+
1401
+ # Connection string
1402
+ c.use :redis, describes: { url: 'redis://127.0.0.1:6379/0' }, service_name: 'redis-connection-string'
1403
+ # Client host, port, db, scheme
1404
+ c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1405
+ # Only a subset of the connection hash
1406
+ c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
1407
+ c.use :redis, describes: { host: ENV['SIDEKIQ_CACHE_HOST'] }, service_name: 'redis-sidekiq'
1408
+ end
1409
+ ```
1410
+
1216
1411
  ### Resque
1217
1412
 
1218
1413
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1239,7 +1434,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1239
1434
  | --- | ----------- | ------- |
1240
1435
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1241
1436
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1242
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1243
1437
  | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1244
1438
 
1245
1439
  ### Rest Client
@@ -1262,7 +1456,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1262
1456
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1263
1457
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1264
1458
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1265
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1266
1459
 
1267
1460
  ### Sequel
1268
1461
 
@@ -1296,7 +1489,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1296
1489
  | --- | ----------- | ------- |
1297
1490
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1298
1491
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1299
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1300
1492
 
1301
1493
  Only Ruby 2.0+ is supported.
1302
1494
 
@@ -1333,7 +1525,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1333
1525
  | --- | ----------- | ------- |
1334
1526
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1335
1527
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1336
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1337
1528
 
1338
1529
  ### Sidekiq
1339
1530
 
@@ -1356,7 +1547,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1356
1547
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1357
1548
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1358
1549
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1359
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1550
+ | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1360
1551
 
1361
1552
  ### Sinatra
1362
1553
 
@@ -1364,6 +1555,8 @@ The Sinatra integration traces requests and template rendering.
1364
1555
 
1365
1556
  To start using the tracing client, make sure you import `ddtrace` and `use :sinatra` after either `sinatra` or `sinatra/base`, and before you define your application/routes:
1366
1557
 
1558
+ #### Classic application
1559
+
1367
1560
  ```ruby
1368
1561
  require 'sinatra'
1369
1562
  require 'ddtrace'
@@ -1377,7 +1570,40 @@ get '/' do
1377
1570
  end
1378
1571
  ```
1379
1572
 
1380
- Where `options` is an optional `Hash` that accepts the following parameters:
1573
+ #### Modular application
1574
+
1575
+ ```ruby
1576
+ require 'sinatra/base'
1577
+ require 'ddtrace'
1578
+
1579
+ Datadog.configure do |c|
1580
+ c.use :sinatra, options
1581
+ end
1582
+
1583
+ class NestedApp < Sinatra::Base
1584
+ register Datadog::Contrib::Sinatra::Tracer
1585
+
1586
+ get '/nested' do
1587
+ 'Hello from nested app!'
1588
+ end
1589
+ end
1590
+
1591
+ class App < Sinatra::Base
1592
+ register Datadog::Contrib::Sinatra::Tracer
1593
+
1594
+ use NestedApp
1595
+
1596
+ get '/' do
1597
+ 'Hello world!'
1598
+ end
1599
+ end
1600
+ ```
1601
+
1602
+ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before you mount your nested applications.
1603
+
1604
+ #### Instrumentation options
1605
+
1606
+ `options` is an optional `Hash` that accepts the following parameters:
1381
1607
 
1382
1608
  | Key | Description | Default |
1383
1609
  | --- | ----------- | ------- |
@@ -1386,7 +1612,29 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1386
1612
  | `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'] }` |
1387
1613
  | `resource_script_names` | Prepend resource names with script name | `false` |
1388
1614
  | `service_name` | Service name used for `sinatra` instrumentation | `'sinatra'` |
1389
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1615
+
1616
+ ### Sneakers
1617
+
1618
+ The Sneakers integration is a server-side middleware which will trace job executions.
1619
+
1620
+ You can enable it through `Datadog.configure`:
1621
+
1622
+ ```ruby
1623
+ require 'ddtrace'
1624
+
1625
+ Datadog.configure do |c|
1626
+ c.use :sneakers, options
1627
+ end
1628
+ ```
1629
+
1630
+ Where `options` is an optional `Hash` that accepts the following parameters:
1631
+
1632
+ | Key | Description | Default |
1633
+ | --- | ----------- | ------- |
1634
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1635
+ | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1636
+ | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1637
+ | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1390
1638
 
1391
1639
  ### Sucker Punch
1392
1640
 
@@ -1409,7 +1657,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1409
1657
  | --- | ----------- | ------- |
1410
1658
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1411
1659
  | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1412
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1413
1660
 
1414
1661
  ## Advanced configuration
1415
1662
 
@@ -1421,20 +1668,30 @@ To change the default behavior of the Datadog tracer, you can provide custom opt
1421
1668
  # config/initializers/datadog-tracer.rb
1422
1669
 
1423
1670
  Datadog.configure do |c|
1424
- c.tracer option_name: option_value, ...
1671
+ c.tracer.enabled = true
1672
+ c.tracer.hostname = 'my-agent'
1673
+ c.tracer.port = 8126
1674
+ c.tracer.partial_flush.enabled = false
1675
+ c.tracer.sampler = Datadog::AllSampler.new
1676
+
1677
+ # OR for advanced use cases, you can specify your own tracer:
1678
+ c.tracer.instance = Datadog::Tracer.new
1679
+
1680
+ # To enable debug mode:
1681
+ c.diagnostics.debug = true
1425
1682
  end
1426
1683
  ```
1427
1684
 
1428
1685
  Available options are:
1429
1686
 
1430
- - `enabled`: defines if the `tracer` is enabled or not. If set to `false` the code could be still instrumented because of other settings, but no spans are sent to the local trace agent.
1431
- - `debug`: set to true to enable debug logging.
1687
+ - `enabled`: defines if the `tracer` is enabled or not. If set to `false` instrumentation will still run, but no spans are sent to the trace agent. Can be configured through the `DD_TRACE_ENABLED` environment variable. Defaults to `true`.
1432
1688
  - `hostname`: set the hostname of the trace agent.
1689
+ - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1690
+ - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1433
1691
  - `port`: set the port the trace agent is listening on.
1434
- - `env`: set the environment. Rails users may set it to `Rails.env` to use their application settings.
1435
- - `tags`: set global tags that should be applied to all spans. Defaults to an empty hash
1436
- - `log`: defines a custom logger.
1437
- - `partial_flush`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1692
+ - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1693
+ - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1694
+ - `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
1438
1695
 
1439
1696
  #### Custom logging
1440
1697
 
@@ -1442,32 +1699,55 @@ By default, all logs are processed by the default Ruby logger. When using Rails,
1442
1699
 
1443
1700
  Datadog client log messages are marked with `[ddtrace]` so you should be able to isolate them from other messages.
1444
1701
 
1445
- Additionally, it is possible to override the default logger and replace it by a custom one. This is done using the `log` attribute of the tracer.
1702
+ Additionally, it is possible to override the default logger and replace it by a custom one. This is done using the `log` setting.
1446
1703
 
1447
1704
  ```ruby
1448
- f = File.new("my-custom.log", "w+") # Log messages should go there
1705
+ f = File.new("my-custom.log", "w+") # Log messages should go there
1449
1706
  Datadog.configure do |c|
1450
- c.tracer log: Logger.new(f) # Overriding the default tracer
1707
+ c.logger = Logger.new(f) # Overriding the default logger
1708
+ c.logger.level = ::Logger::INFO
1451
1709
  end
1452
1710
 
1453
- Datadog::Tracer.log.info { "this is typically called by tracing code" }
1711
+ Datadog.logger.info { "this is typically called by tracing code" }
1454
1712
  ```
1455
1713
 
1456
1714
  ### Environment and tags
1457
1715
 
1458
1716
  By default, the trace agent (not this library, but the program running in the background collecting data from various clients) uses the tags set in the agent config file, see our [environments tutorial](https://app.datadoghq.com/apm/docs/tutorials/environments) for details.
1459
1717
 
1460
- These values can be overridden at the tracer level:
1718
+ You can configure the application to automatically tag your traces and metrics, using the following environment variables:
1719
+
1720
+ - `DD_ENV`: Your application environment (e.g. `production`, `staging`, etc.)
1721
+ - `DD_SERVICE`: Your application's default service name (e.g. `billing-api`)
1722
+ - `DD_VERSION`: Your application version (e.g. `2.5`, `202003181415`, `1.3-alpha`, etc.)
1723
+ - `DD_TAGS`: Custom tags in value pairs separated by `,` (e.g. `layer:api,team:intake`)
1724
+ - If `DD_ENV`, `DD_SERVICE` or `DD_VERSION` are set, it will override any respective `env`/`service`/`version` tag defined in `DD_TAGS`.
1725
+ - If `DD_ENV`, `DD_SERVICE` or `DD_VERSION` are NOT set, tags defined in `DD_TAGS` will be used to populate `env`/`service`/`version` respectively.
1726
+
1727
+ These values can also be overridden at the tracer level:
1461
1728
 
1462
1729
  ```ruby
1463
1730
  Datadog.configure do |c|
1464
- c.tracer tags: { 'env' => 'prod' }
1731
+ c.service = 'billing-api'
1732
+ c.env = 'test'
1733
+ c.tags = { 'team' => 'qa' }
1734
+ c.version = '1.3-alpha'
1465
1735
  end
1466
1736
  ```
1467
1737
 
1468
- This enables you to set this value on a per tracer basis, so you can have for example several applications reporting for different environments on the same host.
1738
+ This enables you to set this value on a per application basis, so you can have for example several applications reporting for different environments on the same host.
1739
+
1740
+ Tags can also be set directly on individual spans, which will supersede any conflicting tags defined at the application level.
1741
+
1742
+ ### Environment variables
1743
+
1744
+ Other Environment Variables:
1469
1745
 
1470
- Ultimately, tags can be set per span, but `env` should typically be the same for all spans belonging to a given trace.
1746
+ - `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`.
1747
+ - `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.
1748
+ - `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`.
1749
+ - `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`.
1750
+ - `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`.
1471
1751
 
1472
1752
  ### Sampling
1473
1753
 
@@ -1478,8 +1758,9 @@ Ultimately, tags can be set per span, but `env` should typically be the same for
1478
1758
  ```ruby
1479
1759
  # Sample rate is between 0 (nothing sampled) to 1 (everything sampled).
1480
1760
  sampler = Datadog::RateSampler.new(0.5) # sample 50% of the traces
1761
+
1481
1762
  Datadog.configure do |c|
1482
- c.tracer sampler: sampler
1763
+ c.tracer.sampler = sampler
1483
1764
  end
1484
1765
  ```
1485
1766
 
@@ -1618,7 +1899,7 @@ Service C:
1618
1899
 
1619
1900
  **Activating distributed tracing for integrations**
1620
1901
 
1621
- Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default, but can be activated via configuration settings.
1902
+ Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default in Agent v7 and most versions of Agent v6. If needed, you can activate distributed tracing with configuration settings.
1622
1903
 
1623
1904
  - If your application receives requests from services with distributed tracing activated, you must activate distributed tracing on the integrations that handle these requests (e.g. Rails)
1624
1905
  - If your application send requests to services with distributed tracing activated, you must activate distributed tracing on the integrations that send these requests (e.g. Faraday)
@@ -1633,6 +1914,7 @@ For more details on how to activate distributed tracing for integrations, see th
1633
1914
  - [Rack](#rack)
1634
1915
  - [Rails](#rails)
1635
1916
  - [Sinatra](#sinatra)
1917
+ - [http.rb](#http-rb)
1636
1918
 
1637
1919
  **Using the HTTP propagator**
1638
1920
 
@@ -1746,28 +2028,26 @@ Datadog::Pipeline.before_flush(
1746
2028
 
1747
2029
  ### Trace correlation
1748
2030
 
1749
- In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing. The tracer can produce a correlation identifier for the currently active trace via `active_correlation`, which can be used to decorate these other data sources.
2031
+ In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing.
2032
+
2033
+ #### For logging in Rails applications
2034
+
2035
+ ##### Automatic
2036
+
2037
+ For Rails applications using the default logger (`ActiveSupport::TaggedLogging`) or `lograge`, you can automatically enable trace correlation injection by setting the `rails` instrumentation configuration option `log_injection` to `true` or by setting environment variable `DD_LOGS_INJECTION=true`:
1750
2038
 
1751
2039
  ```ruby
1752
- # When a trace is active...
1753
- Datadog.tracer.trace('correlation.example') do
1754
- # Returns #<Datadog::Correlation::Identifier>
1755
- correlation = Datadog.tracer.active_correlation
1756
- correlation.trace_id # => 5963550561812073440
1757
- correlation.span_id # => 2232727802607726424
1758
- end
2040
+ # config/initializers/datadog.rb
2041
+ require 'ddtrace'
1759
2042
 
1760
- # When a trace isn't active...
1761
- correlation = Datadog.tracer.active_correlation
1762
- # Returns #<Datadog::Correlation::Identifier>
1763
- correlation = Datadog.tracer.active_correlation
1764
- correlation.trace_id # => 0
1765
- correlation.span_id # => 0
2043
+ Datadog.configure do |c|
2044
+ c.use :rails, log_injection: true
2045
+ end
1766
2046
  ```
1767
2047
 
1768
- #### For logging in Rails applications using Lograge (recommended)
2048
+ ##### Manual (Lograge)
1769
2049
 
1770
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs:
2050
+ After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
1771
2051
 
1772
2052
  ```ruby
1773
2053
  config.lograge.custom_options = lambda do |event|
@@ -1779,7 +2059,10 @@ config.lograge.custom_options = lambda do |event|
1779
2059
  :dd => {
1780
2060
  # To preserve precision during JSON serialization, use strings for large numbers
1781
2061
  :trace_id => correlation.trace_id.to_s,
1782
- :span_id => correlation.span_id.to_s
2062
+ :span_id => correlation.span_id.to_s,
2063
+ :env => correlation.env.to_s,
2064
+ :service => correlation.service.to_s,
2065
+ :version => correlation.version.to_s
1783
2066
  },
1784
2067
  :ddsource => ["ruby"],
1785
2068
  :params => event.payload[:params].reject { |k| %w(controller action).include? k }
@@ -1787,34 +2070,42 @@ config.lograge.custom_options = lambda do |event|
1787
2070
  end
1788
2071
  ```
1789
2072
 
1790
- #### For logging in Rails applications
1791
-
1792
- Rails applications which are configured with an `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. The default Rails logger implements this tagged logging, making it easier to add correlation tags.
2073
+ ##### Manual (ActiveSupport::TaggedLogging)
1793
2074
 
1794
- In your Rails environment configuration file, add the following:
2075
+ Rails applications which are configured with the default `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. To enable Trace Correlation with `ActiveSupport::TaggedLogging`, in your Rails environment configuration file, add the following:
1795
2076
 
1796
2077
  ```ruby
1797
2078
  Rails.application.configure do
1798
2079
  config.log_tags = [proc { Datadog.tracer.active_correlation.to_s }]
1799
2080
  end
1800
2081
 
2082
+ # Given:
2083
+ # DD_ENV = 'production' (The name of the environment your application is running in.)
2084
+ # DD_SERVICE = 'billing-api' (Default service name of your application.)
2085
+ # DD_VERSION = '2.5.17' (The version of your application.)
2086
+
1801
2087
  # Web requests will produce:
1802
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Started GET "/articles" for 172.22.0.1 at 2019-01-16 18:50:57 +0000
1803
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Processing by ArticlesController#index as */*
1804
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Article Load (0.5ms) SELECT "articles".* FROM "articles"
1805
- # [dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.5ms)
2088
+ # [dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Started GET "/articles" for 172.22.0.1 at 2019-01-16 18:50:57 +0000
2089
+ # [dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Processing by ArticlesController#index as */*
2090
+ # [dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Article Load (0.5ms) SELECT "articles".* FROM "articles"
2091
+ # [dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=7110975754844687674 dd.span_id=7518426836986654206] Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.5ms)
1806
2092
  ```
1807
2093
 
1808
2094
  #### For logging in Ruby applications
1809
2095
 
1810
2096
  To add correlation IDs to your logger, add a log formatter which retrieves the correlation IDs with `Datadog.tracer.active_correlation`, then add them to the message.
1811
2097
 
1812
- To properly correlate with Datadog logging, be sure the following is present in the log message:
2098
+ To properly correlate with Datadog logging, be sure the following is present in the log message, in order as they appear:
1813
2099
 
2100
+ - `dd.env=<ENV>`: Where `<ENV>` is equal to `Datadog.tracer.active_correlation.env`. Omit if no environment is configured.
2101
+ - `dd.service=<SERVICE>`: Where `<SERVICE>` is equal to `Datadog.tracer.active_correlation.service`. Omit if no default service name is configured.
2102
+ - `dd.version=<VERSION>`: Where `<VERSION>` is equal to `Datadog.tracer.active_correlation.version`. Omit if no application version is configured.
1814
2103
  - `dd.trace_id=<TRACE_ID>`: Where `<TRACE_ID>` is equal to `Datadog.tracer.active_correlation.trace_id` or `0` if no trace is active during logging.
1815
2104
  - `dd.span_id=<SPAN_ID>`: Where `<SPAN_ID>` is equal to `Datadog.tracer.active_correlation.span_id` or `0` if no trace is active during logging.
1816
2105
 
1817
- By default, `Datadog::Correlation::Identifier#to_s` will return `dd.trace_id=<TRACE_ID> dd.span_id=<SPAN_ID>`.
2106
+ By default, `Datadog::Correlation::Identifier#to_s` will return `dd.env=<ENV> dd.service=<SERVICE> dd.version=<VERSION> dd.trace_id=<TRACE_ID> dd.span_id=<SPAN_ID>`.
2107
+
2108
+ If a trace is not active and the application environment & version is not configured, it will return `dd.trace_id=0 dd.span_id=0 dd.env= dd.version=`.
1818
2109
 
1819
2110
  An example of this in practice:
1820
2111
 
@@ -1822,6 +2113,10 @@ An example of this in practice:
1822
2113
  require 'ddtrace'
1823
2114
  require 'logger'
1824
2115
 
2116
+ ENV['DD_ENV'] = 'production'
2117
+ ENV['DD_SERVICE'] = 'billing-api'
2118
+ ENV['DD_VERSION'] = '2.5.17'
2119
+
1825
2120
  logger = Logger.new(STDOUT)
1826
2121
  logger.progname = 'my_app'
1827
2122
  logger.formatter = proc do |severity, datetime, progname, msg|
@@ -1830,11 +2125,11 @@ end
1830
2125
 
1831
2126
  # When no trace is active
1832
2127
  logger.warn('This is an untraced operation.')
1833
- # [2019-01-16 18:38:41 +0000][my_app][WARN][dd.trace_id=0 dd.span_id=0] This is an untraced operation.
2128
+ # [2019-01-16 18:38:41 +0000][my_app][WARN][dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=0 dd.span_id=0] This is an untraced operation.
1834
2129
 
1835
2130
  # When a trace is active
1836
2131
  Datadog.tracer.trace('my.operation') { logger.warn('This is a traced operation.') }
1837
- # [2019-01-16 18:38:41 +0000][my_app][WARN][dd.trace_id=8545847825299552251 dd.span_id=3711755234730770098] This is a traced operation.
2132
+ # [2019-01-16 18:38:41 +0000][my_app][WARN][dd.env=production dd.service=billing-api dd.version=2.5.17 dd.trace_id=8545847825299552251 dd.span_id=3711755234730770098] This is a traced operation.
1838
2133
  ```
1839
2134
 
1840
2135
  ### Configuring the transport layer
@@ -1849,7 +2144,7 @@ The `Net` adapter submits traces using `Net::HTTP` over TCP. It is the default t
1849
2144
 
1850
2145
  ```ruby
1851
2146
  Datadog.configure do |c|
1852
- c.tracer transport_options: proc do |t|
2147
+ c.tracer.transport_options = proc { |t|
1853
2148
  # Hostname, port, and additional options. :timeout is in seconds.
1854
2149
  t.adapter :net_http, '127.0.0.1', 8126, { timeout: 1 }
1855
2150
  }
@@ -1864,7 +2159,7 @@ To use, first configure your trace agent to listen by Unix socket, then configur
1864
2159
 
1865
2160
  ```ruby
1866
2161
  Datadog.configure do |c|
1867
- c.tracer transport_options: proc { |t|
2162
+ c.tracer.transport_options = proc { |t|
1868
2163
  # Provide filepath to trace agent Unix socket
1869
2164
  t.adapter :unix, '/tmp/ddagent/trace.sock'
1870
2165
  }
@@ -1877,7 +2172,7 @@ The `Test` adapter is a no-op transport that can optionally buffer requests. For
1877
2172
 
1878
2173
  ```ruby
1879
2174
  Datadog.configure do |c|
1880
- c.tracer transport_options: proc { |t|
2175
+ c.tracer.transport_options = proc { |t|
1881
2176
  # Set transport to no-op mode. Does not retain traces.
1882
2177
  t.adapter :test
1883
2178
 
@@ -1894,7 +2189,7 @@ Custom adapters can be configured with:
1894
2189
 
1895
2190
  ```ruby
1896
2191
  Datadog.configure do |c|
1897
- c.tracer transport_options: proc { |t|
2192
+ c.tracer.transport_options = proc { |t|
1898
2193
  # Initialize and pass an instance of the adapter
1899
2194
  custom_adapter = CustomAdapter.new
1900
2195
  t.adapter custom_adapter
@@ -1925,24 +2220,24 @@ require 'ddtrace'
1925
2220
  Datadog.configure do |c|
1926
2221
  # To enable runtime metrics collection, set `true`. Defaults to `false`
1927
2222
  # You can also set DD_RUNTIME_METRICS_ENABLED=true to configure this.
1928
- c.runtime_metrics_enabled = true
2223
+ c.runtime_metrics.enabled = true
1929
2224
 
1930
2225
  # Optionally, you can configure the Statsd instance used for sending runtime metrics.
1931
2226
  # Statsd is automatically configured with default settings if `dogstatsd-ruby` is available.
1932
2227
  # You can configure with host and port of Datadog agent; defaults to 'localhost:8125'.
1933
- c.runtime_metrics statsd: Datadog::Statsd.new
2228
+ c.runtime_metrics.statsd = Datadog::Statsd.new
1934
2229
  end
1935
2230
  ```
1936
2231
 
1937
2232
  See the [Dogstatsd documentation](https://www.rubydoc.info/github/DataDog/dogstatsd-ruby/master/frames) for more details about configuring `Datadog::Statsd`.
1938
2233
 
1939
- The stats sent will include:
2234
+ The stats are VM specific and will include:
1940
2235
 
1941
2236
  | Name | Type | Description |
1942
2237
  | -------------------------- | ------- | -------------------------------------------------------- |
1943
2238
  | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. |
1944
2239
  | `runtime.ruby.thread_count` | `gauge` | Number of threads. |
1945
- | `runtime.ruby.gc.*`. | `gauge` | Garbage collection statistics (one per value in GC.stat) |
2240
+ | `runtime.ruby.gc.*`. | `gauge` | Garbage collection statistics: collected from `GC.stat`. |
1946
2241
 
1947
2242
  In addition, all metrics include the following tags:
1948
2243