ddtrace 0.52.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1169) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +701 -12
  3. data/LICENSE-3rdparty.csv +6 -1
  4. data/README.md +10 -1
  5. data/bin/ddtracerb +5 -5
  6. data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +134 -0
  7. data/ext/ddtrace_profiling_loader/extconf.rb +74 -0
  8. data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +156 -0
  9. data/ext/ddtrace_profiling_native_extension/clock_id.h +25 -0
  10. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +75 -0
  11. data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +23 -0
  12. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +899 -0
  13. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +9 -0
  14. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +776 -0
  15. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +142 -0
  16. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +14 -0
  17. data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +241 -0
  18. data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.h +3 -0
  19. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +390 -0
  20. data/ext/ddtrace_profiling_native_extension/collectors_stack.h +18 -0
  21. data/ext/ddtrace_profiling_native_extension/extconf.rb +234 -14
  22. data/ext/ddtrace_profiling_native_extension/helpers.h +17 -0
  23. data/ext/ddtrace_profiling_native_extension/http_transport.c +353 -0
  24. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +14 -0
  25. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +297 -0
  26. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +836 -0
  27. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +45 -0
  28. data/ext/ddtrace_profiling_native_extension/profiling.c +237 -3
  29. data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +110 -0
  30. data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +89 -0
  31. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.c +115 -0
  32. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +11 -0
  33. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +487 -0
  34. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +39 -0
  35. data/ext/ddtrace_profiling_native_extension/time_helpers.c +17 -0
  36. data/ext/ddtrace_profiling_native_extension/time_helpers.h +10 -0
  37. data/lib/datadog/appsec/assets/blocked.html +99 -0
  38. data/lib/datadog/appsec/assets/blocked.json +1 -0
  39. data/lib/datadog/appsec/assets/blocked.text +5 -0
  40. data/lib/datadog/appsec/assets/waf_rules/README.md +7 -0
  41. data/lib/datadog/appsec/assets/waf_rules/recommended.json +6521 -0
  42. data/lib/datadog/appsec/assets/waf_rules/risky.json +1499 -0
  43. data/lib/datadog/appsec/assets/waf_rules/strict.json +1533 -0
  44. data/lib/datadog/appsec/assets.rb +38 -0
  45. data/lib/datadog/appsec/autoload.rb +18 -0
  46. data/lib/datadog/appsec/configuration/settings.rb +198 -0
  47. data/lib/datadog/appsec/configuration.rb +84 -0
  48. data/lib/datadog/appsec/contrib/auto_instrument.rb +27 -0
  49. data/lib/datadog/appsec/contrib/configuration/settings.rb +20 -0
  50. data/lib/datadog/appsec/contrib/integration.rb +37 -0
  51. data/lib/datadog/appsec/contrib/patcher.rb +12 -0
  52. data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +22 -0
  53. data/lib/datadog/appsec/contrib/rack/ext.rb +15 -0
  54. data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +174 -0
  55. data/lib/datadog/appsec/contrib/rack/integration.rb +49 -0
  56. data/lib/datadog/appsec/contrib/rack/patcher.rb +32 -0
  57. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +83 -0
  58. data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +64 -0
  59. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +64 -0
  60. data/lib/datadog/appsec/contrib/rack/request.rb +78 -0
  61. data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +41 -0
  62. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +139 -0
  63. data/lib/datadog/appsec/contrib/rack/response.rb +24 -0
  64. data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +22 -0
  65. data/lib/datadog/appsec/contrib/rails/ext.rb +15 -0
  66. data/lib/datadog/appsec/contrib/rails/framework.rb +30 -0
  67. data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +82 -0
  68. data/lib/datadog/appsec/contrib/rails/integration.rb +48 -0
  69. data/lib/datadog/appsec/contrib/rails/patcher.rb +159 -0
  70. data/lib/datadog/appsec/contrib/rails/reactive/action.rb +68 -0
  71. data/lib/datadog/appsec/contrib/rails/request.rb +36 -0
  72. data/lib/datadog/appsec/contrib/rails/request_middleware.rb +20 -0
  73. data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +22 -0
  74. data/lib/datadog/appsec/contrib/sinatra/ext.rb +16 -0
  75. data/lib/datadog/appsec/contrib/sinatra/framework.rb +34 -0
  76. data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +126 -0
  77. data/lib/datadog/appsec/contrib/sinatra/integration.rb +48 -0
  78. data/lib/datadog/appsec/contrib/sinatra/patcher.rb +151 -0
  79. data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +63 -0
  80. data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +20 -0
  81. data/lib/datadog/appsec/event.rb +117 -0
  82. data/lib/datadog/appsec/extensions.rb +128 -0
  83. data/lib/datadog/appsec/instrumentation/gateway.rb +58 -0
  84. data/lib/datadog/appsec/processor.rb +198 -0
  85. data/lib/datadog/appsec/rate_limiter.rb +60 -0
  86. data/lib/datadog/appsec/reactive/address_hash.rb +18 -0
  87. data/lib/datadog/appsec/reactive/engine.rb +44 -0
  88. data/lib/datadog/appsec/reactive/operation.rb +51 -0
  89. data/lib/datadog/appsec/reactive/subscriber.rb +18 -0
  90. data/lib/datadog/appsec/response.rb +54 -0
  91. data/lib/datadog/appsec.rb +23 -0
  92. data/lib/datadog/ci/configuration/components.rb +9 -8
  93. data/lib/datadog/ci/configuration/settings.rb +20 -4
  94. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +5 -3
  95. data/lib/datadog/ci/contrib/cucumber/ext.rb +2 -0
  96. data/lib/datadog/ci/contrib/cucumber/formatter.rb +9 -13
  97. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +3 -2
  98. data/lib/datadog/ci/contrib/cucumber/integration.rb +6 -5
  99. data/lib/datadog/ci/contrib/cucumber/patcher.rb +4 -3
  100. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +5 -3
  101. data/lib/datadog/ci/contrib/rspec/example.rb +9 -13
  102. data/lib/datadog/ci/contrib/rspec/ext.rb +2 -0
  103. data/lib/datadog/ci/contrib/rspec/integration.rb +8 -7
  104. data/lib/datadog/ci/contrib/rspec/patcher.rb +4 -3
  105. data/lib/datadog/ci/ext/app_types.rb +2 -1
  106. data/lib/datadog/ci/ext/environment.rb +189 -115
  107. data/lib/datadog/ci/ext/settings.rb +2 -1
  108. data/lib/datadog/ci/ext/test.rb +2 -0
  109. data/lib/datadog/ci/extensions.rb +7 -6
  110. data/lib/datadog/ci/flush.rb +38 -0
  111. data/lib/datadog/ci/test.rb +22 -16
  112. data/lib/datadog/ci.rb +7 -4
  113. data/lib/datadog/core/buffer/cruby.rb +55 -0
  114. data/lib/datadog/core/buffer/random.rb +134 -0
  115. data/lib/datadog/core/buffer/thread_safe.rb +58 -0
  116. data/lib/datadog/core/chunker.rb +35 -0
  117. data/lib/datadog/core/configuration/agent_settings_resolver.rb +362 -0
  118. data/lib/datadog/core/configuration/base.rb +98 -0
  119. data/lib/datadog/core/configuration/components.rb +462 -0
  120. data/lib/datadog/core/configuration/dependency_resolver.rb +28 -0
  121. data/lib/datadog/core/configuration/ext.rb +18 -0
  122. data/lib/datadog/core/configuration/option.rb +69 -0
  123. data/lib/datadog/core/configuration/option_definition.rb +126 -0
  124. data/lib/datadog/core/configuration/option_definition_set.rb +22 -0
  125. data/lib/datadog/core/configuration/option_set.rb +10 -0
  126. data/lib/datadog/core/configuration/options.rb +118 -0
  127. data/lib/datadog/core/configuration/settings.rb +444 -0
  128. data/lib/datadog/core/configuration.rb +289 -0
  129. data/lib/datadog/core/diagnostics/environment_logger.rb +287 -0
  130. data/lib/datadog/core/diagnostics/health.rb +19 -0
  131. data/lib/datadog/core/encoding.rb +76 -0
  132. data/lib/datadog/core/environment/cgroup.rb +5 -2
  133. data/lib/datadog/core/environment/class_count.rb +1 -0
  134. data/lib/datadog/core/environment/container.rb +4 -2
  135. data/lib/datadog/core/environment/ext.rb +29 -10
  136. data/lib/datadog/core/environment/gc.rb +1 -0
  137. data/lib/datadog/core/environment/identity.rb +12 -5
  138. data/lib/datadog/core/environment/platform.rb +40 -0
  139. data/lib/datadog/core/environment/socket.rb +9 -2
  140. data/lib/datadog/core/environment/thread_count.rb +1 -0
  141. data/lib/datadog/core/environment/variable_helpers.rb +85 -11
  142. data/lib/datadog/core/environment/vm_cache.rb +47 -0
  143. data/lib/datadog/core/error.rb +101 -0
  144. data/lib/datadog/core/extensions.rb +16 -0
  145. data/lib/datadog/core/git/ext.rb +35 -0
  146. data/lib/datadog/core/header_collection.rb +41 -0
  147. data/lib/datadog/core/logger.rb +46 -0
  148. data/lib/datadog/core/logging/ext.rb +11 -0
  149. data/lib/datadog/core/metrics/client.rb +198 -0
  150. data/lib/datadog/core/metrics/ext.rb +20 -0
  151. data/lib/datadog/core/metrics/helpers.rb +25 -0
  152. data/lib/datadog/core/metrics/logging.rb +44 -0
  153. data/lib/datadog/core/metrics/metric.rb +14 -0
  154. data/lib/datadog/core/metrics/options.rb +50 -0
  155. data/lib/datadog/core/pin.rb +75 -0
  156. data/lib/datadog/core/runtime/ext.rb +28 -0
  157. data/lib/datadog/core/runtime/metrics.rb +126 -0
  158. data/lib/datadog/core/telemetry/client.rb +79 -0
  159. data/lib/datadog/core/telemetry/collector.rb +232 -0
  160. data/lib/datadog/core/telemetry/emitter.rb +48 -0
  161. data/lib/datadog/core/telemetry/event.rb +71 -0
  162. data/lib/datadog/core/telemetry/ext.rb +11 -0
  163. data/lib/datadog/core/telemetry/heartbeat.rb +37 -0
  164. data/lib/datadog/core/telemetry/http/adapters/net.rb +113 -0
  165. data/lib/datadog/core/telemetry/http/env.rb +20 -0
  166. data/lib/datadog/core/telemetry/http/ext.rb +20 -0
  167. data/lib/datadog/core/telemetry/http/response.rb +68 -0
  168. data/lib/datadog/core/telemetry/http/transport.rb +53 -0
  169. data/lib/datadog/core/telemetry/v1/app_event.rb +52 -0
  170. data/lib/datadog/core/telemetry/v1/application.rb +86 -0
  171. data/lib/datadog/core/telemetry/v1/configuration.rb +25 -0
  172. data/lib/datadog/core/telemetry/v1/dependency.rb +36 -0
  173. data/lib/datadog/core/telemetry/v1/host.rb +51 -0
  174. data/lib/datadog/core/telemetry/v1/integration.rb +58 -0
  175. data/lib/datadog/core/telemetry/v1/product.rb +28 -0
  176. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +100 -0
  177. data/lib/datadog/core/utils/compression.rb +36 -0
  178. data/lib/datadog/core/utils/forking.rb +63 -0
  179. data/lib/datadog/core/utils/object_set.rb +43 -0
  180. data/lib/datadog/core/utils/only_once.rb +44 -0
  181. data/lib/datadog/core/utils/safe_dup.rb +27 -0
  182. data/lib/datadog/core/utils/sequence.rb +26 -0
  183. data/lib/datadog/core/utils/string_table.rb +49 -0
  184. data/lib/datadog/core/utils/time.rb +54 -0
  185. data/lib/datadog/core/utils.rb +94 -0
  186. data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +120 -0
  187. data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +61 -0
  188. data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +139 -0
  189. data/lib/datadog/core/vendor/multipart-post/multipart/post/version.rb +13 -0
  190. data/lib/datadog/core/vendor/multipart-post/multipart/post.rb +12 -0
  191. data/lib/datadog/core/vendor/multipart-post/multipart.rb +16 -0
  192. data/lib/datadog/core/vendor/multipart-post/net/http/post/multipart.rb +36 -0
  193. data/lib/datadog/core/worker.rb +24 -0
  194. data/lib/datadog/core/workers/async.rb +180 -0
  195. data/lib/datadog/core/workers/interval_loop.rb +119 -0
  196. data/lib/datadog/core/workers/polling.rb +59 -0
  197. data/lib/datadog/core/workers/queue.rb +44 -0
  198. data/lib/datadog/core/workers/runtime_metrics.rb +62 -0
  199. data/lib/datadog/core.rb +46 -0
  200. data/lib/datadog/kit/enable_core_dumps.rb +50 -0
  201. data/lib/datadog/kit/identity.rb +63 -0
  202. data/lib/datadog/kit.rb +11 -0
  203. data/lib/datadog/opentracer/binary_propagator.rb +26 -0
  204. data/lib/datadog/opentracer/carrier.rb +9 -0
  205. data/lib/datadog/opentracer/distributed_headers.rb +56 -0
  206. data/lib/datadog/opentracer/global_tracer.rb +17 -0
  207. data/lib/datadog/opentracer/propagator.rb +26 -0
  208. data/lib/datadog/opentracer/rack_propagator.rb +73 -0
  209. data/lib/datadog/opentracer/scope.rb +18 -0
  210. data/lib/datadog/opentracer/scope_manager.rb +9 -0
  211. data/lib/datadog/opentracer/span.rb +101 -0
  212. data/lib/datadog/opentracer/span_context.rb +19 -0
  213. data/lib/datadog/opentracer/span_context_factory.rb +27 -0
  214. data/lib/datadog/opentracer/text_map_propagator.rb +88 -0
  215. data/lib/datadog/opentracer/thread_local_scope.rb +34 -0
  216. data/lib/datadog/opentracer/thread_local_scope_manager.rb +66 -0
  217. data/lib/datadog/opentracer/tracer.rb +214 -0
  218. data/lib/datadog/opentracer.rb +24 -0
  219. data/lib/datadog/profiling/backtrace_location.rb +34 -0
  220. data/lib/datadog/profiling/buffer.rb +43 -0
  221. data/lib/datadog/profiling/collectors/code_provenance.rb +115 -0
  222. data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +43 -0
  223. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +91 -0
  224. data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +14 -0
  225. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +68 -0
  226. data/lib/datadog/profiling/collectors/old_stack.rb +305 -0
  227. data/lib/datadog/profiling/collectors/stack.rb +13 -0
  228. data/lib/datadog/profiling/encoding/profile.rb +43 -0
  229. data/lib/datadog/profiling/event.rb +15 -0
  230. data/lib/datadog/profiling/events/stack.rb +82 -0
  231. data/lib/datadog/profiling/exporter.rb +85 -0
  232. data/lib/datadog/profiling/ext/forking.rb +98 -0
  233. data/lib/datadog/profiling/ext.rb +45 -0
  234. data/lib/datadog/profiling/flush.rb +38 -0
  235. data/lib/datadog/profiling/http_transport.rb +132 -0
  236. data/lib/datadog/profiling/load_native_extension.rb +22 -0
  237. data/lib/datadog/profiling/native_extension.rb +41 -0
  238. data/lib/datadog/profiling/old_recorder.rb +109 -0
  239. data/lib/datadog/profiling/pprof/builder.rb +127 -0
  240. data/lib/datadog/profiling/pprof/converter.rb +104 -0
  241. data/lib/datadog/profiling/pprof/message_set.rb +16 -0
  242. data/lib/datadog/profiling/pprof/payload.rb +20 -0
  243. data/lib/datadog/profiling/pprof/pprof_pb.rb +83 -0
  244. data/lib/datadog/profiling/pprof/stack_sample.rb +141 -0
  245. data/lib/datadog/profiling/pprof/string_table.rb +12 -0
  246. data/lib/datadog/profiling/pprof/template.rb +120 -0
  247. data/lib/datadog/profiling/preload.rb +5 -0
  248. data/lib/datadog/profiling/profiler.rb +41 -0
  249. data/lib/datadog/profiling/scheduler.rb +130 -0
  250. data/lib/datadog/profiling/stack_recorder.rb +79 -0
  251. data/lib/datadog/profiling/tag_builder.rb +53 -0
  252. data/lib/datadog/profiling/tasks/exec.rb +50 -0
  253. data/lib/datadog/profiling/tasks/help.rb +18 -0
  254. data/lib/datadog/profiling/tasks/setup.rb +86 -0
  255. data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +45 -0
  256. data/lib/datadog/profiling/trace_identifiers/helper.rb +47 -0
  257. data/lib/datadog/profiling.rb +173 -0
  258. data/lib/datadog/tracing/analytics.rb +25 -0
  259. data/lib/datadog/tracing/buffer.rb +132 -0
  260. data/lib/datadog/tracing/client_ip.rb +164 -0
  261. data/lib/datadog/tracing/configuration/ext.rb +95 -0
  262. data/lib/datadog/tracing/configuration/settings.rb +433 -0
  263. data/lib/datadog/tracing/context.rb +68 -0
  264. data/lib/datadog/tracing/context_provider.rb +82 -0
  265. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +35 -0
  266. data/lib/datadog/tracing/contrib/action_cable/event.rb +71 -0
  267. data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +58 -0
  268. data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +63 -0
  269. data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +59 -0
  270. data/lib/datadog/tracing/contrib/action_cable/events.rb +37 -0
  271. data/lib/datadog/tracing/contrib/action_cable/ext.rb +32 -0
  272. data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +90 -0
  273. data/lib/datadog/tracing/contrib/action_cable/integration.rb +50 -0
  274. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +31 -0
  275. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +36 -0
  276. data/lib/datadog/tracing/contrib/action_mailer/event.rb +52 -0
  277. data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +60 -0
  278. data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +47 -0
  279. data/lib/datadog/tracing/contrib/action_mailer/events.rb +34 -0
  280. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +33 -0
  281. data/lib/datadog/tracing/contrib/action_mailer/integration.rb +50 -0
  282. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +29 -0
  283. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +160 -0
  284. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +29 -0
  285. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +36 -0
  286. data/lib/datadog/tracing/contrib/action_pack/ext.rb +22 -0
  287. data/lib/datadog/tracing/contrib/action_pack/integration.rb +50 -0
  288. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +27 -0
  289. data/lib/datadog/tracing/contrib/action_pack/utils.rb +40 -0
  290. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +36 -0
  291. data/lib/datadog/tracing/contrib/action_view/event.rb +35 -0
  292. data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +54 -0
  293. data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +57 -0
  294. data/lib/datadog/tracing/contrib/action_view/events.rb +34 -0
  295. data/lib/datadog/tracing/contrib/action_view/ext.rb +24 -0
  296. data/lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb +78 -0
  297. data/lib/datadog/tracing/contrib/action_view/instrumentation/template_renderer.rb +91 -0
  298. data/lib/datadog/tracing/contrib/action_view/integration.rb +57 -0
  299. data/lib/datadog/tracing/contrib/action_view/patcher.rb +47 -0
  300. data/lib/datadog/tracing/contrib/action_view/utils.rb +36 -0
  301. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +37 -0
  302. data/lib/datadog/tracing/contrib/active_job/event.rb +58 -0
  303. data/lib/datadog/tracing/contrib/active_job/events/discard.rb +50 -0
  304. data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +49 -0
  305. data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +49 -0
  306. data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +51 -0
  307. data/lib/datadog/tracing/contrib/active_job/events/perform.rb +49 -0
  308. data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +50 -0
  309. data/lib/datadog/tracing/contrib/active_job/events.rb +42 -0
  310. data/lib/datadog/tracing/contrib/active_job/ext.rb +39 -0
  311. data/lib/datadog/tracing/contrib/active_job/integration.rb +50 -0
  312. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +24 -0
  313. data/lib/datadog/tracing/contrib/active_job/patcher.rb +36 -0
  314. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +33 -0
  315. data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +68 -0
  316. data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +45 -0
  317. data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +47 -0
  318. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +34 -0
  319. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +24 -0
  320. data/lib/datadog/tracing/contrib/active_model_serializers/integration.rb +45 -0
  321. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +32 -0
  322. data/lib/datadog/tracing/contrib/active_record/configuration/makara_resolver.rb +36 -0
  323. data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +138 -0
  324. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +39 -0
  325. data/lib/datadog/tracing/contrib/active_record/event.rb +30 -0
  326. data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +58 -0
  327. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +78 -0
  328. data/lib/datadog/tracing/contrib/active_record/events.rb +34 -0
  329. data/lib/datadog/tracing/contrib/active_record/ext.rb +29 -0
  330. data/lib/datadog/tracing/contrib/active_record/integration.rb +56 -0
  331. data/lib/datadog/tracing/contrib/active_record/patcher.rb +27 -0
  332. data/lib/datadog/tracing/contrib/active_record/utils.rb +128 -0
  333. data/lib/datadog/tracing/contrib/active_record/vendor/connection_specification.rb +307 -0
  334. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +280 -0
  335. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +73 -0
  336. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +47 -0
  337. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +35 -0
  338. data/lib/datadog/tracing/contrib/active_support/ext.rb +31 -0
  339. data/lib/datadog/tracing/contrib/active_support/integration.rb +51 -0
  340. data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +71 -0
  341. data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +71 -0
  342. data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +164 -0
  343. data/lib/datadog/tracing/contrib/active_support/patcher.rb +27 -0
  344. data/lib/datadog/tracing/contrib/analytics.rb +29 -0
  345. data/lib/datadog/tracing/contrib/auto_instrument.rb +53 -0
  346. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +38 -0
  347. data/lib/datadog/tracing/contrib/aws/ext.rb +28 -0
  348. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +96 -0
  349. data/lib/datadog/tracing/contrib/aws/integration.rb +47 -0
  350. data/lib/datadog/tracing/contrib/aws/parsed_context.rb +60 -0
  351. data/lib/datadog/tracing/contrib/aws/patcher.rb +57 -0
  352. data/lib/datadog/tracing/contrib/aws/services.rb +121 -0
  353. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +23 -0
  354. data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +53 -0
  355. data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +16 -0
  356. data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +27 -0
  357. data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +43 -0
  358. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +33 -0
  359. data/lib/datadog/tracing/contrib/configurable.rb +102 -0
  360. data/lib/datadog/tracing/contrib/configuration/resolver.rb +85 -0
  361. data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +43 -0
  362. data/lib/datadog/tracing/contrib/configuration/settings.rb +43 -0
  363. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +38 -0
  364. data/lib/datadog/tracing/contrib/dalli/ext.rb +26 -0
  365. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +61 -0
  366. data/lib/datadog/tracing/contrib/dalli/integration.rb +52 -0
  367. data/lib/datadog/tracing/contrib/dalli/patcher.rb +28 -0
  368. data/lib/datadog/tracing/contrib/dalli/quantize.rb +26 -0
  369. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +38 -0
  370. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +28 -0
  371. data/lib/datadog/tracing/contrib/delayed_job/integration.rb +43 -0
  372. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +37 -0
  373. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +104 -0
  374. data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +32 -0
  375. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +40 -0
  376. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +29 -0
  377. data/lib/datadog/tracing/contrib/elasticsearch/integration.rb +50 -0
  378. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +153 -0
  379. data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +89 -0
  380. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +42 -0
  381. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +176 -0
  382. data/lib/datadog/tracing/contrib/ethon/ext.rb +25 -0
  383. data/lib/datadog/tracing/contrib/ethon/integration.rb +48 -0
  384. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +97 -0
  385. data/lib/datadog/tracing/contrib/ethon/patcher.rb +31 -0
  386. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +42 -0
  387. data/lib/datadog/tracing/contrib/excon/ext.rb +22 -0
  388. data/lib/datadog/tracing/contrib/excon/integration.rb +48 -0
  389. data/lib/datadog/tracing/contrib/excon/middleware.rb +171 -0
  390. data/lib/datadog/tracing/contrib/excon/patcher.rb +31 -0
  391. data/lib/datadog/tracing/contrib/ext.rb +25 -0
  392. data/lib/datadog/tracing/contrib/extensions.rb +199 -0
  393. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +46 -0
  394. data/lib/datadog/tracing/contrib/faraday/connection.rb +22 -0
  395. data/lib/datadog/tracing/contrib/faraday/ext.rb +22 -0
  396. data/lib/datadog/tracing/contrib/faraday/integration.rb +48 -0
  397. data/lib/datadog/tracing/contrib/faraday/middleware.rb +93 -0
  398. data/lib/datadog/tracing/contrib/faraday/patcher.rb +56 -0
  399. data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +22 -0
  400. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +42 -0
  401. data/lib/datadog/tracing/contrib/grape/endpoint.rb +250 -0
  402. data/lib/datadog/tracing/contrib/grape/ext.rb +28 -0
  403. data/lib/datadog/tracing/contrib/grape/instrumentation.rb +37 -0
  404. data/lib/datadog/tracing/contrib/grape/integration.rb +44 -0
  405. data/lib/datadog/tracing/contrib/grape/patcher.rb +33 -0
  406. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +36 -0
  407. data/lib/datadog/tracing/contrib/graphql/ext.rb +19 -0
  408. data/lib/datadog/tracing/contrib/graphql/integration.rb +44 -0
  409. data/lib/datadog/tracing/contrib/graphql/patcher.rb +90 -0
  410. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +43 -0
  411. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +99 -0
  412. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +90 -0
  413. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +107 -0
  414. data/lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb +27 -0
  415. data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +43 -0
  416. data/lib/datadog/tracing/contrib/grpc/ext.rb +27 -0
  417. data/lib/datadog/tracing/contrib/grpc/integration.rb +43 -0
  418. data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +53 -0
  419. data/lib/datadog/tracing/contrib/grpc/patcher.rb +35 -0
  420. data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +47 -0
  421. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +22 -0
  422. data/lib/datadog/tracing/contrib/hanami/ext.rb +24 -0
  423. data/lib/datadog/tracing/contrib/hanami/integration.rb +44 -0
  424. data/lib/datadog/tracing/contrib/hanami/patcher.rb +33 -0
  425. data/lib/datadog/tracing/contrib/hanami/plugin.rb +23 -0
  426. data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +41 -0
  427. data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +44 -0
  428. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +43 -0
  429. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +42 -0
  430. data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +32 -0
  431. data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +38 -0
  432. data/lib/datadog/tracing/contrib/http/ext.rb +22 -0
  433. data/lib/datadog/tracing/contrib/http/instrumentation.rb +140 -0
  434. data/lib/datadog/tracing/contrib/http/integration.rb +49 -0
  435. data/lib/datadog/tracing/contrib/http/patcher.rb +30 -0
  436. data/lib/datadog/tracing/contrib/http_annotation_helper.rb +17 -0
  437. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +42 -0
  438. data/lib/datadog/tracing/contrib/httpclient/ext.rb +22 -0
  439. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +118 -0
  440. data/lib/datadog/tracing/contrib/httpclient/integration.rb +48 -0
  441. data/lib/datadog/tracing/contrib/httpclient/patcher.rb +42 -0
  442. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +42 -0
  443. data/lib/datadog/tracing/contrib/httprb/ext.rb +22 -0
  444. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +129 -0
  445. data/lib/datadog/tracing/contrib/httprb/integration.rb +48 -0
  446. data/lib/datadog/tracing/contrib/httprb/patcher.rb +42 -0
  447. data/lib/datadog/tracing/contrib/integration.rb +78 -0
  448. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +35 -0
  449. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +19 -0
  450. data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +18 -0
  451. data/lib/datadog/tracing/contrib/kafka/event.rb +52 -0
  452. data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +42 -0
  453. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +49 -0
  454. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +47 -0
  455. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +47 -0
  456. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +37 -0
  457. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +37 -0
  458. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +37 -0
  459. data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +41 -0
  460. data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +44 -0
  461. data/lib/datadog/tracing/contrib/kafka/events.rb +48 -0
  462. data/lib/datadog/tracing/contrib/kafka/ext.rb +52 -0
  463. data/lib/datadog/tracing/contrib/kafka/integration.rb +44 -0
  464. data/lib/datadog/tracing/contrib/kafka/patcher.rb +29 -0
  465. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +23 -0
  466. data/lib/datadog/tracing/contrib/lograge/ext.rb +15 -0
  467. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +46 -0
  468. data/lib/datadog/tracing/contrib/lograge/integration.rb +50 -0
  469. data/lib/datadog/tracing/contrib/lograge/patcher.rb +29 -0
  470. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +42 -0
  471. data/lib/datadog/tracing/contrib/mongodb/ext.rb +35 -0
  472. data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +47 -0
  473. data/lib/datadog/tracing/contrib/mongodb/integration.rb +48 -0
  474. data/lib/datadog/tracing/contrib/mongodb/parsers.rb +49 -0
  475. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +34 -0
  476. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +127 -0
  477. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +50 -0
  478. data/lib/datadog/tracing/contrib/mysql2/ext.rb +24 -0
  479. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +77 -0
  480. data/lib/datadog/tracing/contrib/mysql2/integration.rb +43 -0
  481. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +31 -0
  482. data/lib/datadog/tracing/contrib/patchable.rb +109 -0
  483. data/lib/datadog/tracing/contrib/patcher.rb +86 -0
  484. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +50 -0
  485. data/lib/datadog/tracing/contrib/pg/ext.rb +33 -0
  486. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +155 -0
  487. data/lib/datadog/tracing/contrib/pg/integration.rb +43 -0
  488. data/lib/datadog/tracing/contrib/pg/patcher.rb +31 -0
  489. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +38 -0
  490. data/lib/datadog/tracing/contrib/presto/ext.rb +33 -0
  491. data/lib/datadog/tracing/contrib/presto/instrumentation.rb +124 -0
  492. data/lib/datadog/tracing/contrib/presto/integration.rb +43 -0
  493. data/lib/datadog/tracing/contrib/presto/patcher.rb +37 -0
  494. data/lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb +43 -0
  495. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +33 -0
  496. data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +28 -0
  497. data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +47 -0
  498. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +40 -0
  499. data/lib/datadog/tracing/contrib/qless/ext.rb +26 -0
  500. data/lib/datadog/tracing/contrib/qless/integration.rb +43 -0
  501. data/lib/datadog/tracing/contrib/qless/patcher.rb +37 -0
  502. data/lib/datadog/tracing/contrib/qless/qless_job.rb +74 -0
  503. data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +30 -0
  504. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +49 -0
  505. data/lib/datadog/tracing/contrib/que/ext.rb +34 -0
  506. data/lib/datadog/tracing/contrib/que/integration.rb +46 -0
  507. data/lib/datadog/tracing/contrib/que/patcher.rb +28 -0
  508. data/lib/datadog/tracing/contrib/que/tracer.rb +63 -0
  509. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +35 -0
  510. data/lib/datadog/tracing/contrib/racecar/event.rb +78 -0
  511. data/lib/datadog/tracing/contrib/racecar/events/batch.rb +38 -0
  512. data/lib/datadog/tracing/contrib/racecar/events/consume.rb +35 -0
  513. data/lib/datadog/tracing/contrib/racecar/events/message.rb +38 -0
  514. data/lib/datadog/tracing/contrib/racecar/events.rb +36 -0
  515. data/lib/datadog/tracing/contrib/racecar/ext.rb +31 -0
  516. data/lib/datadog/tracing/contrib/racecar/integration.rb +44 -0
  517. data/lib/datadog/tracing/contrib/racecar/patcher.rb +29 -0
  518. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +51 -0
  519. data/lib/datadog/tracing/contrib/rack/ext.rb +25 -0
  520. data/lib/datadog/tracing/contrib/rack/header_collection.rb +35 -0
  521. data/lib/datadog/tracing/contrib/rack/integration.rb +50 -0
  522. data/lib/datadog/tracing/contrib/rack/middlewares.rb +323 -0
  523. data/lib/datadog/tracing/contrib/rack/patcher.rb +119 -0
  524. data/lib/datadog/tracing/contrib/rack/request_queue.rb +48 -0
  525. data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +12 -0
  526. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +74 -0
  527. data/lib/datadog/tracing/contrib/rails/ext.rb +19 -0
  528. data/lib/datadog/tracing/contrib/rails/framework.rb +148 -0
  529. data/lib/datadog/tracing/contrib/rails/integration.rb +49 -0
  530. data/lib/datadog/tracing/contrib/rails/log_injection.rb +32 -0
  531. data/lib/datadog/tracing/contrib/rails/middlewares.rb +46 -0
  532. data/lib/datadog/tracing/contrib/rails/patcher.rb +120 -0
  533. data/lib/datadog/tracing/contrib/rails/railtie.rb +19 -0
  534. data/lib/datadog/tracing/contrib/rails/utils.rb +28 -0
  535. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +51 -0
  536. data/lib/datadog/tracing/contrib/rake/ext.rb +26 -0
  537. data/lib/datadog/tracing/contrib/rake/instrumentation.rb +103 -0
  538. data/lib/datadog/tracing/contrib/rake/integration.rb +43 -0
  539. data/lib/datadog/tracing/contrib/rake/patcher.rb +33 -0
  540. data/lib/datadog/tracing/contrib/redis/configuration/resolver.rb +49 -0
  541. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +43 -0
  542. data/lib/datadog/tracing/contrib/redis/ext.rb +29 -0
  543. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +88 -0
  544. data/lib/datadog/tracing/contrib/redis/integration.rb +80 -0
  545. data/lib/datadog/tracing/contrib/redis/patcher.rb +79 -0
  546. data/lib/datadog/tracing/contrib/redis/quantize.rb +82 -0
  547. data/lib/datadog/tracing/contrib/redis/tags.rb +56 -0
  548. data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +72 -0
  549. data/lib/datadog/tracing/contrib/redis/vendor/resolver.rb +162 -0
  550. data/lib/datadog/tracing/contrib/registerable.rb +50 -0
  551. data/lib/datadog/tracing/contrib/registry.rb +52 -0
  552. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +37 -0
  553. data/lib/datadog/tracing/contrib/resque/ext.rb +21 -0
  554. data/lib/datadog/tracing/contrib/resque/integration.rb +48 -0
  555. data/lib/datadog/tracing/contrib/resque/patcher.rb +29 -0
  556. data/lib/datadog/tracing/contrib/resque/resque_job.rb +104 -0
  557. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +42 -0
  558. data/lib/datadog/tracing/contrib/rest_client/ext.rb +22 -0
  559. data/lib/datadog/tracing/contrib/rest_client/integration.rb +43 -0
  560. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +29 -0
  561. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +106 -0
  562. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +23 -0
  563. data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +15 -0
  564. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +50 -0
  565. data/lib/datadog/tracing/contrib/semantic_logger/integration.rb +52 -0
  566. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +29 -0
  567. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +33 -0
  568. data/lib/datadog/tracing/contrib/sequel/database.rb +59 -0
  569. data/lib/datadog/tracing/contrib/sequel/dataset.rb +64 -0
  570. data/lib/datadog/tracing/contrib/sequel/ext.rb +22 -0
  571. data/lib/datadog/tracing/contrib/sequel/integration.rb +43 -0
  572. data/lib/datadog/tracing/contrib/sequel/patcher.rb +37 -0
  573. data/lib/datadog/tracing/contrib/sequel/utils.rb +87 -0
  574. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +38 -0
  575. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +25 -0
  576. data/lib/datadog/tracing/contrib/shoryuken/integration.rb +44 -0
  577. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +28 -0
  578. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +63 -0
  579. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +57 -0
  580. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +44 -0
  581. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +44 -0
  582. data/lib/datadog/tracing/contrib/sidekiq/integration.rb +53 -0
  583. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +78 -0
  584. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +52 -0
  585. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +34 -0
  586. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +32 -0
  587. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +53 -0
  588. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +102 -0
  589. data/lib/datadog/tracing/contrib/sidekiq/tracing.rb +44 -0
  590. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +43 -0
  591. data/lib/datadog/tracing/contrib/sinatra/env.rb +55 -0
  592. data/lib/datadog/tracing/contrib/sinatra/ext.rb +36 -0
  593. data/lib/datadog/tracing/contrib/sinatra/framework.rb +116 -0
  594. data/lib/datadog/tracing/contrib/sinatra/headers.rb +35 -0
  595. data/lib/datadog/tracing/contrib/sinatra/integration.rb +43 -0
  596. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +76 -0
  597. data/lib/datadog/tracing/contrib/sinatra/tracer.rb +86 -0
  598. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +127 -0
  599. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +38 -0
  600. data/lib/datadog/tracing/contrib/sneakers/ext.rb +26 -0
  601. data/lib/datadog/tracing/contrib/sneakers/integration.rb +46 -0
  602. data/lib/datadog/tracing/contrib/sneakers/patcher.rb +29 -0
  603. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +59 -0
  604. data/lib/datadog/tracing/contrib/status_code_matcher.rb +75 -0
  605. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +35 -0
  606. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +28 -0
  607. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +27 -0
  608. data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +104 -0
  609. data/lib/datadog/tracing/contrib/sucker_punch/integration.rb +43 -0
  610. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +36 -0
  611. data/lib/datadog/tracing/contrib/utils/database.rb +31 -0
  612. data/lib/datadog/tracing/contrib/utils/quantization/hash.rb +111 -0
  613. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +181 -0
  614. data/lib/datadog/tracing/contrib.rb +78 -0
  615. data/lib/datadog/tracing/correlation.rb +100 -0
  616. data/lib/datadog/tracing/diagnostics/ext.rb +36 -0
  617. data/lib/datadog/tracing/diagnostics/health.rb +40 -0
  618. data/lib/datadog/tracing/distributed/b3_multi.rb +66 -0
  619. data/lib/datadog/tracing/distributed/b3_single.rb +66 -0
  620. data/lib/datadog/tracing/distributed/datadog.rb +153 -0
  621. data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +85 -0
  622. data/lib/datadog/tracing/distributed/fetcher.rb +30 -0
  623. data/lib/datadog/tracing/distributed/headers/ext.rb +35 -0
  624. data/lib/datadog/tracing/distributed/helpers.rb +80 -0
  625. data/lib/datadog/tracing/distributed/none.rb +19 -0
  626. data/lib/datadog/tracing/distributed/propagation.rb +127 -0
  627. data/lib/datadog/tracing/distributed/trace_context.rb +369 -0
  628. data/lib/datadog/tracing/event.rb +78 -0
  629. data/lib/datadog/tracing/flush.rb +96 -0
  630. data/lib/datadog/tracing/metadata/analytics.rb +26 -0
  631. data/lib/datadog/tracing/metadata/errors.rb +24 -0
  632. data/lib/datadog/tracing/metadata/ext.rb +178 -0
  633. data/lib/datadog/tracing/metadata/tagging.rb +125 -0
  634. data/lib/datadog/tracing/metadata.rb +20 -0
  635. data/lib/datadog/tracing/pipeline/span_filter.rb +46 -0
  636. data/lib/datadog/tracing/pipeline/span_processor.rb +39 -0
  637. data/lib/datadog/tracing/pipeline.rb +65 -0
  638. data/lib/datadog/tracing/propagation/http.rb +14 -0
  639. data/lib/datadog/tracing/runtime/metrics.rb +19 -0
  640. data/lib/datadog/tracing/sampling/all_sampler.rb +25 -0
  641. data/lib/datadog/tracing/sampling/ext.rb +58 -0
  642. data/lib/datadog/tracing/sampling/matcher.rb +68 -0
  643. data/lib/datadog/tracing/sampling/priority_sampler.rb +165 -0
  644. data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +96 -0
  645. data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +65 -0
  646. data/lib/datadog/tracing/sampling/rate_limiter.rb +188 -0
  647. data/lib/datadog/tracing/sampling/rate_sampler.rb +72 -0
  648. data/lib/datadog/tracing/sampling/rule.rb +76 -0
  649. data/lib/datadog/tracing/sampling/rule_sampler.rb +132 -0
  650. data/lib/datadog/tracing/sampling/sampler.rb +44 -0
  651. data/lib/datadog/tracing/sampling/span/ext.rb +25 -0
  652. data/lib/datadog/tracing/sampling/span/matcher.rb +89 -0
  653. data/lib/datadog/tracing/sampling/span/rule.rb +82 -0
  654. data/lib/datadog/tracing/sampling/span/rule_parser.rb +104 -0
  655. data/lib/datadog/tracing/sampling/span/sampler.rb +75 -0
  656. data/lib/datadog/tracing/span.rb +216 -0
  657. data/lib/datadog/tracing/span_operation.rb +520 -0
  658. data/lib/datadog/tracing/sync_writer.rb +69 -0
  659. data/lib/datadog/tracing/trace_digest.rb +136 -0
  660. data/lib/datadog/tracing/trace_operation.rb +468 -0
  661. data/lib/datadog/tracing/trace_segment.rb +212 -0
  662. data/lib/datadog/tracing/tracer.rb +533 -0
  663. data/lib/datadog/tracing/utils.rb +50 -0
  664. data/lib/datadog/tracing/workers/trace_writer.rb +195 -0
  665. data/lib/datadog/tracing/workers.rb +125 -0
  666. data/lib/datadog/tracing/writer.rb +187 -0
  667. data/lib/datadog/tracing.rb +142 -0
  668. data/lib/ddtrace/auto_instrument.rb +14 -3
  669. data/lib/ddtrace/auto_instrument_base.rb +1 -0
  670. data/lib/ddtrace/profiling/preload.rb +2 -2
  671. data/lib/ddtrace/transport/ext.rb +41 -0
  672. data/lib/ddtrace/transport/http/adapters/net.rb +18 -6
  673. data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
  674. data/lib/ddtrace/transport/http/adapters/test.rb +6 -3
  675. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +25 -13
  676. data/lib/ddtrace/transport/http/api/endpoint.rb +1 -0
  677. data/lib/ddtrace/transport/http/api/fallbacks.rb +1 -0
  678. data/lib/ddtrace/transport/http/api/instance.rb +1 -0
  679. data/lib/ddtrace/transport/http/api/map.rb +2 -1
  680. data/lib/ddtrace/transport/http/api/spec.rb +1 -0
  681. data/lib/ddtrace/transport/http/api.rb +8 -14
  682. data/lib/ddtrace/transport/http/builder.rb +18 -10
  683. data/lib/ddtrace/transport/http/client.rb +5 -3
  684. data/lib/ddtrace/transport/http/env.rb +1 -0
  685. data/lib/ddtrace/transport/http/response.rb +36 -5
  686. data/lib/ddtrace/transport/http/statistics.rb +2 -1
  687. data/lib/ddtrace/transport/http/traces.rb +6 -3
  688. data/lib/ddtrace/transport/http.rb +40 -38
  689. data/lib/ddtrace/transport/io/client.rb +6 -3
  690. data/lib/ddtrace/transport/io/response.rb +2 -1
  691. data/lib/ddtrace/transport/io/traces.rb +5 -4
  692. data/lib/ddtrace/transport/io.rb +5 -4
  693. data/lib/ddtrace/transport/parcel.rb +2 -0
  694. data/lib/ddtrace/transport/request.rb +1 -0
  695. data/lib/ddtrace/transport/response.rb +1 -0
  696. data/lib/ddtrace/transport/serializable_trace.rb +118 -0
  697. data/lib/ddtrace/transport/statistics.rb +6 -4
  698. data/lib/ddtrace/transport/trace_formatter.rb +191 -0
  699. data/lib/ddtrace/transport/traces.rb +20 -8
  700. data/lib/ddtrace/version.rb +14 -12
  701. data/lib/ddtrace.rb +9 -48
  702. metadata +681 -475
  703. data/.editorconfig +0 -22
  704. data/.gitignore +0 -67
  705. data/.yardopts +0 -5
  706. data/CONTRIBUTING.md +0 -81
  707. data/ddtrace.gemspec +0 -53
  708. data/docs/DevelopmentGuide.md +0 -264
  709. data/docs/GettingStarted.md +0 -2535
  710. data/docs/ProfilingDevelopment.md +0 -107
  711. data/lib/datadog/ci/context_flush.rb +0 -29
  712. data/lib/datadog/contrib.rb +0 -69
  713. data/lib/ddtrace/analytics.rb +0 -39
  714. data/lib/ddtrace/buffer.rb +0 -328
  715. data/lib/ddtrace/chunker.rb +0 -35
  716. data/lib/ddtrace/configuration/agent_settings_resolver.rb +0 -231
  717. data/lib/ddtrace/configuration/base.rb +0 -82
  718. data/lib/ddtrace/configuration/components.rb +0 -292
  719. data/lib/ddtrace/configuration/dependency_resolver.rb +0 -25
  720. data/lib/ddtrace/configuration/option.rb +0 -65
  721. data/lib/ddtrace/configuration/option_definition.rb +0 -122
  722. data/lib/ddtrace/configuration/option_definition_set.rb +0 -19
  723. data/lib/ddtrace/configuration/option_set.rb +0 -7
  724. data/lib/ddtrace/configuration/options.rb +0 -112
  725. data/lib/ddtrace/configuration/pin_setup.rb +0 -32
  726. data/lib/ddtrace/configuration/settings.rb +0 -403
  727. data/lib/ddtrace/configuration.rb +0 -195
  728. data/lib/ddtrace/context.rb +0 -326
  729. data/lib/ddtrace/context_flush.rb +0 -82
  730. data/lib/ddtrace/context_provider.rb +0 -62
  731. data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +0 -31
  732. data/lib/ddtrace/contrib/action_cable/event.rb +0 -67
  733. data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +0 -50
  734. data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +0 -56
  735. data/lib/ddtrace/contrib/action_cable/events/transmit.rb +0 -51
  736. data/lib/ddtrace/contrib/action_cable/events.rb +0 -34
  737. data/lib/ddtrace/contrib/action_cable/ext.rb +0 -27
  738. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +0 -32
  739. data/lib/ddtrace/contrib/action_cable/integration.rb +0 -46
  740. data/lib/ddtrace/contrib/action_cable/patcher.rb +0 -28
  741. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +0 -157
  742. data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +0 -26
  743. data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +0 -33
  744. data/lib/ddtrace/contrib/action_pack/ext.rb +0 -20
  745. data/lib/ddtrace/contrib/action_pack/integration.rb +0 -46
  746. data/lib/ddtrace/contrib/action_pack/patcher.rb +0 -24
  747. data/lib/ddtrace/contrib/action_pack/utils.rb +0 -37
  748. data/lib/ddtrace/contrib/action_view/configuration/settings.rb +0 -32
  749. data/lib/ddtrace/contrib/action_view/event.rb +0 -36
  750. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +0 -47
  751. data/lib/ddtrace/contrib/action_view/events/render_template.rb +0 -50
  752. data/lib/ddtrace/contrib/action_view/events.rb +0 -31
  753. data/lib/ddtrace/contrib/action_view/ext.rb +0 -21
  754. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +0 -75
  755. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +0 -168
  756. data/lib/ddtrace/contrib/action_view/integration.rb +0 -53
  757. data/lib/ddtrace/contrib/action_view/patcher.rb +0 -48
  758. data/lib/ddtrace/contrib/action_view/utils.rb +0 -33
  759. data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +0 -31
  760. data/lib/ddtrace/contrib/active_model_serializers/event.rb +0 -69
  761. data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +0 -33
  762. data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +0 -36
  763. data/lib/ddtrace/contrib/active_model_serializers/events.rb +0 -31
  764. data/lib/ddtrace/contrib/active_model_serializers/ext.rb +0 -21
  765. data/lib/ddtrace/contrib/active_model_serializers/integration.rb +0 -41
  766. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +0 -30
  767. data/lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb +0 -31
  768. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +0 -135
  769. data/lib/ddtrace/contrib/active_record/configuration/settings.rb +0 -36
  770. data/lib/ddtrace/contrib/active_record/event.rb +0 -31
  771. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +0 -61
  772. data/lib/ddtrace/contrib/active_record/events/sql.rb +0 -69
  773. data/lib/ddtrace/contrib/active_record/events.rb +0 -31
  774. data/lib/ddtrace/contrib/active_record/ext.rb +0 -25
  775. data/lib/ddtrace/contrib/active_record/integration.rb +0 -54
  776. data/lib/ddtrace/contrib/active_record/patcher.rb +0 -24
  777. data/lib/ddtrace/contrib/active_record/utils.rb +0 -124
  778. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +0 -259
  779. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +0 -70
  780. data/lib/ddtrace/contrib/active_support/cache/redis.rb +0 -44
  781. data/lib/ddtrace/contrib/active_support/configuration/settings.rb +0 -31
  782. data/lib/ddtrace/contrib/active_support/ext.rb +0 -28
  783. data/lib/ddtrace/contrib/active_support/integration.rb +0 -47
  784. data/lib/ddtrace/contrib/active_support/notifications/event.rb +0 -76
  785. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +0 -68
  786. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +0 -164
  787. data/lib/ddtrace/contrib/active_support/patcher.rb +0 -24
  788. data/lib/ddtrace/contrib/analytics.rb +0 -25
  789. data/lib/ddtrace/contrib/auto_instrument.rb +0 -49
  790. data/lib/ddtrace/contrib/aws/configuration/settings.rb +0 -31
  791. data/lib/ddtrace/contrib/aws/ext.rb +0 -24
  792. data/lib/ddtrace/contrib/aws/instrumentation.rb +0 -91
  793. data/lib/ddtrace/contrib/aws/integration.rb +0 -43
  794. data/lib/ddtrace/contrib/aws/parsed_context.rb +0 -57
  795. data/lib/ddtrace/contrib/aws/patcher.rb +0 -54
  796. data/lib/ddtrace/contrib/aws/services.rb +0 -119
  797. data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +0 -21
  798. data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +0 -42
  799. data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +0 -13
  800. data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +0 -24
  801. data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +0 -39
  802. data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +0 -30
  803. data/lib/ddtrace/contrib/configurable.rb +0 -103
  804. data/lib/ddtrace/contrib/configuration/resolver.rb +0 -82
  805. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +0 -40
  806. data/lib/ddtrace/contrib/configuration/settings.rb +0 -56
  807. data/lib/ddtrace/contrib/dalli/configuration/settings.rb +0 -31
  808. data/lib/ddtrace/contrib/dalli/ext.rb +0 -21
  809. data/lib/ddtrace/contrib/dalli/instrumentation.rb +0 -55
  810. data/lib/ddtrace/contrib/dalli/integration.rb +0 -39
  811. data/lib/ddtrace/contrib/dalli/patcher.rb +0 -26
  812. data/lib/ddtrace/contrib/dalli/quantize.rb +0 -23
  813. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +0 -33
  814. data/lib/ddtrace/contrib/delayed_job/ext.rb +0 -24
  815. data/lib/ddtrace/contrib/delayed_job/integration.rb +0 -39
  816. data/lib/ddtrace/contrib/delayed_job/patcher.rb +0 -29
  817. data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -85
  818. data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +0 -32
  819. data/lib/ddtrace/contrib/elasticsearch/ext.rb +0 -23
  820. data/lib/ddtrace/contrib/elasticsearch/integration.rb +0 -40
  821. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +0 -123
  822. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +0 -84
  823. data/lib/ddtrace/contrib/ethon/configuration/settings.rb +0 -33
  824. data/lib/ddtrace/contrib/ethon/easy_patch.rb +0 -152
  825. data/lib/ddtrace/contrib/ethon/ext.rb +0 -20
  826. data/lib/ddtrace/contrib/ethon/integration.rb +0 -44
  827. data/lib/ddtrace/contrib/ethon/multi_patch.rb +0 -85
  828. data/lib/ddtrace/contrib/ethon/patcher.rb +0 -27
  829. data/lib/ddtrace/contrib/excon/configuration/settings.rb +0 -34
  830. data/lib/ddtrace/contrib/excon/ext.rb +0 -18
  831. data/lib/ddtrace/contrib/excon/integration.rb +0 -44
  832. data/lib/ddtrace/contrib/excon/middleware.rb +0 -164
  833. data/lib/ddtrace/contrib/excon/patcher.rb +0 -28
  834. data/lib/ddtrace/contrib/extensions.rb +0 -169
  835. data/lib/ddtrace/contrib/faraday/configuration/settings.rb +0 -39
  836. data/lib/ddtrace/contrib/faraday/connection.rb +0 -19
  837. data/lib/ddtrace/contrib/faraday/ext.rb +0 -18
  838. data/lib/ddtrace/contrib/faraday/integration.rb +0 -44
  839. data/lib/ddtrace/contrib/faraday/middleware.rb +0 -86
  840. data/lib/ddtrace/contrib/faraday/patcher.rb +0 -54
  841. data/lib/ddtrace/contrib/faraday/rack_builder.rb +0 -19
  842. data/lib/ddtrace/contrib/grape/configuration/settings.rb +0 -39
  843. data/lib/ddtrace/contrib/grape/endpoint.rb +0 -246
  844. data/lib/ddtrace/contrib/grape/ext.rb +0 -24
  845. data/lib/ddtrace/contrib/grape/instrumentation.rb +0 -34
  846. data/lib/ddtrace/contrib/grape/integration.rb +0 -40
  847. data/lib/ddtrace/contrib/grape/patcher.rb +0 -32
  848. data/lib/ddtrace/contrib/graphql/configuration/settings.rb +0 -33
  849. data/lib/ddtrace/contrib/graphql/ext.rb +0 -17
  850. data/lib/ddtrace/contrib/graphql/integration.rb +0 -40
  851. data/lib/ddtrace/contrib/graphql/patcher.rb +0 -61
  852. data/lib/ddtrace/contrib/grpc/configuration/settings.rb +0 -32
  853. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +0 -59
  854. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +0 -80
  855. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +0 -79
  856. data/lib/ddtrace/contrib/grpc/ext.rb +0 -19
  857. data/lib/ddtrace/contrib/grpc/integration.rb +0 -39
  858. data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +0 -50
  859. data/lib/ddtrace/contrib/grpc/patcher.rb +0 -34
  860. data/lib/ddtrace/contrib/http/circuit_breaker.rb +0 -38
  861. data/lib/ddtrace/contrib/http/configuration/settings.rb +0 -33
  862. data/lib/ddtrace/contrib/http/ext.rb +0 -18
  863. data/lib/ddtrace/contrib/http/instrumentation.rb +0 -180
  864. data/lib/ddtrace/contrib/http/integration.rb +0 -46
  865. data/lib/ddtrace/contrib/http/patcher.rb +0 -27
  866. data/lib/ddtrace/contrib/http_annotation_helper.rb +0 -11
  867. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +0 -33
  868. data/lib/ddtrace/contrib/httpclient/ext.rb +0 -18
  869. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +0 -148
  870. data/lib/ddtrace/contrib/httpclient/integration.rb +0 -44
  871. data/lib/ddtrace/contrib/httpclient/patcher.rb +0 -39
  872. data/lib/ddtrace/contrib/httprb/configuration/settings.rb +0 -33
  873. data/lib/ddtrace/contrib/httprb/ext.rb +0 -18
  874. data/lib/ddtrace/contrib/httprb/instrumentation.rb +0 -158
  875. data/lib/ddtrace/contrib/httprb/integration.rb +0 -44
  876. data/lib/ddtrace/contrib/httprb/patcher.rb +0 -39
  877. data/lib/ddtrace/contrib/integration.rb +0 -17
  878. data/lib/ddtrace/contrib/kafka/configuration/settings.rb +0 -31
  879. data/lib/ddtrace/contrib/kafka/consumer_event.rb +0 -15
  880. data/lib/ddtrace/contrib/kafka/consumer_group_event.rb +0 -15
  881. data/lib/ddtrace/contrib/kafka/event.rb +0 -52
  882. data/lib/ddtrace/contrib/kafka/events/connection/request.rb +0 -35
  883. data/lib/ddtrace/contrib/kafka/events/consumer/process_batch.rb +0 -42
  884. data/lib/ddtrace/contrib/kafka/events/consumer/process_message.rb +0 -40
  885. data/lib/ddtrace/contrib/kafka/events/consumer_group/heartbeat.rb +0 -40
  886. data/lib/ddtrace/contrib/kafka/events/consumer_group/join_group.rb +0 -30
  887. data/lib/ddtrace/contrib/kafka/events/consumer_group/leave_group.rb +0 -30
  888. data/lib/ddtrace/contrib/kafka/events/consumer_group/sync_group.rb +0 -30
  889. data/lib/ddtrace/contrib/kafka/events/produce_operation/send_messages.rb +0 -33
  890. data/lib/ddtrace/contrib/kafka/events/producer/deliver_messages.rb +0 -36
  891. data/lib/ddtrace/contrib/kafka/events.rb +0 -45
  892. data/lib/ddtrace/contrib/kafka/ext.rb +0 -42
  893. data/lib/ddtrace/contrib/kafka/integration.rb +0 -40
  894. data/lib/ddtrace/contrib/kafka/patcher.rb +0 -27
  895. data/lib/ddtrace/contrib/lograge/configuration/settings.rb +0 -19
  896. data/lib/ddtrace/contrib/lograge/ext.rb +0 -11
  897. data/lib/ddtrace/contrib/lograge/instrumentation.rb +0 -39
  898. data/lib/ddtrace/contrib/lograge/integration.rb +0 -46
  899. data/lib/ddtrace/contrib/lograge/patcher.rb +0 -26
  900. data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +0 -34
  901. data/lib/ddtrace/contrib/mongodb/ext.rb +0 -24
  902. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +0 -70
  903. data/lib/ddtrace/contrib/mongodb/integration.rb +0 -39
  904. data/lib/ddtrace/contrib/mongodb/parsers.rb +0 -69
  905. data/lib/ddtrace/contrib/mongodb/patcher.rb +0 -32
  906. data/lib/ddtrace/contrib/mongodb/subscribers.rb +0 -112
  907. data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +0 -31
  908. data/lib/ddtrace/contrib/mysql2/ext.rb +0 -19
  909. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +0 -65
  910. data/lib/ddtrace/contrib/mysql2/integration.rb +0 -39
  911. data/lib/ddtrace/contrib/mysql2/patcher.rb +0 -28
  912. data/lib/ddtrace/contrib/patchable.rb +0 -71
  913. data/lib/ddtrace/contrib/patcher.rb +0 -66
  914. data/lib/ddtrace/contrib/presto/configuration/settings.rb +0 -31
  915. data/lib/ddtrace/contrib/presto/ext.rb +0 -29
  916. data/lib/ddtrace/contrib/presto/instrumentation.rb +0 -111
  917. data/lib/ddtrace/contrib/presto/integration.rb +0 -39
  918. data/lib/ddtrace/contrib/presto/patcher.rb +0 -34
  919. data/lib/ddtrace/contrib/qless/configuration/settings.rb +0 -36
  920. data/lib/ddtrace/contrib/qless/ext.rb +0 -21
  921. data/lib/ddtrace/contrib/qless/integration.rb +0 -39
  922. data/lib/ddtrace/contrib/qless/patcher.rb +0 -35
  923. data/lib/ddtrace/contrib/qless/qless_job.rb +0 -74
  924. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +0 -34
  925. data/lib/ddtrace/contrib/que/configuration/settings.rb +0 -44
  926. data/lib/ddtrace/contrib/que/ext.rb +0 -31
  927. data/lib/ddtrace/contrib/que/integration.rb +0 -43
  928. data/lib/ddtrace/contrib/que/patcher.rb +0 -25
  929. data/lib/ddtrace/contrib/que/tracer.rb +0 -58
  930. data/lib/ddtrace/contrib/racecar/configuration/settings.rb +0 -31
  931. data/lib/ddtrace/contrib/racecar/event.rb +0 -77
  932. data/lib/ddtrace/contrib/racecar/events/batch.rb +0 -28
  933. data/lib/ddtrace/contrib/racecar/events/consume.rb +0 -28
  934. data/lib/ddtrace/contrib/racecar/events/message.rb +0 -28
  935. data/lib/ddtrace/contrib/racecar/events.rb +0 -33
  936. data/lib/ddtrace/contrib/racecar/ext.rb +0 -26
  937. data/lib/ddtrace/contrib/racecar/integration.rb +0 -40
  938. data/lib/ddtrace/contrib/racecar/patcher.rb +0 -27
  939. data/lib/ddtrace/contrib/rack/configuration/settings.rb +0 -47
  940. data/lib/ddtrace/contrib/rack/ext.rb +0 -22
  941. data/lib/ddtrace/contrib/rack/integration.rb +0 -46
  942. data/lib/ddtrace/contrib/rack/middlewares.rb +0 -288
  943. data/lib/ddtrace/contrib/rack/patcher.rb +0 -106
  944. data/lib/ddtrace/contrib/rack/request_queue.rb +0 -45
  945. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +0 -11
  946. data/lib/ddtrace/contrib/rails/configuration/settings.rb +0 -94
  947. data/lib/ddtrace/contrib/rails/ext.rb +0 -18
  948. data/lib/ddtrace/contrib/rails/framework.rb +0 -149
  949. data/lib/ddtrace/contrib/rails/integration.rb +0 -45
  950. data/lib/ddtrace/contrib/rails/log_injection.rb +0 -42
  951. data/lib/ddtrace/contrib/rails/middlewares.rb +0 -44
  952. data/lib/ddtrace/contrib/rails/patcher.rb +0 -110
  953. data/lib/ddtrace/contrib/rails/railtie.rb +0 -18
  954. data/lib/ddtrace/contrib/rails/utils.rb +0 -25
  955. data/lib/ddtrace/contrib/rake/configuration/settings.rb +0 -32
  956. data/lib/ddtrace/contrib/rake/ext.rb +0 -22
  957. data/lib/ddtrace/contrib/rake/instrumentation.rb +0 -91
  958. data/lib/ddtrace/contrib/rake/integration.rb +0 -39
  959. data/lib/ddtrace/contrib/rake/patcher.rb +0 -31
  960. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +0 -46
  961. data/lib/ddtrace/contrib/redis/configuration/settings.rb +0 -36
  962. data/lib/ddtrace/contrib/redis/ext.rb +0 -23
  963. data/lib/ddtrace/contrib/redis/integration.rb +0 -43
  964. data/lib/ddtrace/contrib/redis/patcher.rb +0 -115
  965. data/lib/ddtrace/contrib/redis/quantize.rb +0 -76
  966. data/lib/ddtrace/contrib/redis/tags.rb +0 -47
  967. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +0 -159
  968. data/lib/ddtrace/contrib/registerable.rb +0 -34
  969. data/lib/ddtrace/contrib/registry.rb +0 -43
  970. data/lib/ddtrace/contrib/resque/configuration/settings.rb +0 -49
  971. data/lib/ddtrace/contrib/resque/ext.rb +0 -18
  972. data/lib/ddtrace/contrib/resque/integration.rb +0 -48
  973. data/lib/ddtrace/contrib/resque/patcher.rb +0 -30
  974. data/lib/ddtrace/contrib/resque/resque_job.rb +0 -104
  975. data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +0 -32
  976. data/lib/ddtrace/contrib/rest_client/ext.rb +0 -18
  977. data/lib/ddtrace/contrib/rest_client/integration.rb +0 -39
  978. data/lib/ddtrace/contrib/rest_client/patcher.rb +0 -25
  979. data/lib/ddtrace/contrib/rest_client/request_patch.rb +0 -92
  980. data/lib/ddtrace/contrib/semantic_logger/configuration/settings.rb +0 -19
  981. data/lib/ddtrace/contrib/semantic_logger/ext.rb +0 -11
  982. data/lib/ddtrace/contrib/semantic_logger/instrumentation.rb +0 -43
  983. data/lib/ddtrace/contrib/semantic_logger/integration.rb +0 -48
  984. data/lib/ddtrace/contrib/semantic_logger/patcher.rb +0 -26
  985. data/lib/ddtrace/contrib/sequel/configuration/settings.rb +0 -29
  986. data/lib/ddtrace/contrib/sequel/database.rb +0 -64
  987. data/lib/ddtrace/contrib/sequel/dataset.rb +0 -64
  988. data/lib/ddtrace/contrib/sequel/ext.rb +0 -20
  989. data/lib/ddtrace/contrib/sequel/integration.rb +0 -39
  990. data/lib/ddtrace/contrib/sequel/patcher.rb +0 -34
  991. data/lib/ddtrace/contrib/sequel/utils.rb +0 -75
  992. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +0 -32
  993. data/lib/ddtrace/contrib/shoryuken/ext.rb +0 -22
  994. data/lib/ddtrace/contrib/shoryuken/integration.rb +0 -40
  995. data/lib/ddtrace/contrib/shoryuken/patcher.rb +0 -25
  996. data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -56
  997. data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +0 -44
  998. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +0 -38
  999. data/lib/ddtrace/contrib/sidekiq/ext.rb +0 -28
  1000. data/lib/ddtrace/contrib/sidekiq/integration.rb +0 -39
  1001. data/lib/ddtrace/contrib/sidekiq/patcher.rb +0 -42
  1002. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +0 -66
  1003. data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -45
  1004. data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +0 -40
  1005. data/lib/ddtrace/contrib/sinatra/env.rb +0 -58
  1006. data/lib/ddtrace/contrib/sinatra/ext.rb +0 -28
  1007. data/lib/ddtrace/contrib/sinatra/headers.rb +0 -30
  1008. data/lib/ddtrace/contrib/sinatra/integration.rb +0 -39
  1009. data/lib/ddtrace/contrib/sinatra/patcher.rb +0 -30
  1010. data/lib/ddtrace/contrib/sinatra/tracer.rb +0 -137
  1011. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +0 -112
  1012. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +0 -34
  1013. data/lib/ddtrace/contrib/sneakers/ext.rb +0 -23
  1014. data/lib/ddtrace/contrib/sneakers/integration.rb +0 -42
  1015. data/lib/ddtrace/contrib/sneakers/patcher.rb +0 -25
  1016. data/lib/ddtrace/contrib/sneakers/tracer.rb +0 -54
  1017. data/lib/ddtrace/contrib/status_code_matcher.rb +0 -70
  1018. data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +0 -31
  1019. data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +0 -25
  1020. data/lib/ddtrace/contrib/sucker_punch/ext.rb +0 -22
  1021. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +0 -89
  1022. data/lib/ddtrace/contrib/sucker_punch/integration.rb +0 -39
  1023. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +0 -44
  1024. data/lib/ddtrace/correlation.rb +0 -40
  1025. data/lib/ddtrace/diagnostics/environment_logger.rb +0 -280
  1026. data/lib/ddtrace/diagnostics/health.rb +0 -34
  1027. data/lib/ddtrace/distributed_tracing/headers/b3.rb +0 -45
  1028. data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +0 -57
  1029. data/lib/ddtrace/distributed_tracing/headers/datadog.rb +0 -43
  1030. data/lib/ddtrace/distributed_tracing/headers/headers.rb +0 -72
  1031. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +0 -44
  1032. data/lib/ddtrace/encoding.rb +0 -72
  1033. data/lib/ddtrace/error.rb +0 -97
  1034. data/lib/ddtrace/event.rb +0 -53
  1035. data/lib/ddtrace/ext/analytics.rb +0 -13
  1036. data/lib/ddtrace/ext/app_types.rb +0 -12
  1037. data/lib/ddtrace/ext/correlation.rb +0 -12
  1038. data/lib/ddtrace/ext/diagnostics.rb +0 -37
  1039. data/lib/ddtrace/ext/distributed.rb +0 -40
  1040. data/lib/ddtrace/ext/environment.rb +0 -24
  1041. data/lib/ddtrace/ext/errors.rb +0 -11
  1042. data/lib/ddtrace/ext/forced_tracing.rb +0 -26
  1043. data/lib/ddtrace/ext/git.rb +0 -20
  1044. data/lib/ddtrace/ext/http.rb +0 -47
  1045. data/lib/ddtrace/ext/integration.rb +0 -9
  1046. data/lib/ddtrace/ext/manual_tracing.rb +0 -10
  1047. data/lib/ddtrace/ext/metrics.rb +0 -16
  1048. data/lib/ddtrace/ext/net.rb +0 -11
  1049. data/lib/ddtrace/ext/priority.rb +0 -17
  1050. data/lib/ddtrace/ext/profiling.rb +0 -56
  1051. data/lib/ddtrace/ext/runtime.rb +0 -22
  1052. data/lib/ddtrace/ext/sampling.rb +0 -17
  1053. data/lib/ddtrace/ext/sql.rb +0 -9
  1054. data/lib/ddtrace/ext/test.rb +0 -9
  1055. data/lib/ddtrace/ext/transport.rb +0 -21
  1056. data/lib/ddtrace/forced_tracing.rb +0 -39
  1057. data/lib/ddtrace/logger.rb +0 -41
  1058. data/lib/ddtrace/metrics.rb +0 -282
  1059. data/lib/ddtrace/opentelemetry/extensions.rb +0 -14
  1060. data/lib/ddtrace/opentelemetry/span.rb +0 -34
  1061. data/lib/ddtrace/opentracer/binary_propagator.rb +0 -25
  1062. data/lib/ddtrace/opentracer/carrier.rb +0 -7
  1063. data/lib/ddtrace/opentracer/distributed_headers.rb +0 -56
  1064. data/lib/ddtrace/opentracer/global_tracer.rb +0 -16
  1065. data/lib/ddtrace/opentracer/propagator.rb +0 -23
  1066. data/lib/ddtrace/opentracer/rack_propagator.rb +0 -61
  1067. data/lib/ddtrace/opentracer/scope.rb +0 -16
  1068. data/lib/ddtrace/opentracer/scope_manager.rb +0 -7
  1069. data/lib/ddtrace/opentracer/span.rb +0 -95
  1070. data/lib/ddtrace/opentracer/span_context.rb +0 -15
  1071. data/lib/ddtrace/opentracer/span_context_factory.rb +0 -24
  1072. data/lib/ddtrace/opentracer/text_map_propagator.rb +0 -76
  1073. data/lib/ddtrace/opentracer/thread_local_scope.rb +0 -32
  1074. data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +0 -41
  1075. data/lib/ddtrace/opentracer/tracer.rb +0 -209
  1076. data/lib/ddtrace/opentracer.rb +0 -22
  1077. data/lib/ddtrace/patcher.rb +0 -69
  1078. data/lib/ddtrace/pin.rb +0 -86
  1079. data/lib/ddtrace/pipeline/span_filter.rb +0 -39
  1080. data/lib/ddtrace/pipeline/span_processor.rb +0 -21
  1081. data/lib/ddtrace/pipeline.rb +0 -47
  1082. data/lib/ddtrace/profiling/backtrace_location.rb +0 -33
  1083. data/lib/ddtrace/profiling/buffer.rb +0 -42
  1084. data/lib/ddtrace/profiling/collectors/stack.rb +0 -257
  1085. data/lib/ddtrace/profiling/encoding/profile.rb +0 -38
  1086. data/lib/ddtrace/profiling/event.rb +0 -14
  1087. data/lib/ddtrace/profiling/events/stack.rb +0 -81
  1088. data/lib/ddtrace/profiling/exporter.rb +0 -24
  1089. data/lib/ddtrace/profiling/ext/cpu.rb +0 -67
  1090. data/lib/ddtrace/profiling/ext/cthread.rb +0 -156
  1091. data/lib/ddtrace/profiling/ext/forking.rb +0 -98
  1092. data/lib/ddtrace/profiling/flush.rb +0 -44
  1093. data/lib/ddtrace/profiling/native_extension.rb +0 -18
  1094. data/lib/ddtrace/profiling/pprof/builder.rb +0 -120
  1095. data/lib/ddtrace/profiling/pprof/converter.rb +0 -90
  1096. data/lib/ddtrace/profiling/pprof/message_set.rb +0 -15
  1097. data/lib/ddtrace/profiling/pprof/payload.rb +0 -19
  1098. data/lib/ddtrace/profiling/pprof/pprof_pb.rb +0 -82
  1099. data/lib/ddtrace/profiling/pprof/stack_sample.rb +0 -117
  1100. data/lib/ddtrace/profiling/pprof/string_table.rb +0 -11
  1101. data/lib/ddtrace/profiling/pprof/template.rb +0 -119
  1102. data/lib/ddtrace/profiling/profiler.rb +0 -31
  1103. data/lib/ddtrace/profiling/recorder.rb +0 -96
  1104. data/lib/ddtrace/profiling/scheduler.rb +0 -134
  1105. data/lib/ddtrace/profiling/tasks/setup.rb +0 -82
  1106. data/lib/ddtrace/profiling/trace_identifiers/ddtrace.rb +0 -41
  1107. data/lib/ddtrace/profiling/trace_identifiers/helper.rb +0 -46
  1108. data/lib/ddtrace/profiling/transport/client.rb +0 -15
  1109. data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +0 -101
  1110. data/lib/ddtrace/profiling/transport/http/api/instance.rb +0 -37
  1111. data/lib/ddtrace/profiling/transport/http/api/spec.rb +0 -41
  1112. data/lib/ddtrace/profiling/transport/http/api.rb +0 -44
  1113. data/lib/ddtrace/profiling/transport/http/builder.rb +0 -29
  1114. data/lib/ddtrace/profiling/transport/http/client.rb +0 -34
  1115. data/lib/ddtrace/profiling/transport/http/response.rb +0 -22
  1116. data/lib/ddtrace/profiling/transport/http.rb +0 -120
  1117. data/lib/ddtrace/profiling/transport/io/client.rb +0 -28
  1118. data/lib/ddtrace/profiling/transport/io/response.rb +0 -17
  1119. data/lib/ddtrace/profiling/transport/io.rb +0 -31
  1120. data/lib/ddtrace/profiling/transport/parcel.rb +0 -18
  1121. data/lib/ddtrace/profiling/transport/request.rb +0 -16
  1122. data/lib/ddtrace/profiling/transport/response.rb +0 -9
  1123. data/lib/ddtrace/profiling.rb +0 -151
  1124. data/lib/ddtrace/propagation/grpc_propagator.rb +0 -75
  1125. data/lib/ddtrace/propagation/http_propagator.rb +0 -91
  1126. data/lib/ddtrace/quantization/hash.rb +0 -104
  1127. data/lib/ddtrace/quantization/http.rb +0 -90
  1128. data/lib/ddtrace/runtime/metrics.rb +0 -121
  1129. data/lib/ddtrace/sampler.rb +0 -293
  1130. data/lib/ddtrace/sampling/matcher.rb +0 -58
  1131. data/lib/ddtrace/sampling/rate_limiter.rb +0 -177
  1132. data/lib/ddtrace/sampling/rule.rb +0 -62
  1133. data/lib/ddtrace/sampling/rule_sampler.rb +0 -121
  1134. data/lib/ddtrace/sampling.rb +0 -3
  1135. data/lib/ddtrace/span.rb +0 -457
  1136. data/lib/ddtrace/sync_writer.rb +0 -69
  1137. data/lib/ddtrace/tasks/exec.rb +0 -47
  1138. data/lib/ddtrace/tasks/help.rb +0 -15
  1139. data/lib/ddtrace/tracer.rb +0 -449
  1140. data/lib/ddtrace/utils/compression.rb +0 -28
  1141. data/lib/ddtrace/utils/database.rb +0 -26
  1142. data/lib/ddtrace/utils/forking.rb +0 -53
  1143. data/lib/ddtrace/utils/object_set.rb +0 -40
  1144. data/lib/ddtrace/utils/only_once.rb +0 -41
  1145. data/lib/ddtrace/utils/sequence.rb +0 -18
  1146. data/lib/ddtrace/utils/string_table.rb +0 -46
  1147. data/lib/ddtrace/utils/time.rb +0 -46
  1148. data/lib/ddtrace/utils.rb +0 -80
  1149. data/lib/ddtrace/vendor/active_record/connection_specification.rb +0 -302
  1150. data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +0 -117
  1151. data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +0 -58
  1152. data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +0 -136
  1153. data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +0 -10
  1154. data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +0 -9
  1155. data/lib/ddtrace/vendor/multipart-post/multipart.rb +0 -13
  1156. data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +0 -33
  1157. data/lib/ddtrace/worker.rb +0 -21
  1158. data/lib/ddtrace/workers/async.rb +0 -175
  1159. data/lib/ddtrace/workers/loop.rb +0 -132
  1160. data/lib/ddtrace/workers/polling.rb +0 -56
  1161. data/lib/ddtrace/workers/queue.rb +0 -41
  1162. data/lib/ddtrace/workers/runtime_metrics.rb +0 -65
  1163. data/lib/ddtrace/workers/trace_writer.rb +0 -200
  1164. data/lib/ddtrace/workers.rb +0 -123
  1165. data/lib/ddtrace/writer.rb +0 -200
  1166. /data/lib/{ddtrace → datadog/core}/vendor/multipart-post/LICENSE +0 -0
  1167. /data/lib/{ddtrace → datadog}/profiling/pprof/pprof.proto +0 -0
  1168. /data/lib/{ddtrace/vendor/active_record → datadog/tracing/contrib/active_record/vendor}/MIT-LICENSE +0 -0
  1169. /data/lib/{ddtrace → datadog/tracing}/contrib/redis/vendor/LICENSE +0 -0
@@ -1,2535 +0,0 @@
1
- # Datadog Ruby Trace Client
2
-
3
- `ddtrace` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
4
- databases and microservices so that developers have high visibility into bottlenecks and troublesome requests.
5
-
6
- ## Getting started
7
-
8
- For the general APM documentation, see our [setup documentation][setup docs].
9
-
10
- For more information about what APM looks like once your application is sending information to Datadog, take a look at [Visualizing your APM data][visualization docs].
11
-
12
- To contribute, check out the [contribution guidelines][contribution docs] and [development guide][development docs].
13
-
14
- [setup docs]: https://docs.datadoghq.com/tracing/
15
- [development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/README.md#development
16
- [visualization docs]: https://docs.datadoghq.com/tracing/visualization/
17
- [contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
18
- [development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
19
-
20
- ## Table of Contents
21
-
22
- - [Compatibility](#compatibility)
23
- - [Installation](#installation)
24
- - [Quickstart for Rails applications](#quickstart-for-rails-applications)
25
- - [Quickstart for Ruby applications](#quickstart-for-ruby-applications)
26
- - [Quickstart for OpenTracing](#quickstart-for-opentracing)
27
- - [Manual instrumentation](#manual-instrumentation)
28
- - [Integration instrumentation](#integration-instrumentation)
29
- - [Action Cable](#action-cable)
30
- - [Action View](#action-view)
31
- - [Active Model Serializers](#active-model-serializers)
32
- - [Action Pack](#action-pack)
33
- - [Active Record](#active-record)
34
- - [Active Support](#active-support)
35
- - [AWS](#aws)
36
- - [Concurrent Ruby](#concurrent-ruby)
37
- - [Cucumber](#cucumber)
38
- - [Dalli](#dalli)
39
- - [DelayedJob](#delayedjob)
40
- - [Elasticsearch](#elasticsearch)
41
- - [Ethon & Typhoeus](#ethon)
42
- - [Excon](#excon)
43
- - [Faraday](#faraday)
44
- - [Grape](#grape)
45
- - [GraphQL](#graphql)
46
- - [gRPC](#grpc)
47
- - [http.rb](#http-rb)
48
- - [httpclient](#httpclient)
49
- - [httpx](#httpx)
50
- - [MongoDB](#mongodb)
51
- - [MySQL2](#mysql2)
52
- - [Net/HTTP](#net-http)
53
- - [Presto](#presto)
54
- - [Qless](#qless)
55
- - [Que](#que)
56
- - [Racecar](#racecar)
57
- - [Rack](#rack)
58
- - [Rails](#rails)
59
- - [Rake](#rake)
60
- - [Redis](#redis)
61
- - [Rest Client](#rest-client)
62
- - [Resque](#resque)
63
- - [RSpec](#rspec)
64
- - [Shoryuken](#shoryuken)
65
- - [Sequel](#sequel)
66
- - [Sidekiq](#sidekiq)
67
- - [Sinatra](#sinatra)
68
- - [Sneakers](#sneakers)
69
- - [Sucker Punch](#sucker-punch)
70
- - [Advanced configuration](#advanced-configuration)
71
- - [Tracer settings](#tracer-settings)
72
- - [Custom logging](#custom-logging)
73
- - [Environment and tags](#environment-and-tags)
74
- - [Environment variables](#environment-variables)
75
- - [Sampling](#sampling)
76
- - [Application-side sampling](#application-side-sampling)
77
- - [Priority sampling](#priority-sampling)
78
- - [Distributed tracing](#distributed-tracing)
79
- - [HTTP request queuing](#http-request-queuing)
80
- - [Processing pipeline](#processing-pipeline)
81
- - [Filtering](#filtering)
82
- - [Processing](#processing)
83
- - [Trace correlation](#trace-correlation)
84
- - [Configuring the transport layer](#configuring-the-transport-layer)
85
- - [Metrics](#metrics)
86
- - [For application runtime](#for-application-runtime)
87
- - [OpenTracing](#opentracing)
88
- - [Profiling](#profiling)
89
- - [Troubleshooting](#troubleshooting)
90
- - [Profiling Resque jobs](#profiling-resque-jobs)
91
- - [Known issues and suggested configurations](#known-issues-and-suggested-configurations)
92
- - [Payload too large](#payload-too-large)
93
- - [Stack level too deep](#stack-level-too-deep)
94
-
95
- ## Compatibility
96
-
97
- **Supported Ruby interpreters**:
98
-
99
- | Type | Documentation | Version | Support type | Gem version support |
100
- | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
101
- | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
102
- | | | 2.7 | Full | Latest |
103
- | | | 2.6 | Full | Latest |
104
- | | | 2.5 | Full | Latest |
105
- | | | 2.4 | Full | Latest |
106
- | | | 2.3 | Full | Latest |
107
- | | | 2.2 | Full | Latest |
108
- | | | 2.1 | Full | Latest |
109
- | | | 2.0 | EOL since June 7th, 2021 | < 0.50.0 |
110
- | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
111
- | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
112
- | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
113
-
114
- **Supported web servers**:
115
-
116
- | Type | Documentation | Version | Support type |
117
- | --------- | --------------------------------- | ------------ | ------------ |
118
- | Puma | http://puma.io/ | 2.16+ / 3.6+ | Full |
119
- | Unicorn | https://bogomips.org/unicorn/ | 4.8+ / 5.1+ | Full |
120
- | Passenger | https://www.phusionpassenger.com/ | 5.0+ | Full |
121
-
122
- **Supported tracing frameworks**:
123
-
124
- | Type | Documentation | Version | Gem version support |
125
- | ----------- | ----------------------------------------------- | --------------------- | ------------------- |
126
- | OpenTracing | https://github.com/opentracing/opentracing-ruby | 0.4.1+ (w/ Ruby 2.1+) | >= 0.16.0 |
127
-
128
- *Full* support indicates all tracer features are available.
129
-
130
- *Deprecated* indicates support will transition to *Maintenance* in a future release.
131
-
132
- *Maintenance* indicates only critical bugfixes are backported until EOL.
133
-
134
- *EOL* indicates support is no longer provided.
135
-
136
- ## Installation
137
-
138
- The following steps will help you quickly start tracing your Ruby application.
139
-
140
- ### Configure the Datadog Agent for APM
141
-
142
- Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
143
-
144
- Install and configure the Datadog Agent to receive traces from your now instrumented application. By default the Datadog Agent is enabled in your `datadog.yaml` file under `apm_enabled: true` and listens for trace traffic at `localhost:8126`. For containerized environments, follow the steps below to enable trace collection within the Datadog Agent.
145
-
146
- #### Containers
147
-
148
- 1. Set `apm_non_local_traffic: true` in your main [`datadog.yaml` configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/#agent-main-configuration-file).
149
-
150
- 2. See the specific setup instructions for [Docker](https://docs.datadoghq.com/agent/docker/apm/?tab=ruby), [Kubernetes](https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm), [Amazon ECS](https://docs.datadoghq.com/agent/amazon_ecs/apm/?tab=ruby) or [Fargate](https://docs.datadoghq.com/integrations/ecs_fargate/#trace-collection) to ensure that the Agent is configured to receive traces in a containerized environment:
151
-
152
- 3. After having instrumented your application, the tracing client sends traces to `localhost:8126` by default. If this is not the correct host and port change it by setting the env variables `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
153
-
154
-
155
- ### Quickstart for Rails applications
156
-
157
- #### Automatic instrumentation
158
-
159
- 1. Add the `ddtrace` gem to your Gemfile:
160
-
161
- ```ruby
162
- source 'https://rubygems.org'
163
- gem 'ddtrace', require: 'ddtrace/auto_instrument'
164
- ```
165
-
166
- 2. Install the gem with `bundle install`
167
-
168
- 3. You can configure, override, or disable any specific integration settings by also adding a [Rails Manual Configuration](#rails-manual-configuration) file.
169
-
170
- #### Manual instrumentation
171
-
172
- 1. Add the `ddtrace` gem to your Gemfile:
173
-
174
- ```ruby
175
- source 'https://rubygems.org'
176
- gem 'ddtrace'
177
- ```
178
-
179
- 2. Install the gem with `bundle install`
180
- 3. Create a `config/initializers/datadog.rb` file containing:
181
-
182
- ```ruby
183
- Datadog.configure do |c|
184
- # This will activate auto-instrumentation for Rails
185
- c.use :rails
186
- end
187
- ```
188
-
189
- You can also activate additional integrations here (see [Integration instrumentation](#integration-instrumentation))
190
-
191
- ### Quickstart for Ruby applications
192
-
193
- #### Automatic instrumentation
194
-
195
- 1. Install the gem with `gem install ddtrace`
196
- 2. Requiring any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
197
- 3. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
198
-
199
- ```ruby
200
- # Example frameworks and libraries
201
- require 'sinatra'
202
- require 'faraday'
203
- require 'redis'
204
-
205
- require 'ddtrace/auto_instrument'
206
- ```
207
-
208
- You can configure, override, or disable any specific integration settings by also adding a [Ruby Manual Configuration Block](#ruby-manual-configuration).
209
-
210
- #### Manual instrumentation
211
-
212
- 1. Install the gem with `gem install ddtrace`
213
- 2. Add a configuration block to your Ruby application:
214
-
215
- ```ruby
216
- require 'ddtrace'
217
- Datadog.configure do |c|
218
- # Configure the tracer here.
219
- # Activate integrations, change tracer settings, etc...
220
- # By default without additional configuration, nothing will be traced.
221
- end
222
- ```
223
-
224
- 3. Add or activate instrumentation by doing either of the following:
225
- - Activate integration instrumentation (see [Integration instrumentation](#integration-instrumentation))
226
- - Add manual instrumentation around your code (see [Manual instrumentation](#manual-instrumentation))
227
-
228
- ### Quickstart for OpenTracing
229
-
230
- 1. Install the gem with `gem install ddtrace`
231
- 2. To your OpenTracing configuration file, add the following:
232
-
233
- ```ruby
234
- require 'opentracing'
235
- require 'ddtrace'
236
- require 'ddtrace/opentracer'
237
-
238
- # Activate the Datadog tracer for OpenTracing
239
- OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new
240
- ```
241
-
242
- 3. (Optional) Add a configuration block to your Ruby application to configure Datadog with:
243
-
244
- ```ruby
245
- Datadog.configure do |c|
246
- # Configure the Datadog tracer here.
247
- # Activate integrations, change tracer settings, etc...
248
- # By default without additional configuration,
249
- # no additional integrations will be traced, only
250
- # what you have instrumented with OpenTracing.
251
- end
252
- ```
253
-
254
- 4. (Optional) Add or activate additional instrumentation by doing either of the following:
255
- - Activate Datadog integration instrumentation (see [Integration instrumentation](#integration-instrumentation))
256
- - Add Datadog manual instrumentation around your code (see [Manual instrumentation](#manual-instrumentation))
257
-
258
- ### Final steps for installation
259
-
260
- After setting up, your services will appear on the [APM services page](https://app.datadoghq.com/apm/services) within a few minutes. Learn more about [using the APM UI][visualization docs].
261
-
262
- ## Manual Instrumentation
263
-
264
- If you aren't using a supported framework instrumentation, you may want to manually instrument your code.
265
-
266
- To trace any Ruby code, you can use the `Datadog.tracer.trace` method:
267
-
268
- ```ruby
269
- Datadog.tracer.trace(name, options) do |span|
270
- # Wrap this block around the code you want to instrument
271
- # Additionally, you can modify the span here.
272
- # e.g. Change the resource name, set tags, etc...
273
- end
274
- ```
275
-
276
- Where `name` should be a `String` that describes the generic kind of operation being done (e.g. `'web.request'`, or `'request.parse'`)
277
-
278
- And `options` is an optional `Hash` that accepts the following parameters:
279
-
280
- | Key | Type | Description | Default |
281
- | --- | --- | --- | --- |
282
- | `service` | `String` | The service name which this span belongs (e.g. `'my-web-service'`) | Tracer `default-service`, `$PROGRAM_NAME` or `'ruby'` |
283
- | `resource` | `String` | Name of the resource or action being operated on. Traces with the same resource value will be grouped together for the purpose of metrics (but still independently viewable.) Usually domain specific, such as a URL, query, request, etc. (e.g. `'Article#submit'`, `http://example.com/articles/list`.) | `name` of Span. |
284
- | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
285
- | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
286
- | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
287
- | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
288
- | `on_error` | `Proc` | Handler invoked when a block is provided to trace, and it raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
289
-
290
- It's highly recommended you set both `service` and `resource` at a minimum. Spans without a `service` or `resource` as `nil` will be discarded by the Datadog agent.
291
-
292
- Example of manual instrumentation in action:
293
-
294
- ```ruby
295
- get '/posts' do
296
- Datadog.tracer.trace('web.request', service: 'my-blog', resource: 'GET /posts') do |span|
297
- # Trace the activerecord call
298
- Datadog.tracer.trace('posts.fetch') do
299
- @posts = Posts.order(created_at: :desc).limit(10)
300
- end
301
-
302
- # Add some APM tags
303
- span.set_tag('http.method', request.request_method)
304
- span.set_tag('posts.count', @posts.length)
305
-
306
- # Trace the template rendering
307
- Datadog.tracer.trace('template.render') do
308
- erb :index
309
- end
310
- end
311
- end
312
- ```
313
-
314
- ### Asynchronous tracing
315
-
316
- It might not always be possible to wrap `Datadog.tracer.trace` around a block of code. Some event or notification based instrumentation might only notify you when an event begins or ends.
317
-
318
- To trace these operations, you can trace code asynchronously by calling `Datadog.tracer.trace` without a block:
319
-
320
- ```ruby
321
- # Some instrumentation framework calls this after an event finishes...
322
- def db_query(start, finish, query)
323
- span = Datadog.tracer.trace('database.query')
324
- span.resource = query
325
- span.start_time = start
326
- span.finish(finish)
327
- end
328
- ```
329
-
330
- Calling `Datadog.tracer.trace` without a block will cause the function to return a `Datadog::Span` that is started, but not finished. You can then modify this span however you wish, then close it `finish`.
331
-
332
- *You must not leave any unfinished spans.* If any spans are left open when the trace completes, the trace will be discarded. You can [activate debug mode](#tracer-settings) to check for warnings if you suspect this might be happening.
333
-
334
- To avoid this scenario when handling start/finish events, you can use `Datadog.tracer.active_span` to get the current active span.
335
-
336
- ```ruby
337
- # e.g. ActiveSupport::Notifications calls this when an event starts
338
- def start(name, id, payload)
339
- # Start a span
340
- Datadog.tracer.trace(name)
341
- end
342
-
343
- # e.g. ActiveSupport::Notifications calls this when an event finishes
344
- def finish(name, id, payload)
345
- # Retrieve current active span (thread-safe)
346
- current_span = Datadog.tracer.active_span
347
- unless current_span.nil?
348
- current_span.resource = payload[:query]
349
- current_span.finish
350
- end
351
- end
352
- ```
353
- ### Enriching traces from nested methods
354
-
355
- You can tag additional information to the current active span from any method. Note however that if the method is called and there is no span currently active `active_span` will be nil.
356
-
357
- ```ruby
358
- # e.g. adding tag to active span
359
-
360
- current_span = Datadog.tracer.active_span
361
- current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
362
- ```
363
-
364
- You can also get the root span of the current active trace using the `active_root_span` method. This method will return `nil` if there is no active trace.
365
-
366
- ```ruby
367
- # e.g. adding tag to active root span
368
-
369
- current_root_span = Datadog.tracer.active_root_span
370
- current_root_span.set_tag('my_tag', 'my_value') unless current_root_span.nil?
371
- ```
372
-
373
- ## Integration instrumentation
374
-
375
- Many popular libraries and frameworks are supported out-of-the-box, which can be auto-instrumented. Although they are not activated automatically, they can be easily activated and configured by using the `Datadog.configure` API:
376
-
377
- ```ruby
378
- Datadog.configure do |c|
379
- # Activates and configures an integration
380
- c.use :integration_name, options
381
- end
382
- ```
383
-
384
- `options` is a `Hash` of integration-specific configuration settings.
385
-
386
- For a list of available integrations, and their configuration options, please refer to the following:
387
-
388
- | Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
389
- | ------------------------ | -------------------------- | ------------------------ | --------------------------| ----------------------------------- | ------------------------------------------------------------------------------ |
390
- | Action Cable | `action_cable` | `>= 5.0` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
391
- | Action View | `action_view` | `>= 3.0` | `>= 3.0` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
392
- | Active Model Serializers | `active_model_serializers` | `>= 0.9` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
393
- | Action Pack | `action_pack` | `>= 3.0` | `>= 3.0` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
394
- | Active Record | `active_record` | `>= 3.0` | `>= 3.0` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
395
- | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
396
- | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
397
- | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
398
- | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
399
- | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
400
- | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
401
- | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
402
- | Ethon | `ethon` | `>= 0.11` | `>= 0.11` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
403
- | Excon | `excon` | `>= 0.50` | `>= 0.50` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
404
- | Faraday | `faraday` | `>= 0.14` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
405
- | Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
406
- | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
407
- | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
408
- | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
409
- | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
410
- | httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
411
- | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
412
- | Makara (through Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
413
- | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
414
- | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
415
- | Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
416
- | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
417
- | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
418
- | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
419
- | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
420
- | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
421
- | Rails | `rails` | `>= 3.0` | `>= 3.0` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
422
- | Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
423
- | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
424
- | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
425
- | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
426
- | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
427
- | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
428
- | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
429
- | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
430
- | Sinatra | `sinatra` | `>= 1.4` | `>= 1.4` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
431
- | Sneakers | `sneakers` | `>= 2.12.0` | `>= 2.12.0` | *[Link](#sneakers)* | *[Link](https://github.com/jondot/sneakers)* |
432
- | Sucker Punch | `sucker_punch` | `>= 2.0` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
433
-
434
- ### Action Cable
435
-
436
- The Action Cable integration traces broadcast messages and channel actions.
437
-
438
- You can enable it through `Datadog.configure`:
439
-
440
- ```ruby
441
- require 'ddtrace'
442
-
443
- Datadog.configure do |c|
444
- c.use :action_cable, options
445
- end
446
- ```
447
-
448
- Where `options` is an optional `Hash` that accepts the following parameters:
449
-
450
- | Key | Description | Default |
451
- | --- | ----------- | ------- |
452
- | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
453
-
454
- ### Action View
455
-
456
- Most of the time, Active Support is set up as part of Rails, but it can be activated separately:
457
-
458
- ```ruby
459
- require 'actionview'
460
- require 'ddtrace'
461
-
462
- Datadog.configure do |c|
463
- c.use :action_view, options
464
- end
465
- ```
466
-
467
- Where `options` is an optional `Hash` that accepts the following parameters:
468
-
469
- | Key | Description | Default |
470
- | ---| --- | --- |
471
- | `service_name` | Service name used for rendering instrumentation. | `action_view` |
472
- | `template_base_path` | Used when the template name is parsed. If you don't store your templates in the `views/` folder, you may need to change this value | `'views/'` |
473
-
474
- ### Active Model Serializers
475
-
476
- The Active Model Serializers integration traces the `serialize` event for version 0.9+ and the `render` event for version 0.10+.
477
-
478
- ```ruby
479
- require 'active_model_serializers'
480
- require 'ddtrace'
481
-
482
- Datadog.configure do |c|
483
- c.use :active_model_serializers, options
484
- end
485
-
486
- my_object = MyModel.new(name: 'my object')
487
- ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
488
- ```
489
-
490
- | Key | Description | Default |
491
- | --- | ----------- | ------- |
492
- | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
493
-
494
- ### Action Pack
495
-
496
- Most of the time, Action Pack is set up as part of Rails, but it can be activated separately:
497
-
498
- ```ruby
499
- require 'actionpack'
500
- require 'ddtrace'
501
-
502
- Datadog.configure do |c|
503
- c.use :action_pack, options
504
- end
505
- ```
506
-
507
- Where `options` is an optional `Hash` that accepts the following parameters:
508
-
509
- | Key | Description | Default |
510
- | ---| --- | --- |
511
- | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
512
-
513
- ### Active Record
514
-
515
- Most of the time, Active Record is set up as part of a web framework (Rails, Sinatra...) however, it can be set up alone:
516
-
517
- ```ruby
518
- require 'tmpdir'
519
- require 'sqlite3'
520
- require 'active_record'
521
- require 'ddtrace'
522
-
523
- Datadog.configure do |c|
524
- c.use :active_record, options
525
- end
526
-
527
- Dir::Tmpname.create(['test', '.sqlite']) do |db|
528
- conn = ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
529
- database: db)
530
- conn.connection.execute('SELECT 42') # traced!
531
- end
532
- ```
533
-
534
- Where `options` is an optional `Hash` that accepts the following parameters:
535
-
536
- | Key | Description | Default |
537
- | ---| --- | --- |
538
- | `orm_service_name` | Service name used for the mapping portion of query results to ActiveRecord objects. Inherits service name from parent by default. | _parent.service_name_ (e.g. `'mysql2'`) |
539
- | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
540
-
541
- **Configuring trace settings per database**
542
-
543
- You can configure trace settings per database connection by using the `describes` option:
544
-
545
- ```ruby
546
- # Provide a `:describes` option with a connection key.
547
- # Any of the following keys are acceptable and equivalent to one another.
548
- # If a block is provided, it yields a Settings object that
549
- # accepts any of the configuration options listed above.
550
-
551
- Datadog.configure do |c|
552
- # Symbol matching your database connection in config/database.yml
553
- # Only available if you are using Rails with ActiveRecord.
554
- c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
555
-
556
- # Block configuration pattern.
557
- c.use :active_record, describes: :secondary_database do |second_db|
558
- second_db.service_name = 'secondary-db'
559
- end
560
-
561
- # Connection string with the following connection settings:
562
- # adapter, username, host, port, database
563
- # Other fields are ignored.
564
- c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
565
-
566
- # Hash with following connection settings:
567
- # adapter, username, host, port, database
568
- # Other fields are ignored.
569
- c.use :active_record, describes: {
570
- adapter: 'mysql2',
571
- host: '127.0.0.1',
572
- port: '3306',
573
- database: 'mysql',
574
- username: 'root'
575
- },
576
- service_name: 'secondary-db'
577
-
578
- # If using the `makara` gem, it's possible to match on connection `role`:
579
- c.use :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
580
- c.use :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
581
- end
582
- ```
583
-
584
- You can also create configurations based on partial matching of database connection fields:
585
-
586
- ```ruby
587
- Datadog.configure do |c|
588
- # Matches any connection on host `127.0.0.1`.
589
- c.use :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
590
-
591
- # Matches any `mysql2` connection.
592
- c.use :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
593
-
594
- # Matches any `mysql2` connection to the `reports` database.
595
- #
596
- # In case of multiple matching `describe` configurations, the latest one applies.
597
- # In this case a connection with both adapter `mysql` and database `reports`
598
- # will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
599
- c.use :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
600
- end
601
- ```
602
-
603
- When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
604
-
605
- If ActiveRecord traces an event that uses a connection that matches a key defined by `describes`, it will use the trace settings assigned to that connection. If the connection does not match any of the described connections, it will use default settings defined by `c.use :active_record` instead.
606
-
607
- ### Active Support
608
-
609
- Most of the time, Active Support is set up as part of Rails, but it can be activated separately:
610
-
611
- ```ruby
612
- require 'activesupport'
613
- require 'ddtrace'
614
-
615
- Datadog.configure do |c|
616
- c.use :active_support, options
617
- end
618
-
619
- cache = ActiveSupport::Cache::MemoryStore.new
620
- cache.read('city')
621
- ```
622
-
623
- Where `options` is an optional `Hash` that accepts the following parameters:
624
-
625
- | Key | Description | Default |
626
- | ---| --- | --- |
627
- | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
628
-
629
- ### AWS
630
-
631
- The AWS integration will trace every interaction (e.g. API calls) with AWS services (S3, ElastiCache etc.).
632
-
633
- ```ruby
634
- require 'aws-sdk'
635
- require 'ddtrace'
636
-
637
- Datadog.configure do |c|
638
- c.use :aws, options
639
- end
640
-
641
- # Perform traced call
642
- Aws::S3::Client.new.list_buckets
643
- ```
644
-
645
- Where `options` is an optional `Hash` that accepts the following parameters:
646
-
647
- | Key | Description | Default |
648
- | --- | ----------- | ------- |
649
- | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
650
-
651
- ### Concurrent Ruby
652
-
653
- The Concurrent Ruby integration adds support for context propagation when using `::Concurrent::Future`.
654
- Making sure that code traced within the `Future#execute` will have correct parent set.
655
-
656
- To activate your integration, use the `Datadog.configure` method:
657
-
658
- ```ruby
659
- # Inside Rails initializer or equivalent
660
- Datadog.configure do |c|
661
- # Patches ::Concurrent::Future to use ExecutorService that propagates context
662
- c.use :concurrent_ruby, options
663
- end
664
-
665
- # Pass context into code executed within Concurrent::Future
666
- Datadog.tracer.trace('outer') do
667
- Concurrent::Future.execute { Datadog.tracer.trace('inner') { } }.wait
668
- end
669
- ```
670
-
671
- Where `options` is an optional `Hash` that accepts the following parameters:
672
-
673
- | Key | Description | Default |
674
- | --- | ----------- | ------- |
675
- | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
676
-
677
- ### Cucumber
678
-
679
- Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
680
-
681
- To activate your integration, use the `Datadog.configure` method:
682
-
683
- ```ruby
684
- require 'cucumber'
685
- require 'ddtrace'
686
-
687
- # Configure default Cucumber integration
688
- Datadog.configure do |c|
689
- c.use :cucumber, options
690
- end
691
-
692
- # Example of how to attach tags from scenario to active span
693
- Around do |scenario, block|
694
- active_span = Datadog.configuration[:cucumber][:tracer].active_span
695
- unless active_span.nil?
696
- scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
697
- active_span.set_tag(*tag.name.split(':', 2))
698
- end
699
- end
700
- block.call
701
- end
702
- ```
703
-
704
- Where `options` is an optional `Hash` that accepts the following parameters:
705
-
706
- | Key | Description | Default |
707
- | --- | ----------- | ------- |
708
- | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
709
- | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
710
- | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
711
-
712
- ### Dalli
713
-
714
- Dalli integration will trace all calls to your `memcached` server:
715
-
716
- ```ruby
717
- require 'dalli'
718
- require 'ddtrace'
719
-
720
- # Configure default Dalli tracing behavior
721
- Datadog.configure do |c|
722
- c.use :dalli, options
723
- end
724
-
725
- # Configure Dalli tracing behavior for single client
726
- client = Dalli::Client.new('localhost:11211', options)
727
- client.set('abc', 123)
728
- ```
729
-
730
- Where `options` is an optional `Hash` that accepts the following parameters:
731
-
732
- | Key | Description | Default |
733
- | --- | ----------- | ------- |
734
- | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
735
-
736
- ### DelayedJob
737
-
738
- The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
739
-
740
- You can enable it through `Datadog.configure`:
741
-
742
- ```ruby
743
- require 'ddtrace'
744
-
745
- Datadog.configure do |c|
746
- c.use :delayed_job, options
747
- end
748
- ```
749
-
750
- Where `options` is an optional `Hash` that accepts the following parameters:
751
-
752
- | Key | Description | Default |
753
- | --- | ----------- | ------- |
754
- | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
755
- | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
756
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
757
-
758
- ### Elasticsearch
759
-
760
- The Elasticsearch integration will trace any call to `perform_request` in the `Client` object:
761
-
762
- ```ruby
763
- require 'elasticsearch/transport'
764
- require 'ddtrace'
765
-
766
- Datadog.configure do |c|
767
- c.use :elasticsearch, options
768
- end
769
-
770
- # Perform a query to Elasticsearch
771
- client = Elasticsearch::Client.new url: 'http://127.0.0.1:9200'
772
- response = client.perform_request 'GET', '_cluster/health'
773
- ```
774
-
775
- Where `options` is an optional `Hash` that accepts the following parameters:
776
-
777
- | Key | Description | Default |
778
- | --- | ----------- | ------- |
779
- | `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{}` |
780
- | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
781
-
782
- ### Ethon
783
-
784
- The `ethon` integration will trace any HTTP request through `Easy` or `Multi` objects. Note that this integration also supports `Typhoeus` library which is based on `Ethon`.
785
-
786
- ```ruby
787
- require 'ddtrace'
788
-
789
- Datadog.configure do |c|
790
- c.use :ethon, options
791
-
792
- # optionally, specify a different service name for hostnames matching a regex
793
- c.use :ethon, describes: /user-[^.]+\.example\.com/ do |ethon|
794
- ethon.service_name = 'user.example.com'
795
- ethon.split_by_domain = false # Only necessary if split_by_domain is true by default
796
- end
797
- end
798
- ```
799
-
800
- Where `options` is an optional `Hash` that accepts the following parameters:
801
-
802
- | Key | Description | Default |
803
- | --- | ----------- | ------- |
804
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
805
- | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
806
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
807
-
808
- ### Excon
809
-
810
- The `excon` integration is available through the `ddtrace` middleware:
811
-
812
- ```ruby
813
- require 'excon'
814
- require 'ddtrace'
815
-
816
- # Configure default Excon tracing behavior
817
- Datadog.configure do |c|
818
- c.use :excon, options
819
-
820
- # optionally, specify a different service name for hostnames matching a regex
821
- c.use :excon, describes: /user-[^.]+\.example\.com/ do |excon|
822
- excon.service_name = 'user.example.com'
823
- excon.split_by_domain = false # Only necessary if split_by_domain is true by default
824
- end
825
- end
826
-
827
- connection = Excon.new('https://example.com')
828
- connection.get
829
- ```
830
-
831
- Where `options` is an optional `Hash` that accepts the following parameters:
832
-
833
- | Key | Description | Default |
834
- | --- | ----------- | ------- |
835
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
836
- | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
837
- | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
838
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
839
-
840
- **Configuring connections to use different settings**
841
-
842
- If you use multiple connections with Excon, you can give each of them different settings by configuring their constructors with middleware:
843
-
844
- ```ruby
845
- # Wrap the Datadog tracing middleware around the default middleware stack
846
- Excon.new(
847
- 'http://example.com',
848
- middlewares: Datadog::Contrib::Excon::Middleware.with(options).around_default_stack
849
- )
850
-
851
- # Insert the middleware into a custom middleware stack.
852
- # NOTE: Trace middleware must be inserted after ResponseParser!
853
- Excon.new(
854
- 'http://example.com',
855
- middlewares: [
856
- Excon::Middleware::ResponseParser,
857
- Datadog::Contrib::Excon::Middleware.with(options),
858
- Excon::Middleware::Idempotent
859
- ]
860
- )
861
- ```
862
-
863
- Where `options` is a Hash that contains any of the parameters listed in the table above.
864
-
865
- ### Faraday
866
-
867
- The `faraday` integration is available through the `ddtrace` middleware:
868
-
869
- ```ruby
870
- require 'faraday'
871
- require 'ddtrace'
872
-
873
- # Configure default Faraday tracing behavior
874
- Datadog.configure do |c|
875
- c.use :faraday, options
876
-
877
- # optionally, specify a different service name for hostnames matching a regex
878
- c.use :faraday, describes: /user-[^.]+\.example\.com/ do |faraday|
879
- faraday.service_name = 'user.example.com'
880
- faraday.split_by_domain = false # Only necessary if split_by_domain is true by default
881
- end
882
- end
883
-
884
- # In case you want to override the global configuration for a certain client instance
885
- connection = Faraday.new('https://example.com') do |builder|
886
- builder.use(:ddtrace, options)
887
- builder.adapter Faraday.default_adapter
888
- end
889
-
890
- connection.get('/foo')
891
- ```
892
-
893
- Where `options` is an optional `Hash` that accepts the following parameters:
894
-
895
- | Key | Description | Default |
896
- | --- | ----------- | ------- |
897
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
898
- | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
899
- | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
900
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
901
-
902
- ### Grape
903
-
904
- The Grape integration adds the instrumentation to Grape endpoints and filters. This integration can work side by side with other integrations like Rack and Rails.
905
-
906
- To activate your integration, use the `Datadog.configure` method before defining your Grape application:
907
-
908
- ```ruby
909
- # api.rb
910
- require 'grape'
911
- require 'ddtrace'
912
-
913
- Datadog.configure do |c|
914
- c.use :grape, options
915
- end
916
-
917
- # Then define your application
918
- class RackTestingAPI < Grape::API
919
- desc 'main endpoint'
920
- get :success do
921
- 'Hello world!'
922
- end
923
- end
924
- ```
925
-
926
- Where `options` is an optional `Hash` that accepts the following parameters:
927
-
928
- | Key | Description | Default |
929
- | --- | ----------- | ------- |
930
- | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
931
- | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
932
- | `error_statuses`| Defines a status code or range of status codes which should be marked as errors. `'404,405,500-599'` or `[404,405,'500-599']` | `nil` |
933
-
934
- ### GraphQL
935
-
936
- The GraphQL integration activates instrumentation for GraphQL queries.
937
-
938
- To activate your integration, use the `Datadog.configure` method:
939
-
940
- ```ruby
941
- # Inside Rails initializer or equivalent
942
- Datadog.configure do |c|
943
- c.use :graphql, schemas: [YourSchema], options
944
- end
945
-
946
- # Then run a GraphQL query
947
- YourSchema.execute(query, variables: {}, context: {}, operation_name: nil)
948
- ```
949
-
950
- The `use :graphql` method accepts the following parameters. Additional options can be substituted in for `options`:
951
-
952
- | Key | Description | Default |
953
- | --- | ----------- | ------- |
954
- | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
955
- | `schemas` | Required. Array of `GraphQL::Schema` objects which to trace. Tracing will be added to all the schemas listed, using the options provided to this configuration. If you do not provide any, then tracing will not be activated. | `[]` |
956
-
957
- **Manually configuring GraphQL schemas**
958
-
959
- 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):
960
-
961
- ```ruby
962
- # Class-based schema
963
- class YourSchema < GraphQL::Schema
964
- use(
965
- GraphQL::Tracing::DataDogTracing,
966
- service: 'graphql'
967
- )
968
- end
969
- ```
970
-
971
- ```ruby
972
- # .define-style schema
973
- YourSchema = GraphQL::Schema.define do
974
- use(
975
- GraphQL::Tracing::DataDogTracing,
976
- service: 'graphql'
977
- )
978
- end
979
- ```
980
-
981
- Or you can modify an already defined schema:
982
-
983
- ```ruby
984
- # Class-based schema
985
- YourSchema.use(
986
- GraphQL::Tracing::DataDogTracing,
987
- service: 'graphql'
988
- )
989
- ```
990
-
991
- ```ruby
992
- # .define-style schema
993
- YourSchema.define do
994
- use(
995
- GraphQL::Tracing::DataDogTracing,
996
- service: 'graphql'
997
- )
998
- end
999
- ```
1000
-
1001
- Do *NOT* `use :graphql` in `Datadog.configure` if you choose to configure manually, as to avoid double tracing. These two means of configuring GraphQL tracing are considered mutually exclusive.
1002
-
1003
- ### gRPC
1004
-
1005
- The `grpc` integration adds both client and server interceptors, which run as middleware before executing the service's remote procedure call. As gRPC applications are often distributed, the integration shares trace information between client and server.
1006
-
1007
- To setup your integration, use the `Datadog.configure` method like so:
1008
-
1009
- ```ruby
1010
- require 'grpc'
1011
- require 'ddtrace'
1012
-
1013
- Datadog.configure do |c|
1014
- c.use :grpc, options
1015
- end
1016
-
1017
- # Server side
1018
- server = GRPC::RpcServer.new
1019
- server.add_http2_port('localhost:50051', :this_port_is_insecure)
1020
- server.handle(Demo)
1021
- server.run_till_terminated
1022
-
1023
- # Client side
1024
- client = Demo.rpc_stub_class.new('localhost:50051', :this_channel_is_insecure)
1025
- client.my_endpoint(DemoMessage.new(contents: 'hello!'))
1026
- ```
1027
-
1028
- Where `options` is an optional `Hash` that accepts the following parameters:
1029
-
1030
- | Key | Description | Default |
1031
- | --- | ----------- | ------- |
1032
- | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
1033
- | `error_handler` | Custom error handler invoked when a request is an error. A `Proc` that accepts `span` and `error` parameters. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1034
-
1035
- **Configuring clients to use different settings**
1036
-
1037
- In situations where you have multiple clients calling multiple distinct services, you may pass the Datadog interceptor directly, like so
1038
-
1039
- ```ruby
1040
- configured_interceptor = Datadog::Contrib::GRPC::DatadogInterceptor::Client.new do |c|
1041
- c.service_name = "Alternate"
1042
- end
1043
-
1044
- alternate_client = Demo::Echo::Service.rpc_stub_class.new(
1045
- 'localhost:50052',
1046
- :this_channel_is_insecure,
1047
- :interceptors => [configured_interceptor]
1048
- )
1049
- ```
1050
-
1051
- The integration will ensure that the `configured_interceptor` establishes a unique tracing setup for that client instance.
1052
-
1053
- ### http.rb
1054
-
1055
- The http.rb integration will trace any HTTP call using the Http.rb gem.
1056
-
1057
- ```ruby
1058
- require 'http'
1059
- require 'ddtrace'
1060
- Datadog.configure do |c|
1061
- c.use :httprb, options
1062
- # optionally, specify a different service name for hostnames matching a regex
1063
- c.use :httprb, describes: /user-[^.]+\.example\.com/ do |httprb|
1064
- httprb.service_name = 'user.example.com'
1065
- httprb.split_by_domain = false # Only necessary if split_by_domain is true by default
1066
- end
1067
- end
1068
- ```
1069
-
1070
- Where `options` is an optional `Hash` that accepts the following parameters:
1071
-
1072
- | Key | Description | Default |
1073
- | --- | ----------- | ------- |
1074
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1075
- | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
1076
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1077
-
1078
- ### httpclient
1079
-
1080
- The httpclient integration will trace any HTTP call using the httpclient gem.
1081
-
1082
- ```ruby
1083
- require 'httpclient'
1084
- require 'ddtrace'
1085
- Datadog.configure do |c|
1086
- c.use :httpclient, options
1087
- # optionally, specify a different service name for hostnames matching a regex
1088
- c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1089
- httpclient.service_name = 'user.example.com'
1090
- httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1091
- end
1092
- end
1093
- ```
1094
-
1095
- Where `options` is an optional `Hash` that accepts the following parameters:
1096
-
1097
- | Key | Description | Default |
1098
- | --- | ----------- | ------- |
1099
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1100
- | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1101
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1102
-
1103
- ### httpx
1104
-
1105
- `httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
1106
-
1107
- ```ruby
1108
- require "ddtrace"
1109
- require "httpx/adapters/datadog"
1110
-
1111
- Datadog.configure do |c|
1112
- c.use :httpx
1113
-
1114
- # optionally, specify a different service name for hostnames matching a regex
1115
- c.use :httpx, describes: /user-[^.]+\.example\.com/ do |http|
1116
- http.service_name = 'user.example.com'
1117
- http.split_by_domain = false # Only necessary if split_by_domain is true by default
1118
- end
1119
- end
1120
- ```
1121
-
1122
- ### Kafka
1123
-
1124
- The Kafka integration provides tracing of the `ruby-kafka` gem:
1125
-
1126
- You can enable it through `Datadog.configure`:
1127
-
1128
- ```ruby
1129
- require 'active_support/notifications' # required to enable 'ruby-kafka' instrumentation
1130
- require 'kafka'
1131
- require 'ddtrace'
1132
-
1133
- Datadog.configure do |c|
1134
- c.use :kafka, options
1135
- end
1136
- ```
1137
-
1138
- Where `options` is an optional `Hash` that accepts the following parameters:
1139
-
1140
- | Key | Description | Default |
1141
- | --- | ----------- | ------- |
1142
- | `service_name` | Service name used for `kafka` instrumentation | `'kafka'` |
1143
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1144
-
1145
- ### MongoDB
1146
-
1147
- 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:
1148
-
1149
- ```ruby
1150
- require 'mongo'
1151
- require 'ddtrace'
1152
-
1153
- Datadog.configure do |c|
1154
- c.use :mongo, options
1155
- end
1156
-
1157
- # Create a MongoDB client and use it as usual
1158
- client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
1159
- collection = client[:people]
1160
- collection.insert_one({ name: 'Steve' })
1161
-
1162
- # In case you want to override the global configuration for a certain client instance
1163
- Datadog.configure(client, options)
1164
- ```
1165
-
1166
- Where `options` is an optional `Hash` that accepts the following parameters:
1167
-
1168
- | Key | Description | Default |
1169
- | --- | ----------- | ------- |
1170
- | `quantize` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{ show: [:collection, :database, :operation] }` |
1171
- | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
1172
-
1173
- ### MySQL2
1174
-
1175
- The MySQL2 integration traces any SQL command sent through `mysql2` gem.
1176
-
1177
- ```ruby
1178
- require 'mysql2'
1179
- require 'ddtrace'
1180
-
1181
- Datadog.configure do |c|
1182
- c.use :mysql2, options
1183
- end
1184
-
1185
- client = Mysql2::Client.new(:host => "localhost", :username => "root")
1186
- client.query("SELECT * FROM users WHERE group='x'")
1187
- ```
1188
-
1189
- Where `options` is an optional `Hash` that accepts the following parameters:
1190
-
1191
- | Key | Description | Default |
1192
- | --- | ----------- | ------- |
1193
- | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1194
-
1195
- ### Net/HTTP
1196
-
1197
- The Net/HTTP integration will trace any HTTP call using the standard lib Net::HTTP module.
1198
-
1199
- ```ruby
1200
- require 'net/http'
1201
- require 'ddtrace'
1202
-
1203
- Datadog.configure do |c|
1204
- c.use :http, options
1205
-
1206
- # optionally, specify a different service name for hostnames matching a regex
1207
- c.use :http, describes: /user-[^.]+\.example\.com/ do |http|
1208
- http.service_name = 'user.example.com'
1209
- http.split_by_domain = false # Only necessary if split_by_domain is true by default
1210
- end
1211
- end
1212
-
1213
- Net::HTTP.start('127.0.0.1', 8080) do |http|
1214
- request = Net::HTTP::Get.new '/index'
1215
- response = http.request(request)
1216
- end
1217
-
1218
- content = Net::HTTP.get(URI('http://127.0.0.1/index.html'))
1219
- ```
1220
-
1221
- Where `options` is an optional `Hash` that accepts the following parameters:
1222
-
1223
- | Key | Description | Default |
1224
- | --- | ----------- | ------- |
1225
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1226
- | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1227
- | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1228
-
1229
- If you wish to configure each connection object individually, you may use the `Datadog.configure` as it follows:
1230
-
1231
- ```ruby
1232
- client = Net::HTTP.new(host, port)
1233
- Datadog.configure(client, options)
1234
- ```
1235
-
1236
- ### Presto
1237
-
1238
- The Presto integration traces any SQL command sent through `presto-client` gem.
1239
-
1240
- ```ruby
1241
- require 'presto-client'
1242
- require 'ddtrace'
1243
-
1244
- Datadog.configure do |c|
1245
- c.use :presto, options
1246
- end
1247
-
1248
- client = Presto::Client.new(
1249
- server: "localhost:8880",
1250
- ssl: {verify: false},
1251
- catalog: "native",
1252
- schema: "default",
1253
- time_zone: "US/Pacific",
1254
- language: "English",
1255
- http_debug: true,
1256
- )
1257
-
1258
- client.run("select * from system.nodes")
1259
- ```
1260
-
1261
- Where `options` is an optional `Hash` that accepts the following parameters:
1262
-
1263
- | Key | Description | Default |
1264
- | --- | ----------- | ------- |
1265
- | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1266
-
1267
- ### Qless
1268
-
1269
- The Qless integration uses lifecycle hooks to trace job executions.
1270
-
1271
- To add tracing to a Qless job:
1272
-
1273
- ```ruby
1274
- require 'ddtrace'
1275
-
1276
- Datadog.configure do |c|
1277
- c.use :qless, options
1278
- end
1279
- ```
1280
-
1281
- Where `options` is an optional `Hash` that accepts the following parameters:
1282
-
1283
- | Key | Description | Default |
1284
- | --- | ----------- | ------- |
1285
- | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1286
- | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1287
- | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1288
-
1289
- ### Que
1290
-
1291
- The Que integration is a middleware which will trace job executions.
1292
-
1293
- You can enable it through `Datadog.configure`:
1294
-
1295
- ```ruby
1296
- require 'ddtrace'
1297
-
1298
- Datadog.configure do |c|
1299
- c.use :que, options
1300
- end
1301
- ```
1302
-
1303
- Where `options` is an optional `Hash` that accepts the following parameters:
1304
-
1305
- | Key | Description | Default |
1306
- | --- | ----------- | ------- |
1307
- | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1308
- | `service_name` | Service name used for `que` instrumentation | `'que'` |
1309
- | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1310
- | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1311
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1312
-
1313
- ### Racecar
1314
-
1315
- The Racecar integration provides tracing for Racecar jobs.
1316
-
1317
- You can enable it through `Datadog.configure`:
1318
-
1319
- ```ruby
1320
- require 'ddtrace'
1321
-
1322
- Datadog.configure do |c|
1323
- c.use :racecar, options
1324
- end
1325
- ```
1326
-
1327
- Where `options` is an optional `Hash` that accepts the following parameters:
1328
-
1329
- | Key | Description | Default |
1330
- | --- | ----------- | ------- |
1331
- | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1332
-
1333
- ### Rack
1334
-
1335
- The Rack integration provides a middleware that traces all requests before they reach the underlying framework or application. It responds to the Rack minimal interface, providing reasonable values that can be retrieved at the Rack level.
1336
-
1337
- This integration is automatically activated with web frameworks like Rails. If you're using a plain Rack application, enable the integration it to your `config.ru`:
1338
-
1339
- ```ruby
1340
- # config.ru example
1341
- require 'ddtrace'
1342
-
1343
- Datadog.configure do |c|
1344
- c.use :rack, options
1345
- end
1346
-
1347
- use Datadog::Contrib::Rack::TraceMiddleware
1348
-
1349
- app = proc do |env|
1350
- [ 200, {'Content-Type' => 'text/plain'}, ['OK'] ]
1351
- end
1352
-
1353
- run app
1354
- ```
1355
-
1356
- Where `options` is an optional `Hash` that accepts the following parameters:
1357
-
1358
- | Key | Description | Default |
1359
- | --- | ----------- | ------- |
1360
- | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1361
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
1362
- | `headers` | Hash of HTTP request or response headers to add as tags to the `rack.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
1363
- | `middleware_names` | Enable this if you want to use the last executed middleware class as the resource name for the `rack` span. If enabled alongside the `rails` instrumention, `rails` takes precedence by setting the `rack` resource name to the active `rails` controller when applicable. Requires `application` option to use. | `false` |
1364
- | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1365
- | `quantize.query` | Hash containing options for query portion of URL quantization. May include `:show` or `:exclude`. See options below. Option must be nested inside the `quantize` option. | `{}` |
1366
- | `quantize.query.show` | Defines which values should always be shown. Shows no values by default. May be an Array of strings, or `:all` to show all values. Option must be nested inside the `query` option. | `nil` |
1367
- | `quantize.query.exclude` | Defines which values should be removed entirely. Excludes nothing by default. May be an Array of strings, or `:all` to remove the query string entirely. Option must be nested inside the `query` option. | `nil` |
1368
- | `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` |
1369
- | `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` |
1370
- | `service_name` | Service name used for `rack` instrumentation | `'rack'` |
1371
- | `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
1372
-
1373
- **Configuring URL quantization behavior**
1374
-
1375
- ```ruby
1376
- Datadog.configure do |c|
1377
- # Default behavior: all values are quantized, fragment is removed.
1378
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id&sort_by
1379
- # http://example.com/path?categories[]=1&categories[]=2 --> http://example.com/path?categories[]
1380
-
1381
- # Show values for any query string parameter matching 'category_id' exactly
1382
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by
1383
- c.use :rack, quantize: { query: { show: ['category_id'] } }
1384
-
1385
- # Show all values for all query string parameters
1386
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by=asc
1387
- c.use :rack, quantize: { query: { show: :all } }
1388
-
1389
- # Totally exclude any query string parameter matching 'sort_by' exactly
1390
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id
1391
- c.use :rack, quantize: { query: { exclude: ['sort_by'] } }
1392
-
1393
- # Remove the query string entirely
1394
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path
1395
- c.use :rack, quantize: { query: { exclude: :all } }
1396
-
1397
- # Show URL fragments
1398
- # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id&sort_by#featured
1399
- c.use :rack, quantize: { fragment: :show }
1400
- end
1401
- ```
1402
-
1403
- ### Rails
1404
-
1405
- The Rails integration will trace requests, database calls, templates rendering, and cache read/write/delete operations. The integration makes use of the Active Support Instrumentation, listening to the Notification API so that any operation instrumented by the API is traced.
1406
-
1407
- To enable the Rails instrumentation, create an initializer file in your `config/initializers` folder:
1408
-
1409
- ```ruby
1410
- # config/initializers/datadog.rb
1411
- require 'ddtrace'
1412
-
1413
- Datadog.configure do |c|
1414
- c.use :rails, options
1415
- end
1416
- ```
1417
-
1418
- Where `options` is an optional `Hash` that accepts the following parameters:
1419
-
1420
- | Key | Description | Default |
1421
- | --- | ----------- | ------- |
1422
- | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1423
- | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1424
- | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
1425
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
1426
- | `exception_controller` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | `nil` |
1427
- | `middleware` | Add the trace middleware to the Rails application. Set to `false` if you don't want the middleware to load. | `true` |
1428
- | `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
1429
- | `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
1430
- | `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/'` |
1431
- | `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` |
1432
-
1433
- **Supported versions**
1434
-
1435
- | MRI Versions | JRuby Versions | Rails Versions |
1436
- | ------------- | -------------- | -------------- |
1437
- | 2.0 | | 3.0 - 3.2 |
1438
- | 2.1 | | 3.0 - 4.2 |
1439
- | 2.2 - 2.3 | | 3.0 - 5.2 |
1440
- | 2.4 | | 4.2.8 - 5.2 |
1441
- | 2.5 | | 4.2.8 - 6.1 |
1442
- | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1443
- | 3.0 | | 6.1 |
1444
-
1445
- ### Rake
1446
-
1447
- You can add instrumentation around your Rake tasks by activating the `rake` integration. Each task and its subsequent subtasks will be traced.
1448
-
1449
- To activate Rake task tracing, add the following to your `Rakefile`:
1450
-
1451
- ```ruby
1452
- # At the top of your Rakefile:
1453
- require 'rake'
1454
- require 'ddtrace'
1455
-
1456
- Datadog.configure do |c|
1457
- c.use :rake, options
1458
- end
1459
-
1460
- task :my_task do
1461
- # Do something task work here...
1462
- end
1463
-
1464
- Rake::Task['my_task'].invoke
1465
- ```
1466
-
1467
- Where `options` is an optional `Hash` that accepts the following parameters:
1468
-
1469
- | Key | Description | Default |
1470
- | --- | ----------- | ------- |
1471
- | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1472
- | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1473
- | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
1474
-
1475
- **Configuring task quantization behavior**
1476
-
1477
- ```ruby
1478
- Datadog.configure do |c|
1479
- # Given a task that accepts :one, :two, :three...
1480
- # Invoked with 'foo', 'bar', 'baz'.
1481
-
1482
- # Default behavior: all arguments are quantized.
1483
- # `rake.invoke.args` tag --> ['?']
1484
- # `rake.execute.args` tag --> { one: '?', two: '?', three: '?' }
1485
- c.use :rake
1486
-
1487
- # Show values for any argument matching :two exactly
1488
- # `rake.invoke.args` tag --> ['?']
1489
- # `rake.execute.args` tag --> { one: '?', two: 'bar', three: '?' }
1490
- c.use :rake, quantize: { args: { show: [:two] } }
1491
-
1492
- # Show all values for all arguments.
1493
- # `rake.invoke.args` tag --> ['foo', 'bar', 'baz']
1494
- # `rake.execute.args` tag --> { one: 'foo', two: 'bar', three: 'baz' }
1495
- c.use :rake, quantize: { args: { show: :all } }
1496
-
1497
- # Totally exclude any argument matching :three exactly
1498
- # `rake.invoke.args` tag --> ['?']
1499
- # `rake.execute.args` tag --> { one: '?', two: '?' }
1500
- c.use :rake, quantize: { args: { exclude: [:three] } }
1501
-
1502
- # Remove the arguments entirely
1503
- # `rake.invoke.args` tag --> ['?']
1504
- # `rake.execute.args` tag --> {}
1505
- c.use :rake, quantize: { args: { exclude: :all } }
1506
- end
1507
- ```
1508
-
1509
- ### Redis
1510
-
1511
- The Redis integration will trace simple calls as well as pipelines.
1512
-
1513
- ```ruby
1514
- require 'redis'
1515
- require 'ddtrace'
1516
-
1517
- Datadog.configure do |c|
1518
- c.use :redis, options
1519
- end
1520
-
1521
- # Perform Redis commands
1522
- redis = Redis.new
1523
- redis.set 'foo', 'bar'
1524
- ```
1525
-
1526
- Where `options` is an optional `Hash` that accepts the following parameters:
1527
-
1528
- | Key | Description | Default |
1529
- | --- | ----------- | ------- |
1530
- | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1531
- | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1532
-
1533
- You can also set *per-instance* configuration as it follows:
1534
-
1535
- ```ruby
1536
- require 'redis'
1537
- require 'ddtrace'
1538
-
1539
- Datadog.configure do |c|
1540
- c.use :redis # Enabling integration instrumentation is still required
1541
- end
1542
-
1543
- customer_cache = Redis.new
1544
- invoice_cache = Redis.new
1545
-
1546
- Datadog.configure(customer_cache, service_name: 'customer-cache')
1547
- Datadog.configure(invoice_cache, service_name: 'invoice-cache')
1548
-
1549
- # Traced call will belong to `customer-cache` service
1550
- customer_cache.get(...)
1551
- # Traced call will belong to `invoice-cache` service
1552
- invoice_cache.get(...)
1553
- ```
1554
-
1555
- **Configuring trace settings per connection**
1556
-
1557
- You can configure trace settings per connection by using the `describes` option:
1558
-
1559
- ```ruby
1560
- # Provide a `:describes` option with a connection key.
1561
- # Any of the following keys are acceptable and equivalent to one another.
1562
- # If a block is provided, it yields a Settings object that
1563
- # accepts any of the configuration options listed above.
1564
-
1565
- Datadog.configure do |c|
1566
- # The default configuration for any redis client
1567
- c.use :redis, service_name: 'redis-default'
1568
-
1569
- # The configuration matching a given unix socket.
1570
- c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1571
-
1572
- # For network connections, only these fields are considered during matching:
1573
- # scheme, host, port, db
1574
- # Other fields are ignored.
1575
-
1576
- # Network connection string
1577
- c.use :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
1578
- c.use :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
1579
- # Network client hash
1580
- c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1581
- # Only a subset of the connection hash
1582
- c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
1583
- c.use :redis, describes: { host: ENV['SIDEKIQ_CACHE_HOST'] }, service_name: 'redis-sidekiq'
1584
- end
1585
- ```
1586
-
1587
- When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1588
-
1589
- ### Resque
1590
-
1591
- The Resque integration uses Resque hooks that wraps the `perform` method.
1592
-
1593
- To add tracing to a Resque job:
1594
-
1595
- ```ruby
1596
- require 'resque'
1597
- require 'ddtrace'
1598
-
1599
- Datadog.configure do |c|
1600
- c.use :resque, **options
1601
- end
1602
- ```
1603
-
1604
- Where `options` is an optional `Hash` that accepts the following parameters:
1605
-
1606
- | Key | Description | Default |
1607
- | --- | ----------- | ------- |
1608
- | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1609
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1610
- | `workers` | **[DEPRECATED]** Limits instrumented worker classes to only the ones specified in an array (e.g. `[MyJob]`). If not provided, instruments all workers. | `nil` |
1611
-
1612
- ### Rest Client
1613
-
1614
- The `rest-client` integration is available through the `ddtrace` middleware:
1615
-
1616
- ```ruby
1617
- require 'rest_client'
1618
- require 'ddtrace'
1619
-
1620
- Datadog.configure do |c|
1621
- c.use :rest_client, options
1622
- end
1623
- ```
1624
-
1625
- Where `options` is an optional `Hash` that accepts the following parameters:
1626
-
1627
- | Key | Description | Default |
1628
- | --- | ----------- | ------- |
1629
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1630
- | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1631
-
1632
- ### RSpec
1633
-
1634
- RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1635
-
1636
- To activate your integration, use the `Datadog.configure` method:
1637
-
1638
- ```ruby
1639
- require 'rspec'
1640
- require 'ddtrace'
1641
-
1642
- # Configure default RSpec integration
1643
- Datadog.configure do |c|
1644
- c.use :rspec, options
1645
- end
1646
- ```
1647
-
1648
- Where `options` is an optional `Hash` that accepts the following parameters:
1649
-
1650
- | Key | Description | Default |
1651
- | --- | ----------- | ------- |
1652
- | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1653
- | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1654
- | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1655
-
1656
- ### Sequel
1657
-
1658
- The Sequel integration traces queries made to your database.
1659
-
1660
- ```ruby
1661
- require 'sequel'
1662
- require 'ddtrace'
1663
-
1664
- # Connect to database
1665
- database = Sequel.sqlite
1666
-
1667
- # Create a table
1668
- database.create_table :articles do
1669
- primary_key :id
1670
- String :name
1671
- end
1672
-
1673
- Datadog.configure do |c|
1674
- c.use :sequel, options
1675
- end
1676
-
1677
- # Perform a query
1678
- articles = database[:articles]
1679
- articles.all
1680
- ```
1681
-
1682
- Where `options` is an optional `Hash` that accepts the following parameters:
1683
-
1684
- | Key | Description | Default |
1685
- | --- | ----------- | ------- |
1686
- | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1687
-
1688
- **Configuring databases to use different settings**
1689
-
1690
- If you use multiple databases with Sequel, you can give each of them different settings by configuring their respective `Sequel::Database` objects:
1691
-
1692
- ```ruby
1693
- sqlite_database = Sequel.sqlite
1694
- postgres_database = Sequel.connect('postgres://user:password@host:port/database_name')
1695
-
1696
- # Configure each database with different service names
1697
- Datadog.configure(sqlite_database, service_name: 'my-sqlite-db')
1698
- Datadog.configure(postgres_database, service_name: 'my-postgres-db')
1699
- ```
1700
-
1701
- ### Shoryuken
1702
-
1703
- The Shoryuken integration is a server-side middleware which will trace job executions.
1704
-
1705
- You can enable it through `Datadog.configure`:
1706
-
1707
- ```ruby
1708
- require 'ddtrace'
1709
-
1710
- Datadog.configure do |c|
1711
- c.use :shoryuken, options
1712
- end
1713
- ```
1714
-
1715
- Where `options` is an optional `Hash` that accepts the following parameters:
1716
-
1717
- | Key | Description | Default |
1718
- | --- | ----------- | ------- |
1719
- | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1720
- | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1721
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1722
-
1723
- ### Sidekiq
1724
-
1725
- The Sidekiq integration is a client-side & server-side middleware which will trace job queuing and executions respectively.
1726
-
1727
- You can enable it through `Datadog.configure`:
1728
-
1729
- ```ruby
1730
- require 'ddtrace'
1731
-
1732
- Datadog.configure do |c|
1733
- c.use :sidekiq, options
1734
- end
1735
- ```
1736
-
1737
- Where `options` is an optional `Hash` that accepts the following parameters:
1738
-
1739
- | Key | Description | Default |
1740
- | --- | ----------- | ------- |
1741
- | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1742
- | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1743
- | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1744
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1745
-
1746
- ### Sinatra
1747
-
1748
- The Sinatra integration traces requests and template rendering.
1749
-
1750
- 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:
1751
-
1752
- #### Classic application
1753
-
1754
- ```ruby
1755
- require 'sinatra'
1756
- require 'ddtrace'
1757
-
1758
- Datadog.configure do |c|
1759
- c.use :sinatra, options
1760
- end
1761
-
1762
- get '/' do
1763
- 'Hello world!'
1764
- end
1765
- ```
1766
-
1767
- #### Modular application
1768
-
1769
- ```ruby
1770
- require 'sinatra/base'
1771
- require 'ddtrace'
1772
-
1773
- Datadog.configure do |c|
1774
- c.use :sinatra, options
1775
- end
1776
-
1777
- class NestedApp < Sinatra::Base
1778
- register Datadog::Contrib::Sinatra::Tracer
1779
-
1780
- get '/nested' do
1781
- 'Hello from nested app!'
1782
- end
1783
- end
1784
-
1785
- class App < Sinatra::Base
1786
- register Datadog::Contrib::Sinatra::Tracer
1787
-
1788
- use NestedApp
1789
-
1790
- get '/' do
1791
- 'Hello world!'
1792
- end
1793
- end
1794
- ```
1795
-
1796
- Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before you mount your nested applications.
1797
-
1798
- #### Instrumentation options
1799
-
1800
- `options` is an optional `Hash` that accepts the following parameters:
1801
-
1802
- | Key | Description | Default |
1803
- | --- | ----------- | ------- |
1804
- | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
1805
- | `headers` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
1806
- | `resource_script_names` | Prepend resource names with script name | `false` |
1807
- | `service_name` | Service name used for `sinatra` instrumentation | `'sinatra'` |
1808
-
1809
- ### Sneakers
1810
-
1811
- The Sneakers integration is a server-side middleware which will trace job executions.
1812
-
1813
- You can enable it through `Datadog.configure`:
1814
-
1815
- ```ruby
1816
- require 'ddtrace'
1817
-
1818
- Datadog.configure do |c|
1819
- c.use :sneakers, options
1820
- end
1821
- ```
1822
-
1823
- Where `options` is an optional `Hash` that accepts the following parameters:
1824
-
1825
- | Key | Description | Default |
1826
- | --- | ----------- | ------- |
1827
- | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1828
- | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1829
- | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1830
- | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1831
-
1832
- ### Sucker Punch
1833
-
1834
- The `sucker_punch` integration traces all scheduled jobs:
1835
-
1836
- ```ruby
1837
- require 'ddtrace'
1838
-
1839
- Datadog.configure do |c|
1840
- c.use :sucker_punch, options
1841
- end
1842
-
1843
- # Execution of this job is traced
1844
- LogJob.perform_async('login')
1845
- ```
1846
-
1847
- Where `options` is an optional `Hash` that accepts the following parameters:
1848
-
1849
- | Key | Description | Default |
1850
- | --- | ----------- | ------- |
1851
- | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1852
-
1853
- ## Advanced configuration
1854
-
1855
- ### Tracer settings
1856
-
1857
- To change the default behavior of the Datadog tracer, you can provide custom options inside the `Datadog.configure` block as in:
1858
-
1859
- ```ruby
1860
- # config/initializers/datadog-tracer.rb
1861
-
1862
- Datadog.configure do |c|
1863
- c.tracer.enabled = true
1864
- c.tracer.hostname = 'my-agent'
1865
- c.tracer.port = 8126
1866
-
1867
- # Ensure all traces are ingested by Datadog
1868
- c.sampling.default_rate = 1.0 # Recommended
1869
- c.sampling.rate_limit = 200
1870
- # or provide a custom implementation (overrides c.sampling settings)
1871
- c.tracer.sampler = Datadog::AllSampler.new
1872
-
1873
- # Breaks down very large traces into smaller batches
1874
- c.tracer.partial_flush.enabled = false
1875
-
1876
- # You can specify your own tracer
1877
- c.tracer.instance = Datadog::Tracer.new
1878
-
1879
- # To enable debug mode
1880
- c.diagnostics.debug = true
1881
- end
1882
- ```
1883
-
1884
- Available options are:
1885
-
1886
- - `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`.
1887
- - `hostname`: set the hostname of the trace agent.
1888
- - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1889
- - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1890
- - `port`: set the port the trace agent is listening on.
1891
- - `sampling.default_rate`: default tracer sampling rate, between `0.0` (0%) and `1.0` (100%, recommended). `1.0` or Tracing without Limits™, allows you to send all of your traffic and retention can be [configured within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/). When this configuration is not set, the Datadog agent will keep an intelligent assortment of diverse traces.
1892
- - `sampling.rate_limit`: maximum number of traces per second to sample. Defaults to 100 per second.
1893
- - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1894
- - `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
1895
- - `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
1896
- - `time_now_provider`: when testing, it might be helpful to use a different time provider. For Timecop, for example, `->{ Time.now_without_mock_time }` allows the tracer to use the real wall time. Span duration calculation will still use the system monotonic clock when available, thus not being affected by this setting. Defaults to `->{ Time.now }`.
1897
-
1898
- #### Custom logging
1899
-
1900
- By default, all logs are processed by the default Ruby logger. When using Rails, you should see the messages in your application log file.
1901
-
1902
- Datadog client log messages are marked with `[ddtrace]` so you should be able to isolate them from other messages.
1903
-
1904
- Additionally, it is possible to override the default logger and replace it by a custom one. This is done using the `log` setting.
1905
-
1906
- ```ruby
1907
- f = File.new("my-custom.log", "w+") # Log messages should go there
1908
- Datadog.configure do |c|
1909
- c.logger = Logger.new(f) # Overriding the default logger
1910
- c.logger.level = ::Logger::INFO
1911
- end
1912
-
1913
- Datadog.logger.info { "this is typically called by tracing code" }
1914
- ```
1915
-
1916
- ### Environment and tags
1917
-
1918
- 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.
1919
-
1920
- You can configure the application to automatically tag your traces and metrics, using the following environment variables:
1921
-
1922
- - `DD_ENV`: Your application environment (e.g. `production`, `staging`, etc.)
1923
- - `DD_SERVICE`: Your application's default service name (e.g. `billing-api`)
1924
- - `DD_VERSION`: Your application version (e.g. `2.5`, `202003181415`, `1.3-alpha`, etc.)
1925
- - `DD_TAGS`: Custom tags in value pairs separated by `,` (e.g. `layer:api,team:intake`)
1926
- - If `DD_ENV`, `DD_SERVICE` or `DD_VERSION` are set, it will override any respective `env`/`service`/`version` tag defined in `DD_TAGS`.
1927
- - 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.
1928
-
1929
- These values can also be overridden at the tracer level:
1930
-
1931
- ```ruby
1932
- Datadog.configure do |c|
1933
- c.service = 'billing-api'
1934
- c.env = 'test'
1935
- c.tags = { 'team' => 'qa' }
1936
- c.version = '1.3-alpha'
1937
- end
1938
- ```
1939
-
1940
- 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.
1941
-
1942
- Tags can also be set directly on individual spans, which will supersede any conflicting tags defined at the application level.
1943
-
1944
- ### Environment variables
1945
-
1946
- Other Environment Variables:
1947
-
1948
- - `DD_TRACE_AGENT_URL`: Sets the URL endpoint where traces are sent. Has priority over `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT` if set. e.g. `DD_TRACE_AGENT_URL=http://localhost:8126`.
1949
- - `DD_TRACE_<INTEGRATION>_ENABLED`: Enables or disables an **activated** integration. Defaults to `true`.. e.g. `DD_TRACE_RAILS_ENABLED=false`. This option has no effects on integrations that have not been explicitly activated (e.g. `Datadog.configure{ |c| c.use :integration }`).on code. This environment variable can only be used to disable an integration.
1950
- - `DD_TRACE_SAMPLE_RATE`: Sets the trace sampling rate between `0.0` (0%) and `1.0` (100%, recommended). `1.0` or Tracing without Limits™, allows you to send all of your traffic and retention can be [configured within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/). When this configuration is not set, the Datadog agent will keep an intelligent assortment of diverse traces.
1951
- - `DD_LOGS_INJECTION`: Automatically enables injection [Trace Correlation](#trace-correlation) information, such as `dd.trace_id`, into Rails logs. Supports the default logger (`ActiveSupport::TaggedLogging`) and `Lograge`. Details on the format of Trace Correlation information can be found in the [Trace Correlation](#trace-correlation) section. Valid values are: `true` or `false`(default). e.g. `DD_LOGS_INJECTION=true`.
1952
-
1953
- ### Sampling
1954
-
1955
- Datadog's Tracing without Limits™ allows you to send all of your traffic and [configure retention within the Datadog app](https://docs.datadoghq.com/tracing/trace_retention_and_ingestion/).
1956
-
1957
- We recommend setting the environment variable `DD_TRACE_SAMPLE_RATE=1.0` in all new applications using `ddtrace`.
1958
-
1959
- App Analytics, previously configured with the `analytics_enabled` setting, is deprecated in favor of Tracing without Limits™. Documentation for this [deprecated configuration is still available](https://docs.datadoghq.com/tracing/legacy_app_analytics/).
1960
-
1961
- #### Application-side sampling
1962
-
1963
- While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
1964
-
1965
- This will **reduce visibility and is not recommended**. See [DD_TRACE_SAMPLE_RATE](#environment-variables) for the recommended sampling approach.
1966
-
1967
- `Datadog::RateSampler` samples a ratio of the traces. For example:
1968
-
1969
- ```ruby
1970
- # Sample rate is between 0 (nothing sampled) to 1 (everything sampled).
1971
- sampler = Datadog::RateSampler.new(0.5) # sample 50% of the traces
1972
-
1973
- Datadog.configure do |c|
1974
- c.tracer.sampler = sampler
1975
- end
1976
- ```
1977
-
1978
- #### Priority sampling
1979
-
1980
- Priority sampling decides whether to keep a trace by using a priority attribute propagated for distributed traces. Its value indicates to the Agent and the backend about how important the trace is.
1981
-
1982
- The sampler can set the priority to the following values:
1983
-
1984
- - `Datadog::Ext::Priority::AUTO_REJECT`: the sampler automatically decided to reject the trace.
1985
- - `Datadog::Ext::Priority::AUTO_KEEP`: the sampler automatically decided to keep the trace.
1986
-
1987
- Priority sampling is enabled by default. Enabling it ensures that your sampled distributed traces will be complete. Once enabled, the sampler will automatically assign a priority of 0 or 1 to traces, depending on their service and volume.
1988
-
1989
- You can also set this priority manually to either drop a non-interesting trace or to keep an important one. For that, set the `context#sampling_priority` to:
1990
-
1991
- - `Datadog::Ext::Priority::USER_REJECT`: the user asked to reject the trace.
1992
- - `Datadog::Ext::Priority::USER_KEEP`: the user asked to keep the trace.
1993
-
1994
- When not using [distributed tracing](#distributed-tracing), you may change the priority at any time, as long as the trace incomplete. But it has to be done before any context propagation (fork, RPC calls) to be useful in a distributed context. Changing the priority after the context has been propagated causes different parts of a distributed trace to use different priorities. Some parts might be kept, some parts might be rejected, and this can cause the trace to be partially stored and remain incomplete.
1995
-
1996
- If you change the priority, we recommend you do it as soon as possible - when the root span has just been created.
1997
-
1998
- ```ruby
1999
- # First, grab the active span
2000
- span = Datadog.tracer.active_span
2001
-
2002
- # Indicate to reject the trace
2003
- span.context.sampling_priority = Datadog::Ext::Priority::USER_REJECT
2004
-
2005
- # Indicate to keep the trace
2006
- span.context.sampling_priority = Datadog::Ext::Priority::USER_KEEP
2007
- ```
2008
-
2009
- ### Distributed Tracing
2010
-
2011
- Distributed tracing allows traces to be propagated across multiple instrumented applications so that a request can be presented as a single trace, rather than a separate trace per service.
2012
-
2013
- To trace requests across application boundaries, the following must be propagated between each application:
2014
-
2015
- | Property | Type | Description |
2016
- | --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
2017
- | **Trace ID** | Integer | ID of the trace. This value should be the same across all requests that belong to the same trace. |
2018
- | **Parent Span ID** | Integer | ID of the span in the service originating the request. This value will always be different for each request within a trace. |
2019
- | **Sampling Priority** | Integer | Sampling priority level for the trace. This value should be the same across all requests that belong to the same trace. |
2020
-
2021
- Such propagation can be visualized as:
2022
-
2023
- ```
2024
- Service A:
2025
- Trace ID: 100000000000000001
2026
- Parent ID: 0
2027
- Span ID: 100000000000000123
2028
- Priority: 1
2029
-
2030
- |
2031
- | Service B Request:
2032
- | Metadata:
2033
- | Trace ID: 100000000000000001
2034
- | Parent ID: 100000000000000123
2035
- | Priority: 1
2036
- |
2037
- V
2038
-
2039
- Service B:
2040
- Trace ID: 100000000000000001
2041
- Parent ID: 100000000000000123
2042
- Span ID: 100000000000000456
2043
- Priority: 1
2044
-
2045
- |
2046
- | Service C Request:
2047
- | Metadata:
2048
- | Trace ID: 100000000000000001
2049
- | Parent ID: 100000000000000456
2050
- | Priority: 1
2051
- |
2052
- V
2053
-
2054
- Service C:
2055
- Trace ID: 100000000000000001
2056
- Parent ID: 100000000000000456
2057
- Span ID: 100000000000000789
2058
- Priority: 1
2059
- ```
2060
-
2061
- **Via HTTP**
2062
-
2063
- For HTTP requests between instrumented applications, this trace metadata is propagated by use of HTTP Request headers:
2064
-
2065
- | Property | Type | HTTP Header name |
2066
- | --------------------- | ------- | ----------------------------- |
2067
- | **Trace ID** | Integer | `x-datadog-trace-id` |
2068
- | **Parent Span ID** | Integer | `x-datadog-parent-id` |
2069
- | **Sampling Priority** | Integer | `x-datadog-sampling-priority` |
2070
-
2071
- Such that:
2072
-
2073
- ```
2074
- Service A:
2075
- Trace ID: 100000000000000001
2076
- Parent ID: 0
2077
- Span ID: 100000000000000123
2078
- Priority: 1
2079
-
2080
- |
2081
- | Service B HTTP Request:
2082
- | Headers:
2083
- | x-datadog-trace-id: 100000000000000001
2084
- | x-datadog-parent-id: 100000000000000123
2085
- | x-datadog-sampling-priority: 1
2086
- |
2087
- V
2088
-
2089
- Service B:
2090
- Trace ID: 100000000000000001
2091
- Parent ID: 100000000000000123
2092
- Span ID: 100000000000000456
2093
- Priority: 1
2094
-
2095
- |
2096
- | Service C HTTP Request:
2097
- | Headers:
2098
- | x-datadog-trace-id: 100000000000000001
2099
- | x-datadog-parent-id: 100000000000000456
2100
- | x-datadog-sampling-priority: 1
2101
- |
2102
- V
2103
-
2104
- Service C:
2105
- Trace ID: 100000000000000001
2106
- Parent ID: 100000000000000456
2107
- Span ID: 100000000000000789
2108
- Priority: 1
2109
- ```
2110
-
2111
- **Activating distributed tracing for integrations**
2112
-
2113
- 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.
2114
-
2115
- - 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)
2116
- - 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)
2117
- - If your application both sends and receives requests implementing distributed tracing, it must activate all integrations that handle these requests.
2118
-
2119
- For more details on how to activate distributed tracing for integrations, see their documentation:
2120
-
2121
- - [Excon](#excon)
2122
- - [Faraday](#faraday)
2123
- - [Rest Client](#rest-client)
2124
- - [Net/HTTP](#nethttp)
2125
- - [Rack](#rack)
2126
- - [Rails](#rails)
2127
- - [Sinatra](#sinatra)
2128
- - [http.rb](#http-rb)
2129
- - [httpclient](#httpclient)
2130
- - [httpx](#httpx)
2131
-
2132
- **Using the HTTP propagator**
2133
-
2134
- To make the process of propagating this metadata easier, you can use the `Datadog::HTTPPropagator` module.
2135
-
2136
- On the client:
2137
-
2138
- ```ruby
2139
- Datadog.tracer.trace('web.call') do |span|
2140
- # Inject span context into headers (`env` must be a Hash)
2141
- Datadog::HTTPPropagator.inject!(span.context, env)
2142
- end
2143
- ```
2144
-
2145
- On the server:
2146
-
2147
- ```ruby
2148
- Datadog.tracer.trace('web.work') do |span|
2149
- # Build a context from headers (`env` must be a Hash)
2150
- context = HTTPPropagator.extract(request.env)
2151
- Datadog.tracer.provider.context = context if context.trace_id
2152
- end
2153
- ```
2154
-
2155
- ### HTTP request queuing
2156
-
2157
- Traces that originate from HTTP requests can be configured to include the time spent in a frontend web server or load balancer queue before the request reaches the Ruby application.
2158
-
2159
- This feature is disabled by default. To activate it, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
2160
-
2161
- ```
2162
- # /etc/nginx/conf.d/ruby_service.conf
2163
- server {
2164
- listen 8080;
2165
-
2166
- location / {
2167
- proxy_set_header X-Request-Start "t=${msec}";
2168
- proxy_pass http://web:3000;
2169
- }
2170
- }
2171
- ```
2172
-
2173
- Then you must enable the request queuing feature, by setting `request_queuing: true`, in the integration handling the request. For Rack-based applications, see the [documentation](#rack) for details.
2174
-
2175
- ### Processing Pipeline
2176
-
2177
- Some applications might require that traces be altered or filtered out before they are sent upstream. The processing pipeline allows users to create *processors* to define such behavior.
2178
-
2179
- Processors can be any object that responds to `#call` accepting `trace` as an argument (which is an `Array` of `Datadog::Span`s.)
2180
-
2181
- For example:
2182
-
2183
- ```ruby
2184
- lambda_processor = ->(trace) do
2185
- # Processing logic...
2186
- trace
2187
- end
2188
-
2189
- class MyCustomProcessor
2190
- def call(trace)
2191
- # Processing logic...
2192
- trace
2193
- end
2194
- end
2195
- custom_processor = MyFancyProcessor.new
2196
- ```
2197
-
2198
- `#call` blocks of processors *must* return the `trace` object; this return value will be passed to the next processor in the pipeline.
2199
-
2200
- These processors must then be added to the pipeline via `Datadog::Pipeline.before_flush`:
2201
-
2202
- ```ruby
2203
- Datadog::Pipeline.before_flush(lambda_processor, custom_processor)
2204
- ```
2205
-
2206
- You can also define processors using the short-hand block syntax for `Datadog::Pipeline.before_flush`:
2207
-
2208
- ```ruby
2209
- Datadog::Pipeline.before_flush do |trace|
2210
- trace.delete_if { |span| span.name =~ /forbidden/ }
2211
- end
2212
- ```
2213
-
2214
- #### Filtering
2215
-
2216
- You can use the `Datadog::Pipeline::SpanFilter` processor to remove spans, when the block evaluates as truthy:
2217
-
2218
- ```ruby
2219
- Datadog::Pipeline.before_flush(
2220
- # Remove spans that match a particular resource
2221
- Datadog::Pipeline::SpanFilter.new { |span| span.resource =~ /PingController/ },
2222
- # Remove spans that are trafficked to localhost
2223
- Datadog::Pipeline::SpanFilter.new { |span| span.get_tag('host') == 'localhost' }
2224
- )
2225
- ```
2226
-
2227
- #### Processing
2228
-
2229
- You can use the `Datadog::Pipeline::SpanProcessor` processor to modify spans:
2230
-
2231
- ```ruby
2232
- Datadog::Pipeline.before_flush(
2233
- # Strip matching text from the resource field
2234
- Datadog::Pipeline::SpanProcessor.new { |span| span.resource.gsub!(/password=.*/, '') }
2235
- )
2236
- ```
2237
-
2238
- ### Trace correlation
2239
-
2240
- In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing.
2241
-
2242
- #### For logging in Rails applications
2243
-
2244
- ##### Automatic
2245
-
2246
- For Rails applications using the default logger (`ActiveSupport::TaggedLogging`), `semantic_logger`, or `lograge`, you can automatically enable trace correlation injection by setting the `rails` instrumentation configuration option `log_injection` to `true` or by setting environment variable `DD_LOGS_INJECTION=true`:
2247
-
2248
- ```ruby
2249
- # config/initializers/datadog.rb
2250
- require 'ddtrace'
2251
-
2252
- Datadog.configure do |c|
2253
- c.use :rails, log_injection: true
2254
- end
2255
- ```
2256
-
2257
- ##### Manual (Lograge)
2258
-
2259
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
2260
-
2261
- ```ruby
2262
- config.lograge.custom_options = lambda do |event|
2263
- # Retrieves trace information for current thread
2264
- correlation = Datadog.tracer.active_correlation
2265
-
2266
- {
2267
- # Adds IDs as tags to log output
2268
- :dd => {
2269
- # To preserve precision during JSON serialization, use strings for large numbers
2270
- :trace_id => correlation.trace_id.to_s,
2271
- :span_id => correlation.span_id.to_s,
2272
- :env => correlation.env.to_s,
2273
- :service => correlation.service.to_s,
2274
- :version => correlation.version.to_s
2275
- },
2276
- :ddsource => ["ruby"],
2277
- :params => event.payload[:params].reject { |k| %w(controller action).include? k }
2278
- }
2279
- end
2280
- ```
2281
-
2282
- ##### Manual (ActiveSupport::TaggedLogging)
2283
-
2284
- 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:
2285
-
2286
- ```ruby
2287
- Rails.application.configure do
2288
- config.log_tags = [proc { Datadog.tracer.active_correlation.to_s }]
2289
- end
2290
-
2291
- # Given:
2292
- # DD_ENV = 'production' (The name of the environment your application is running in.)
2293
- # DD_SERVICE = 'billing-api' (Default service name of your application.)
2294
- # DD_VERSION = '2.5.17' (The version of your application.)
2295
-
2296
- # Web requests will produce:
2297
- # [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
2298
- # [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 */*
2299
- # [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"
2300
- # [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)
2301
- ```
2302
-
2303
- #### For logging in Ruby applications
2304
-
2305
- 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.
2306
-
2307
- To properly correlate with Datadog logging, be sure the following is present in the log message, in order as they appear:
2308
-
2309
- - `dd.env=<ENV>`: Where `<ENV>` is equal to `Datadog.tracer.active_correlation.env`. Omit if no environment is configured.
2310
- - `dd.service=<SERVICE>`: Where `<SERVICE>` is equal to `Datadog.tracer.active_correlation.service`. Omit if no default service name is configured.
2311
- - `dd.version=<VERSION>`: Where `<VERSION>` is equal to `Datadog.tracer.active_correlation.version`. Omit if no application version is configured.
2312
- - `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.
2313
- - `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.
2314
-
2315
- 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>`.
2316
-
2317
- 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=`.
2318
-
2319
- An example of this in practice:
2320
-
2321
- ```ruby
2322
- require 'ddtrace'
2323
- require 'logger'
2324
-
2325
- ENV['DD_ENV'] = 'production'
2326
- ENV['DD_SERVICE'] = 'billing-api'
2327
- ENV['DD_VERSION'] = '2.5.17'
2328
-
2329
- logger = Logger.new(STDOUT)
2330
- logger.progname = 'my_app'
2331
- logger.formatter = proc do |severity, datetime, progname, msg|
2332
- "[#{datetime}][#{progname}][#{severity}][#{Datadog.tracer.active_correlation}] #{msg}\n"
2333
- end
2334
-
2335
- # When no trace is active
2336
- logger.warn('This is an untraced operation.')
2337
- # [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.
2338
-
2339
- # When a trace is active
2340
- Datadog.tracer.trace('my.operation') { logger.warn('This is a traced operation.') }
2341
- # [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.
2342
- ```
2343
-
2344
- ### Configuring the transport layer
2345
-
2346
- By default, the tracer submits trace data using `Net::HTTP` to `127.0.0.1:8126`, the default location for the Datadog trace agent process. However, the tracer can be configured to send its trace data to alternative destinations, or by alternative protocols.
2347
-
2348
- Some basic settings, such as hostname and port, can be configured using [tracer settings](#tracer-settings).
2349
-
2350
- #### Using the Net::HTTP adapter
2351
-
2352
- The `Net` adapter submits traces using `Net::HTTP` over TCP. It is the default transport adapter.
2353
-
2354
- ```ruby
2355
- Datadog.configure do |c|
2356
- c.tracer.transport_options = proc { |t|
2357
- # Hostname, port, and additional options. :timeout is in seconds.
2358
- t.adapter :net_http, '127.0.0.1', 8126, { timeout: 1 }
2359
- }
2360
- end
2361
- ```
2362
-
2363
- #### Using the Unix socket adapter
2364
-
2365
- The `UnixSocket` adapter submits traces using `Net::HTTP` over Unix socket.
2366
-
2367
- To use, first configure your trace agent to listen by Unix socket, then configure the tracer with:
2368
-
2369
- ```ruby
2370
- Datadog.configure do |c|
2371
- c.tracer.transport_options = proc { |t|
2372
- # Provide filepath to trace agent Unix socket
2373
- t.adapter :unix, '/tmp/ddagent/trace.sock'
2374
- }
2375
- end
2376
- ```
2377
-
2378
- #### Using the transport test adapter
2379
-
2380
- The `Test` adapter is a no-op transport that can optionally buffer requests. For use in test suites or other non-production environments.
2381
-
2382
- ```ruby
2383
- Datadog.configure do |c|
2384
- c.tracer.transport_options = proc { |t|
2385
- # Set transport to no-op mode. Does not retain traces.
2386
- t.adapter :test
2387
-
2388
- # Alternatively, you can provide a buffer to examine trace output.
2389
- # The buffer must respond to '<<'.
2390
- t.adapter :test, []
2391
- }
2392
- end
2393
- ```
2394
-
2395
- #### Using a custom transport adapter
2396
-
2397
- Custom adapters can be configured with:
2398
-
2399
- ```ruby
2400
- Datadog.configure do |c|
2401
- c.tracer.transport_options = proc { |t|
2402
- # Initialize and pass an instance of the adapter
2403
- custom_adapter = CustomAdapter.new
2404
- t.adapter custom_adapter
2405
- }
2406
- end
2407
- ```
2408
-
2409
- ### Metrics
2410
-
2411
- The tracer and its integrations can produce some additional metrics that can provide useful insight into the performance of your application. These metrics are collected with `dogstatsd-ruby`, and can be sent to the same Datadog agent to which you send your traces.
2412
-
2413
- To configure your application for metrics collection:
2414
-
2415
- 1. [Configure your Datadog agent for StatsD](https://docs.datadoghq.com/developers/dogstatsd/#setup)
2416
- 2. Add `gem 'dogstatsd-ruby', '~> 5.2'` to your Gemfile
2417
-
2418
- #### For application runtime
2419
-
2420
- If runtime metrics are configured, the trace library will automatically collect and send metrics about the health of your application.
2421
-
2422
- To configure runtime metrics, add the following configuration:
2423
-
2424
- ```ruby
2425
- # config/initializers/datadog.rb
2426
- require 'datadog/statsd'
2427
- require 'ddtrace'
2428
-
2429
- Datadog.configure do |c|
2430
- # To enable runtime metrics collection, set `true`. Defaults to `false`
2431
- # You can also set DD_RUNTIME_METRICS_ENABLED=true to configure this.
2432
- c.runtime_metrics.enabled = true
2433
-
2434
- # Optionally, you can configure the Statsd instance used for sending runtime metrics.
2435
- # Statsd is automatically configured with default settings if `dogstatsd-ruby` is available.
2436
- # You can configure with host and port of Datadog agent; defaults to 'localhost:8125'.
2437
- c.runtime_metrics.statsd = Datadog::Statsd.new
2438
- end
2439
- ```
2440
-
2441
- See the [Dogstatsd documentation](https://www.rubydoc.info/github/DataDog/dogstatsd-ruby/master/frames) for more details about configuring `Datadog::Statsd`.
2442
-
2443
- The stats are VM specific and will include:
2444
-
2445
- | Name | Type | Description |
2446
- | -------------------------- | ------- | -------------------------------------------------------- |
2447
- | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. |
2448
- | `runtime.ruby.thread_count` | `gauge` | Number of threads. |
2449
- | `runtime.ruby.gc.*`. | `gauge` | Garbage collection statistics: collected from `GC.stat`. |
2450
-
2451
- In addition, all metrics include the following tags:
2452
-
2453
- | Name | Description |
2454
- | ------------ | ------------------------------------------------------- |
2455
- | `language` | Programming language traced. (e.g. `ruby`) |
2456
- | `service` | List of services this associated with this metric. |
2457
-
2458
- ### OpenTracing
2459
-
2460
- For setting up Datadog with OpenTracing, see out [Quickstart for OpenTracing](#quickstart-for-opentracing) section for details.
2461
-
2462
- **Configuring Datadog tracer settings**
2463
-
2464
- The underlying Datadog tracer can be configured by passing options (which match `Datadog::Tracer`) when configuring the global tracer:
2465
-
2466
- ```ruby
2467
- # Where `options` is a Hash of options provided to Datadog::Tracer
2468
- OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new(options)
2469
- ```
2470
-
2471
- It can also be configured by using `Datadog.configure` described in the [Tracer settings](#tracer-settings) section.
2472
-
2473
- **Activating and configuring integrations**
2474
-
2475
- By default, configuring OpenTracing with Datadog will not automatically activate any additional instrumentation provided by Datadog. You will only receive spans and traces from OpenTracing instrumentation you have in your application.
2476
-
2477
- However, additional instrumentation provided by Datadog can be activated alongside OpenTracing using `Datadog.configure`, which can be used to enhance your tracing further. To activate this, see [Integration instrumentation](#integration-instrumentation) for more details.
2478
-
2479
- **Supported serialization formats**
2480
-
2481
- | Type | Supported? | Additional information |
2482
- | ------------------------------ | ---------- | ---------------------- |
2483
- | `OpenTracing::FORMAT_TEXT_MAP` | Yes | |
2484
- | `OpenTracing::FORMAT_RACK` | Yes | Because of the loss of resolution in the Rack format, please note that baggage items with names containing either upper case characters or `-` will be converted to lower case and `_` in a round-trip respectively. We recommend avoiding these characters or accommodating accordingly on the receiving end. |
2485
- | `OpenTracing::FORMAT_BINARY` | No | |
2486
-
2487
- ### Profiling
2488
-
2489
- *Currently available as BETA feature.*
2490
-
2491
- `ddtrace` can produce profiles that measure method-level application resource usage within production environments. These profiles can give insight into resources spent in Ruby code outside of existing trace instrumentation.
2492
-
2493
- **Setup**
2494
-
2495
- To get started with profiling, follow the [Profiler Getting Started Guide](https://docs.datadoghq.com/tracing/profiler/getting_started/?code-lang=ruby).
2496
-
2497
- #### Troubleshooting
2498
-
2499
- If you run into issues with profiling, please check the [Profiler Troubleshooting Guide](https://docs.datadoghq.com/tracing/profiler/profiler_troubleshooting/?code-lang=ruby).
2500
-
2501
- #### Profiling Resque jobs
2502
-
2503
- When profiling [Resque](https://github.com/resque/resque) jobs, you should set the `RUN_AT_EXIT_HOOKS=1` option described in the [Resque](https://github.com/resque/resque/blob/v2.0.0/docs/HOOKS.md#worker-hooks) documentation.
2504
-
2505
- Without this flag, profiles for short-lived Resque jobs will not be available as Resque kills worker processes before they have a chance to submit this information.
2506
-
2507
- ## Known issues and suggested configurations
2508
-
2509
- ### Payload too large
2510
-
2511
- By default, Datadog limits the size of trace payloads to prevent memory overhead within instrumented applications. As a result, traces containing thousands of operations may not be sent to Datadog.
2512
-
2513
- If traces are missing, enable [debug mode](#tracer-settings) to check if messages containing `"Dropping trace. Payload too large"` are logged.
2514
-
2515
- Since debug mode is verbose, Datadog does not recommend leaving this enabled or enabling this in production. Disable it after confirming. You can inspect the [Datadog Agent logs](https://docs.datadoghq.com/agent/guide/agent-log-files/) for similar messages.
2516
-
2517
- If you have confirmed that traces are dropped due to large payloads, then enable the [partial_flush](#tracer-settings) setting to break down large traces into smaller chunks.
2518
-
2519
- ### Stack level too deep
2520
-
2521
- Datadog tracing collects trace data by adding instrumentation into other common libraries (e.g. Rails, Rack, etc.) Some libraries provide APIs to add this instrumentation, but some do not. In order to add instrumentation into libraries lacking an instrumentation API, Datadog uses a technique called "monkey-patching" to modify the code of that library.
2522
-
2523
- In Ruby version 1.9.3 and earlier, "monkey-patching" often involved the use of [`alias_method`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-alias_method), also known as *method rewriting*, to destructively replace existing Ruby methods. However, this practice would often create conflicts & errors if two libraries attempted to "rewrite" the same method. (e.g. two different APM packages trying to instrument the same method.)
2524
-
2525
- In Ruby 2.0, the [`Module#prepend`](https://ruby-doc.org/core-3.0.0/Module.html#method-i-prepend) feature was introduced. This feature avoids destructive method rewriting and allows multiple "monkey patches" on the same method. Consequently, it has become the safest, preferred means to "monkey patch" code.
2526
-
2527
- Datadog instrumentation almost exclusively uses the `Module#prepend` feature to add instrumentation non-destructively. However, some libraries (typically those supporting Ruby < 2.0) still use `alias_method` which can create conflicts with Datadog instrumentation, often resulting in `SystemStackError` or `stack level too deep` errors.
2528
-
2529
- As the implementation of `alias_method` exists within those libraries, Datadog generally cannot fix them. However, some libraries have known workarounds:
2530
-
2531
- * `rack-mini-profiler`: [Net::HTTP stack level too deep errors](https://github.com/MiniProfiler/rack-mini-profiler#nethttp-stack-level-too-deep-errors).
2532
-
2533
- For libraries without a known workaround, consider removing the library using `alias` or `Module#alias_method` or separating libraries into different environments for testing.
2534
-
2535
- For any further questions or to report an occurence of this issue, please [reach out to Datadog support](https://docs.datadoghq.com/help)