ddtrace 0.35.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1018) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +22 -0
  3. data/.gitignore +16 -17
  4. data/CHANGELOG.md +1969 -293
  5. data/CONTRIBUTING.md +3 -7
  6. data/LICENSE-3rdparty.csv +4 -0
  7. data/README.md +5 -0
  8. data/bin/ddtracerb +15 -0
  9. data/ddtrace.gemspec +34 -32
  10. data/docs/0.x-trace.png +0 -0
  11. data/docs/1.0-trace.png +0 -0
  12. data/docs/AutoInstrumentation.md +36 -0
  13. data/docs/Deprecation.md +8 -0
  14. data/docs/DevelopmentGuide.md +73 -9
  15. data/docs/GettingStarted.md +989 -496
  16. data/docs/ProfilingDevelopment.md +110 -0
  17. data/docs/PublicApi.md +14 -0
  18. data/docs/UpgradeGuide.md +736 -0
  19. data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +118 -0
  20. data/ext/ddtrace_profiling_loader/extconf.rb +53 -0
  21. data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +112 -0
  22. data/ext/ddtrace_profiling_native_extension/clock_id.h +4 -0
  23. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +44 -0
  24. data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +14 -0
  25. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +278 -0
  26. data/ext/ddtrace_profiling_native_extension/extconf.rb +176 -0
  27. data/ext/ddtrace_profiling_native_extension/libddprof_helpers.h +13 -0
  28. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +186 -0
  29. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +607 -0
  30. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +33 -0
  31. data/ext/ddtrace_profiling_native_extension/profiling.c +31 -0
  32. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +139 -0
  33. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +28 -0
  34. data/lib/datadog/appsec/assets/blocked.html +4 -0
  35. data/lib/datadog/appsec/assets/waf_rules/README.md +7 -0
  36. data/lib/datadog/appsec/assets/waf_rules/recommended.json +5638 -0
  37. data/lib/datadog/appsec/assets/waf_rules/risky.json +1499 -0
  38. data/lib/datadog/appsec/assets/waf_rules/strict.json +1298 -0
  39. data/lib/datadog/appsec/assets.rb +38 -0
  40. data/lib/datadog/appsec/autoload.rb +16 -0
  41. data/lib/datadog/appsec/configuration/settings.rb +194 -0
  42. data/lib/datadog/appsec/configuration.rb +80 -0
  43. data/lib/datadog/appsec/contrib/auto_instrument.rb +29 -0
  44. data/lib/datadog/appsec/contrib/configuration/settings.rb +20 -0
  45. data/lib/datadog/appsec/contrib/integration.rb +37 -0
  46. data/lib/datadog/appsec/contrib/patcher.rb +12 -0
  47. data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +22 -0
  48. data/lib/datadog/appsec/contrib/rack/ext.rb +15 -0
  49. data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +169 -0
  50. data/lib/datadog/appsec/contrib/rack/integration.rb +49 -0
  51. data/lib/datadog/appsec/contrib/rack/patcher.rb +32 -0
  52. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +87 -0
  53. data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +64 -0
  54. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +64 -0
  55. data/lib/datadog/appsec/contrib/rack/request.rb +58 -0
  56. data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +41 -0
  57. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +112 -0
  58. data/lib/datadog/appsec/contrib/rack/response.rb +24 -0
  59. data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +22 -0
  60. data/lib/datadog/appsec/contrib/rails/ext.rb +15 -0
  61. data/lib/datadog/appsec/contrib/rails/framework.rb +30 -0
  62. data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +81 -0
  63. data/lib/datadog/appsec/contrib/rails/integration.rb +48 -0
  64. data/lib/datadog/appsec/contrib/rails/patcher.rb +158 -0
  65. data/lib/datadog/appsec/contrib/rails/reactive/action.rb +68 -0
  66. data/lib/datadog/appsec/contrib/rails/request.rb +33 -0
  67. data/lib/datadog/appsec/contrib/rails/request_middleware.rb +20 -0
  68. data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +22 -0
  69. data/lib/datadog/appsec/contrib/sinatra/ext.rb +15 -0
  70. data/lib/datadog/appsec/contrib/sinatra/framework.rb +34 -0
  71. data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +124 -0
  72. data/lib/datadog/appsec/contrib/sinatra/integration.rb +48 -0
  73. data/lib/datadog/appsec/contrib/sinatra/patcher.rb +144 -0
  74. data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +63 -0
  75. data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +20 -0
  76. data/lib/datadog/appsec/event.rb +121 -0
  77. data/lib/datadog/appsec/extensions.rb +118 -0
  78. data/lib/datadog/appsec/instrumentation/gateway.rb +44 -0
  79. data/lib/datadog/appsec/processor.rb +164 -0
  80. data/lib/datadog/appsec/rate_limiter.rb +60 -0
  81. data/lib/datadog/appsec/reactive/address_hash.rb +18 -0
  82. data/lib/datadog/appsec/reactive/engine.rb +44 -0
  83. data/lib/datadog/appsec/reactive/operation.rb +51 -0
  84. data/lib/datadog/appsec/reactive/subscriber.rb +18 -0
  85. data/lib/datadog/appsec.rb +23 -0
  86. data/lib/datadog/ci/configuration/components.rb +32 -0
  87. data/lib/datadog/ci/configuration/settings.rb +53 -0
  88. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +33 -0
  89. data/lib/datadog/ci/contrib/cucumber/ext.rb +22 -0
  90. data/lib/datadog/ci/contrib/cucumber/formatter.rb +94 -0
  91. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +28 -0
  92. data/lib/datadog/ci/contrib/cucumber/integration.rb +49 -0
  93. data/lib/datadog/ci/contrib/cucumber/patcher.rb +27 -0
  94. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +33 -0
  95. data/lib/datadog/ci/contrib/rspec/example.rb +70 -0
  96. data/lib/datadog/ci/contrib/rspec/ext.rb +21 -0
  97. data/lib/datadog/ci/contrib/rspec/integration.rb +50 -0
  98. data/lib/datadog/ci/contrib/rspec/patcher.rb +27 -0
  99. data/lib/datadog/ci/ext/app_types.rb +11 -0
  100. data/lib/datadog/ci/ext/environment.rb +503 -0
  101. data/lib/datadog/ci/ext/settings.rb +12 -0
  102. data/lib/datadog/ci/ext/test.rb +37 -0
  103. data/lib/datadog/ci/extensions.rb +19 -0
  104. data/lib/datadog/ci/flush.rb +38 -0
  105. data/lib/datadog/ci/test.rb +83 -0
  106. data/lib/datadog/ci.rb +20 -0
  107. data/lib/datadog/core/buffer/cruby.rb +55 -0
  108. data/lib/datadog/core/buffer/random.rb +134 -0
  109. data/lib/datadog/core/buffer/thread_safe.rb +58 -0
  110. data/lib/datadog/core/chunker.rb +35 -0
  111. data/lib/datadog/core/configuration/agent_settings_resolver.rb +365 -0
  112. data/lib/datadog/core/configuration/base.rb +89 -0
  113. data/lib/datadog/core/configuration/components.rb +411 -0
  114. data/lib/datadog/core/configuration/dependency_resolver.rb +28 -0
  115. data/lib/datadog/core/configuration/option.rb +69 -0
  116. data/lib/datadog/core/configuration/option_definition.rb +126 -0
  117. data/lib/datadog/core/configuration/option_definition_set.rb +22 -0
  118. data/lib/datadog/core/configuration/option_set.rb +10 -0
  119. data/lib/datadog/core/configuration/options.rb +118 -0
  120. data/lib/datadog/core/configuration/settings.rb +618 -0
  121. data/lib/datadog/core/configuration.rb +286 -0
  122. data/lib/datadog/core/diagnostics/environment_logger.rb +283 -0
  123. data/lib/datadog/core/diagnostics/ext.rb +41 -0
  124. data/lib/datadog/core/diagnostics/health.rb +37 -0
  125. data/lib/datadog/core/encoding.rb +76 -0
  126. data/lib/datadog/core/environment/cgroup.rb +55 -0
  127. data/lib/datadog/core/environment/class_count.rb +21 -0
  128. data/lib/datadog/core/environment/container.rb +93 -0
  129. data/lib/datadog/core/environment/ext.rb +46 -0
  130. data/lib/datadog/core/environment/gc.rb +20 -0
  131. data/lib/datadog/core/environment/identity.rb +58 -0
  132. data/lib/datadog/core/environment/socket.rb +24 -0
  133. data/lib/datadog/core/environment/thread_count.rb +20 -0
  134. data/lib/datadog/core/environment/variable_helpers.rb +68 -0
  135. data/lib/datadog/core/environment/vm_cache.rb +47 -0
  136. data/lib/datadog/core/error.rb +101 -0
  137. data/lib/datadog/core/extensions.rb +16 -0
  138. data/lib/datadog/core/git/ext.rb +35 -0
  139. data/lib/datadog/core/logger.rb +46 -0
  140. data/lib/datadog/core/logging/ext.rb +11 -0
  141. data/lib/datadog/core/metrics/client.rb +198 -0
  142. data/lib/datadog/core/metrics/ext.rb +20 -0
  143. data/lib/datadog/core/metrics/helpers.rb +25 -0
  144. data/lib/datadog/core/metrics/logging.rb +44 -0
  145. data/lib/datadog/core/metrics/metric.rb +14 -0
  146. data/lib/datadog/core/metrics/options.rb +50 -0
  147. data/lib/datadog/core/pin.rb +75 -0
  148. data/lib/datadog/core/runtime/ext.rb +28 -0
  149. data/lib/datadog/core/runtime/metrics.rb +126 -0
  150. data/lib/datadog/core/utils/compression.rb +32 -0
  151. data/lib/datadog/core/utils/forking.rb +63 -0
  152. data/lib/datadog/core/utils/object_set.rb +43 -0
  153. data/lib/datadog/core/utils/only_once.rb +44 -0
  154. data/lib/datadog/core/utils/safe_dup.rb +27 -0
  155. data/lib/datadog/core/utils/sequence.rb +21 -0
  156. data/lib/datadog/core/utils/string_table.rb +49 -0
  157. data/lib/datadog/core/utils/time.rb +54 -0
  158. data/lib/datadog/core/utils.rb +115 -0
  159. data/lib/datadog/core/vendor/multipart-post/LICENSE +11 -0
  160. data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +120 -0
  161. data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +61 -0
  162. data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +139 -0
  163. data/lib/datadog/core/vendor/multipart-post/multipart/post/version.rb +13 -0
  164. data/lib/datadog/core/vendor/multipart-post/multipart/post.rb +12 -0
  165. data/lib/datadog/core/vendor/multipart-post/multipart.rb +16 -0
  166. data/lib/datadog/core/vendor/multipart-post/net/http/post/multipart.rb +36 -0
  167. data/lib/datadog/core/worker.rb +24 -0
  168. data/lib/datadog/core/workers/async.rb +182 -0
  169. data/lib/datadog/core/workers/interval_loop.rb +119 -0
  170. data/lib/datadog/core/workers/polling.rb +59 -0
  171. data/lib/datadog/core/workers/queue.rb +44 -0
  172. data/lib/datadog/core/workers/runtime_metrics.rb +62 -0
  173. data/lib/datadog/core.rb +80 -0
  174. data/lib/datadog/kit/enable_core_dumps.rb +50 -0
  175. data/lib/datadog/kit/identity.rb +63 -0
  176. data/lib/datadog/kit.rb +11 -0
  177. data/lib/datadog/opentracer/binary_propagator.rb +26 -0
  178. data/lib/datadog/opentracer/carrier.rb +9 -0
  179. data/lib/datadog/opentracer/distributed_headers.rb +58 -0
  180. data/lib/datadog/opentracer/global_tracer.rb +17 -0
  181. data/lib/datadog/opentracer/propagator.rb +26 -0
  182. data/lib/datadog/opentracer/rack_propagator.rb +72 -0
  183. data/lib/datadog/opentracer/scope.rb +18 -0
  184. data/lib/datadog/opentracer/scope_manager.rb +9 -0
  185. data/lib/datadog/opentracer/span.rb +101 -0
  186. data/lib/datadog/opentracer/span_context.rb +19 -0
  187. data/lib/datadog/opentracer/span_context_factory.rb +27 -0
  188. data/lib/datadog/opentracer/text_map_propagator.rb +87 -0
  189. data/lib/datadog/opentracer/thread_local_scope.rb +34 -0
  190. data/lib/datadog/opentracer/thread_local_scope_manager.rb +43 -0
  191. data/lib/datadog/opentracer/tracer.rb +212 -0
  192. data/lib/datadog/opentracer.rb +24 -0
  193. data/lib/datadog/profiling/backtrace_location.rb +34 -0
  194. data/lib/datadog/profiling/buffer.rb +43 -0
  195. data/lib/datadog/profiling/collectors/code_provenance.rb +114 -0
  196. data/lib/datadog/profiling/collectors/old_stack.rb +298 -0
  197. data/lib/datadog/profiling/collectors/stack.rb +16 -0
  198. data/lib/datadog/profiling/encoding/profile.rb +47 -0
  199. data/lib/datadog/profiling/event.rb +15 -0
  200. data/lib/datadog/profiling/events/stack.rb +82 -0
  201. data/lib/datadog/profiling/exporter.rb +25 -0
  202. data/lib/datadog/profiling/ext/forking.rb +99 -0
  203. data/lib/datadog/profiling/ext.rb +57 -0
  204. data/lib/datadog/profiling/flush.rb +69 -0
  205. data/lib/datadog/profiling/load_native_extension.rb +22 -0
  206. data/lib/datadog/profiling/native_extension.rb +41 -0
  207. data/lib/datadog/profiling/pprof/builder.rb +127 -0
  208. data/lib/datadog/profiling/pprof/converter.rb +104 -0
  209. data/lib/datadog/profiling/pprof/message_set.rb +16 -0
  210. data/lib/datadog/profiling/pprof/payload.rb +20 -0
  211. data/lib/datadog/profiling/pprof/pprof.proto +212 -0
  212. data/lib/datadog/profiling/pprof/pprof_pb.rb +83 -0
  213. data/lib/datadog/profiling/pprof/stack_sample.rb +141 -0
  214. data/lib/datadog/profiling/pprof/string_table.rb +12 -0
  215. data/lib/datadog/profiling/pprof/template.rb +120 -0
  216. data/lib/datadog/profiling/preload.rb +5 -0
  217. data/lib/datadog/profiling/profiler.rb +34 -0
  218. data/lib/datadog/profiling/recorder.rb +117 -0
  219. data/lib/datadog/profiling/scheduler.rb +151 -0
  220. data/lib/datadog/profiling/stack_recorder.rb +33 -0
  221. data/lib/datadog/profiling/tag_builder.rb +48 -0
  222. data/lib/datadog/profiling/tasks/exec.rb +50 -0
  223. data/lib/datadog/profiling/tasks/help.rb +18 -0
  224. data/lib/datadog/profiling/tasks/setup.rb +93 -0
  225. data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +45 -0
  226. data/lib/datadog/profiling/trace_identifiers/helper.rb +47 -0
  227. data/lib/datadog/profiling/transport/client.rb +16 -0
  228. data/lib/datadog/profiling/transport/http/api/endpoint.rb +107 -0
  229. data/lib/datadog/profiling/transport/http/api/instance.rb +38 -0
  230. data/lib/datadog/profiling/transport/http/api/spec.rb +42 -0
  231. data/lib/datadog/profiling/transport/http/api.rb +45 -0
  232. data/lib/datadog/profiling/transport/http/builder.rb +30 -0
  233. data/lib/datadog/profiling/transport/http/client.rb +35 -0
  234. data/lib/datadog/profiling/transport/http/response.rb +23 -0
  235. data/lib/datadog/profiling/transport/http.rb +112 -0
  236. data/lib/datadog/profiling/transport/io/client.rb +29 -0
  237. data/lib/datadog/profiling/transport/io/response.rb +18 -0
  238. data/lib/datadog/profiling/transport/io.rb +32 -0
  239. data/lib/datadog/profiling/transport/parcel.rb +19 -0
  240. data/lib/datadog/profiling/transport/request.rb +17 -0
  241. data/lib/datadog/profiling/transport/response.rb +10 -0
  242. data/lib/datadog/profiling.rb +170 -0
  243. data/lib/datadog/tracing/analytics.rb +25 -0
  244. data/lib/datadog/tracing/buffer.rb +132 -0
  245. data/lib/datadog/tracing/configuration/ext.rb +51 -0
  246. data/lib/datadog/tracing/context.rb +68 -0
  247. data/lib/datadog/tracing/context_provider.rb +66 -0
  248. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +35 -0
  249. data/lib/datadog/tracing/contrib/action_cable/event.rb +72 -0
  250. data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +58 -0
  251. data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +63 -0
  252. data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +59 -0
  253. data/lib/datadog/tracing/contrib/action_cable/events.rb +37 -0
  254. data/lib/datadog/tracing/contrib/action_cable/ext.rb +32 -0
  255. data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +91 -0
  256. data/lib/datadog/tracing/contrib/action_cable/integration.rb +50 -0
  257. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +31 -0
  258. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +36 -0
  259. data/lib/datadog/tracing/contrib/action_mailer/event.rb +52 -0
  260. data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +60 -0
  261. data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +47 -0
  262. data/lib/datadog/tracing/contrib/action_mailer/events.rb +34 -0
  263. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +33 -0
  264. data/lib/datadog/tracing/contrib/action_mailer/integration.rb +50 -0
  265. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +29 -0
  266. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +156 -0
  267. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +29 -0
  268. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +36 -0
  269. data/lib/datadog/tracing/contrib/action_pack/ext.rb +22 -0
  270. data/lib/datadog/tracing/contrib/action_pack/integration.rb +50 -0
  271. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +27 -0
  272. data/lib/datadog/tracing/contrib/action_pack/utils.rb +40 -0
  273. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +36 -0
  274. data/lib/datadog/tracing/contrib/action_view/event.rb +35 -0
  275. data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +54 -0
  276. data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +57 -0
  277. data/lib/datadog/tracing/contrib/action_view/events.rb +34 -0
  278. data/lib/datadog/tracing/contrib/action_view/ext.rb +24 -0
  279. data/lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb +78 -0
  280. data/lib/datadog/tracing/contrib/action_view/instrumentation/template_renderer.rb +91 -0
  281. data/lib/datadog/tracing/contrib/action_view/integration.rb +57 -0
  282. data/lib/datadog/tracing/contrib/action_view/patcher.rb +47 -0
  283. data/lib/datadog/tracing/contrib/action_view/utils.rb +36 -0
  284. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +37 -0
  285. data/lib/datadog/tracing/contrib/active_job/event.rb +58 -0
  286. data/lib/datadog/tracing/contrib/active_job/events/discard.rb +50 -0
  287. data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +49 -0
  288. data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +49 -0
  289. data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +51 -0
  290. data/lib/datadog/tracing/contrib/active_job/events/perform.rb +49 -0
  291. data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +50 -0
  292. data/lib/datadog/tracing/contrib/active_job/events.rb +42 -0
  293. data/lib/datadog/tracing/contrib/active_job/ext.rb +39 -0
  294. data/lib/datadog/tracing/contrib/active_job/integration.rb +50 -0
  295. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +26 -0
  296. data/lib/datadog/tracing/contrib/active_job/patcher.rb +36 -0
  297. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +33 -0
  298. data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +69 -0
  299. data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +45 -0
  300. data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +47 -0
  301. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +34 -0
  302. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +24 -0
  303. data/lib/datadog/tracing/contrib/active_model_serializers/integration.rb +45 -0
  304. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +33 -0
  305. data/lib/datadog/tracing/contrib/active_record/configuration/makara_resolver.rb +36 -0
  306. data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +138 -0
  307. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +39 -0
  308. data/lib/datadog/tracing/contrib/active_record/event.rb +30 -0
  309. data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +58 -0
  310. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +78 -0
  311. data/lib/datadog/tracing/contrib/active_record/events.rb +34 -0
  312. data/lib/datadog/tracing/contrib/active_record/ext.rb +29 -0
  313. data/lib/datadog/tracing/contrib/active_record/integration.rb +56 -0
  314. data/lib/datadog/tracing/contrib/active_record/patcher.rb +27 -0
  315. data/lib/datadog/tracing/contrib/active_record/utils.rb +128 -0
  316. data/lib/datadog/tracing/contrib/active_record/vendor/MIT-LICENSE +20 -0
  317. data/lib/datadog/tracing/contrib/active_record/vendor/connection_specification.rb +307 -0
  318. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +270 -0
  319. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +73 -0
  320. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +47 -0
  321. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +35 -0
  322. data/lib/datadog/tracing/contrib/active_support/ext.rb +31 -0
  323. data/lib/datadog/tracing/contrib/active_support/integration.rb +51 -0
  324. data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +71 -0
  325. data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +71 -0
  326. data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +164 -0
  327. data/lib/datadog/tracing/contrib/active_support/patcher.rb +27 -0
  328. data/lib/datadog/tracing/contrib/analytics.rb +29 -0
  329. data/lib/datadog/tracing/contrib/auto_instrument.rb +53 -0
  330. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +35 -0
  331. data/lib/datadog/tracing/contrib/aws/ext.rb +27 -0
  332. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +95 -0
  333. data/lib/datadog/tracing/contrib/aws/integration.rb +47 -0
  334. data/lib/datadog/tracing/contrib/aws/parsed_context.rb +60 -0
  335. data/lib/datadog/tracing/contrib/aws/patcher.rb +57 -0
  336. data/lib/datadog/tracing/contrib/aws/services.rb +123 -0
  337. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +23 -0
  338. data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +53 -0
  339. data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +16 -0
  340. data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +27 -0
  341. data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +43 -0
  342. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +33 -0
  343. data/lib/datadog/tracing/contrib/configurable.rb +102 -0
  344. data/lib/datadog/tracing/contrib/configuration/resolver.rb +85 -0
  345. data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +43 -0
  346. data/lib/datadog/tracing/contrib/configuration/settings.rb +43 -0
  347. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +35 -0
  348. data/lib/datadog/tracing/contrib/dalli/ext.rb +24 -0
  349. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +58 -0
  350. data/lib/datadog/tracing/contrib/dalli/integration.rb +52 -0
  351. data/lib/datadog/tracing/contrib/dalli/patcher.rb +28 -0
  352. data/lib/datadog/tracing/contrib/dalli/quantize.rb +26 -0
  353. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +38 -0
  354. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +26 -0
  355. data/lib/datadog/tracing/contrib/delayed_job/integration.rb +43 -0
  356. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +31 -0
  357. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +101 -0
  358. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +36 -0
  359. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +26 -0
  360. data/lib/datadog/tracing/contrib/elasticsearch/integration.rb +50 -0
  361. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +151 -0
  362. data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +89 -0
  363. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +37 -0
  364. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +177 -0
  365. data/lib/datadog/tracing/contrib/ethon/ext.rb +24 -0
  366. data/lib/datadog/tracing/contrib/ethon/integration.rb +48 -0
  367. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +96 -0
  368. data/lib/datadog/tracing/contrib/ethon/patcher.rb +31 -0
  369. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +38 -0
  370. data/lib/datadog/tracing/contrib/excon/ext.rb +21 -0
  371. data/lib/datadog/tracing/contrib/excon/integration.rb +48 -0
  372. data/lib/datadog/tracing/contrib/excon/middleware.rb +170 -0
  373. data/lib/datadog/tracing/contrib/excon/patcher.rb +31 -0
  374. data/lib/datadog/tracing/contrib/extensions.rb +197 -0
  375. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +42 -0
  376. data/lib/datadog/tracing/contrib/faraday/connection.rb +22 -0
  377. data/lib/datadog/tracing/contrib/faraday/ext.rb +21 -0
  378. data/lib/datadog/tracing/contrib/faraday/integration.rb +48 -0
  379. data/lib/datadog/tracing/contrib/faraday/middleware.rb +93 -0
  380. data/lib/datadog/tracing/contrib/faraday/patcher.rb +56 -0
  381. data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +22 -0
  382. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +42 -0
  383. data/lib/datadog/tracing/contrib/grape/endpoint.rb +253 -0
  384. data/lib/datadog/tracing/contrib/grape/ext.rb +28 -0
  385. data/lib/datadog/tracing/contrib/grape/instrumentation.rb +37 -0
  386. data/lib/datadog/tracing/contrib/grape/integration.rb +44 -0
  387. data/lib/datadog/tracing/contrib/grape/patcher.rb +33 -0
  388. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +36 -0
  389. data/lib/datadog/tracing/contrib/graphql/ext.rb +19 -0
  390. data/lib/datadog/tracing/contrib/graphql/integration.rb +44 -0
  391. data/lib/datadog/tracing/contrib/graphql/patcher.rb +91 -0
  392. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +37 -0
  393. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +84 -0
  394. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +90 -0
  395. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +104 -0
  396. data/lib/datadog/tracing/contrib/grpc/ext.rb +23 -0
  397. data/lib/datadog/tracing/contrib/grpc/integration.rb +43 -0
  398. data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +53 -0
  399. data/lib/datadog/tracing/contrib/grpc/patcher.rb +37 -0
  400. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +44 -0
  401. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +37 -0
  402. data/lib/datadog/tracing/contrib/http/ext.rb +21 -0
  403. data/lib/datadog/tracing/contrib/http/instrumentation.rb +139 -0
  404. data/lib/datadog/tracing/contrib/http/integration.rb +49 -0
  405. data/lib/datadog/tracing/contrib/http/patcher.rb +30 -0
  406. data/lib/datadog/tracing/contrib/http_annotation_helper.rb +17 -0
  407. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +37 -0
  408. data/lib/datadog/tracing/contrib/httpclient/ext.rb +21 -0
  409. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +117 -0
  410. data/lib/datadog/tracing/contrib/httpclient/integration.rb +48 -0
  411. data/lib/datadog/tracing/contrib/httpclient/patcher.rb +42 -0
  412. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +37 -0
  413. data/lib/datadog/tracing/contrib/httprb/ext.rb +21 -0
  414. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +128 -0
  415. data/lib/datadog/tracing/contrib/httprb/integration.rb +48 -0
  416. data/lib/datadog/tracing/contrib/httprb/patcher.rb +42 -0
  417. data/lib/datadog/tracing/contrib/integration.rb +78 -0
  418. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +35 -0
  419. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +18 -0
  420. data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +18 -0
  421. data/lib/datadog/tracing/contrib/kafka/event.rb +52 -0
  422. data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +42 -0
  423. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +49 -0
  424. data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +47 -0
  425. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +47 -0
  426. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +37 -0
  427. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +37 -0
  428. data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +37 -0
  429. data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +40 -0
  430. data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +43 -0
  431. data/lib/datadog/tracing/contrib/kafka/events.rb +48 -0
  432. data/lib/datadog/tracing/contrib/kafka/ext.rb +52 -0
  433. data/lib/datadog/tracing/contrib/kafka/integration.rb +44 -0
  434. data/lib/datadog/tracing/contrib/kafka/patcher.rb +29 -0
  435. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +23 -0
  436. data/lib/datadog/tracing/contrib/lograge/ext.rb +15 -0
  437. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +47 -0
  438. data/lib/datadog/tracing/contrib/lograge/integration.rb +50 -0
  439. data/lib/datadog/tracing/contrib/lograge/patcher.rb +29 -0
  440. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +38 -0
  441. data/lib/datadog/tracing/contrib/mongodb/ext.rb +27 -0
  442. data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +47 -0
  443. data/lib/datadog/tracing/contrib/mongodb/integration.rb +48 -0
  444. data/lib/datadog/tracing/contrib/mongodb/parsers.rb +49 -0
  445. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +34 -0
  446. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +121 -0
  447. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +35 -0
  448. data/lib/datadog/tracing/contrib/mysql2/ext.rb +22 -0
  449. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +62 -0
  450. data/lib/datadog/tracing/contrib/mysql2/integration.rb +43 -0
  451. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +31 -0
  452. data/lib/datadog/tracing/contrib/patchable.rb +109 -0
  453. data/lib/datadog/tracing/contrib/patcher.rb +74 -0
  454. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +35 -0
  455. data/lib/datadog/tracing/contrib/presto/ext.rb +32 -0
  456. data/lib/datadog/tracing/contrib/presto/instrumentation.rb +125 -0
  457. data/lib/datadog/tracing/contrib/presto/integration.rb +43 -0
  458. data/lib/datadog/tracing/contrib/presto/patcher.rb +37 -0
  459. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +40 -0
  460. data/lib/datadog/tracing/contrib/qless/ext.rb +26 -0
  461. data/lib/datadog/tracing/contrib/qless/integration.rb +43 -0
  462. data/lib/datadog/tracing/contrib/qless/patcher.rb +38 -0
  463. data/lib/datadog/tracing/contrib/qless/qless_job.rb +75 -0
  464. data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +32 -0
  465. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +49 -0
  466. data/lib/datadog/tracing/contrib/que/ext.rb +34 -0
  467. data/lib/datadog/tracing/contrib/que/integration.rb +46 -0
  468. data/lib/datadog/tracing/contrib/que/patcher.rb +28 -0
  469. data/lib/datadog/tracing/contrib/que/tracer.rb +61 -0
  470. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +35 -0
  471. data/lib/datadog/tracing/contrib/racecar/event.rb +79 -0
  472. data/lib/datadog/tracing/contrib/racecar/events/batch.rb +35 -0
  473. data/lib/datadog/tracing/contrib/racecar/events/consume.rb +35 -0
  474. data/lib/datadog/tracing/contrib/racecar/events/message.rb +35 -0
  475. data/lib/datadog/tracing/contrib/racecar/events.rb +36 -0
  476. data/lib/datadog/tracing/contrib/racecar/ext.rb +31 -0
  477. data/lib/datadog/tracing/contrib/racecar/integration.rb +44 -0
  478. data/lib/datadog/tracing/contrib/racecar/patcher.rb +29 -0
  479. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +51 -0
  480. data/lib/datadog/tracing/contrib/rack/ext.rb +25 -0
  481. data/lib/datadog/tracing/contrib/rack/integration.rb +50 -0
  482. data/lib/datadog/tracing/contrib/rack/middlewares.rb +255 -0
  483. data/lib/datadog/tracing/contrib/rack/patcher.rb +109 -0
  484. data/lib/datadog/tracing/contrib/rack/request_queue.rb +48 -0
  485. data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +12 -0
  486. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +71 -0
  487. data/lib/datadog/tracing/contrib/rails/ext.rb +19 -0
  488. data/lib/datadog/tracing/contrib/rails/framework.rb +152 -0
  489. data/lib/datadog/tracing/contrib/rails/integration.rb +49 -0
  490. data/lib/datadog/tracing/contrib/rails/log_injection.rb +34 -0
  491. data/lib/datadog/tracing/contrib/rails/middlewares.rb +47 -0
  492. data/lib/datadog/tracing/contrib/rails/patcher.rb +121 -0
  493. data/lib/datadog/tracing/contrib/rails/railtie.rb +19 -0
  494. data/lib/datadog/tracing/contrib/rails/utils.rb +28 -0
  495. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +36 -0
  496. data/lib/datadog/tracing/contrib/rake/ext.rb +26 -0
  497. data/lib/datadog/tracing/contrib/rake/instrumentation.rb +98 -0
  498. data/lib/datadog/tracing/contrib/rake/integration.rb +43 -0
  499. data/lib/datadog/tracing/contrib/rake/patcher.rb +34 -0
  500. data/lib/datadog/tracing/contrib/redis/configuration/resolver.rb +49 -0
  501. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +40 -0
  502. data/lib/datadog/tracing/contrib/redis/ext.rb +26 -0
  503. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +78 -0
  504. data/lib/datadog/tracing/contrib/redis/integration.rb +47 -0
  505. data/lib/datadog/tracing/contrib/redis/patcher.rb +35 -0
  506. data/lib/datadog/tracing/contrib/redis/quantize.rb +79 -0
  507. data/lib/datadog/tracing/contrib/redis/tags.rb +54 -0
  508. data/lib/datadog/tracing/contrib/redis/vendor/LICENSE +20 -0
  509. data/lib/datadog/tracing/contrib/redis/vendor/resolver.rb +162 -0
  510. data/lib/datadog/tracing/contrib/registerable.rb +50 -0
  511. data/lib/datadog/tracing/contrib/registry.rb +52 -0
  512. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +37 -0
  513. data/lib/datadog/tracing/contrib/resque/ext.rb +21 -0
  514. data/lib/datadog/tracing/contrib/resque/integration.rb +48 -0
  515. data/lib/datadog/tracing/contrib/resque/patcher.rb +29 -0
  516. data/lib/datadog/tracing/contrib/resque/resque_job.rb +103 -0
  517. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +36 -0
  518. data/lib/datadog/tracing/contrib/rest_client/ext.rb +21 -0
  519. data/lib/datadog/tracing/contrib/rest_client/integration.rb +43 -0
  520. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +29 -0
  521. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +105 -0
  522. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +23 -0
  523. data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +15 -0
  524. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +51 -0
  525. data/lib/datadog/tracing/contrib/semantic_logger/integration.rb +52 -0
  526. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +29 -0
  527. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +33 -0
  528. data/lib/datadog/tracing/contrib/sequel/database.rb +60 -0
  529. data/lib/datadog/tracing/contrib/sequel/dataset.rb +65 -0
  530. data/lib/datadog/tracing/contrib/sequel/ext.rb +22 -0
  531. data/lib/datadog/tracing/contrib/sequel/integration.rb +43 -0
  532. data/lib/datadog/tracing/contrib/sequel/patcher.rb +37 -0
  533. data/lib/datadog/tracing/contrib/sequel/utils.rb +87 -0
  534. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +38 -0
  535. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +25 -0
  536. data/lib/datadog/tracing/contrib/shoryuken/integration.rb +44 -0
  537. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +28 -0
  538. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +61 -0
  539. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +53 -0
  540. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +44 -0
  541. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +38 -0
  542. data/lib/datadog/tracing/contrib/sidekiq/integration.rb +53 -0
  543. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +71 -0
  544. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +34 -0
  545. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +34 -0
  546. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_push.rb +33 -0
  547. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +98 -0
  548. data/lib/datadog/tracing/contrib/sidekiq/tracing.rb +44 -0
  549. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +43 -0
  550. data/lib/datadog/tracing/contrib/sinatra/env.rb +66 -0
  551. data/lib/datadog/tracing/contrib/sinatra/ext.rb +32 -0
  552. data/lib/datadog/tracing/contrib/sinatra/framework.rb +118 -0
  553. data/lib/datadog/tracing/contrib/sinatra/headers.rb +35 -0
  554. data/lib/datadog/tracing/contrib/sinatra/integration.rb +43 -0
  555. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +76 -0
  556. data/lib/datadog/tracing/contrib/sinatra/tracer.rb +159 -0
  557. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +123 -0
  558. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +38 -0
  559. data/lib/datadog/tracing/contrib/sneakers/ext.rb +26 -0
  560. data/lib/datadog/tracing/contrib/sneakers/integration.rb +46 -0
  561. data/lib/datadog/tracing/contrib/sneakers/patcher.rb +29 -0
  562. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +58 -0
  563. data/lib/datadog/tracing/contrib/status_code_matcher.rb +75 -0
  564. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +35 -0
  565. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +28 -0
  566. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +27 -0
  567. data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +105 -0
  568. data/lib/datadog/tracing/contrib/sucker_punch/integration.rb +43 -0
  569. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +37 -0
  570. data/lib/datadog/tracing/contrib/utils/database.rb +31 -0
  571. data/lib/datadog/tracing/contrib/utils/quantization/hash.rb +111 -0
  572. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +99 -0
  573. data/lib/datadog/tracing/contrib.rb +76 -0
  574. data/lib/datadog/tracing/correlation.rb +100 -0
  575. data/lib/datadog/tracing/distributed/headers/b3.rb +55 -0
  576. data/lib/datadog/tracing/distributed/headers/b3_single.rb +67 -0
  577. data/lib/datadog/tracing/distributed/headers/datadog.rb +52 -0
  578. data/lib/datadog/tracing/distributed/headers/ext.rb +31 -0
  579. data/lib/datadog/tracing/distributed/helpers.rb +44 -0
  580. data/lib/datadog/tracing/distributed/parser.rb +70 -0
  581. data/lib/datadog/tracing/event.rb +78 -0
  582. data/lib/datadog/tracing/flush.rb +74 -0
  583. data/lib/datadog/tracing/metadata/analytics.rb +26 -0
  584. data/lib/datadog/tracing/metadata/errors.rb +24 -0
  585. data/lib/datadog/tracing/metadata/ext.rb +151 -0
  586. data/lib/datadog/tracing/metadata/tagging.rb +110 -0
  587. data/lib/datadog/tracing/metadata.rb +20 -0
  588. data/lib/datadog/tracing/pipeline/span_filter.rb +42 -0
  589. data/lib/datadog/tracing/pipeline/span_processor.rb +39 -0
  590. data/lib/datadog/tracing/pipeline.rb +65 -0
  591. data/lib/datadog/tracing/propagation/grpc.rb +88 -0
  592. data/lib/datadog/tracing/propagation/http.rb +109 -0
  593. data/lib/datadog/tracing/runtime/metrics.rb +19 -0
  594. data/lib/datadog/tracing/sampling/all_sampler.rb +25 -0
  595. data/lib/datadog/tracing/sampling/ext.rb +27 -0
  596. data/lib/datadog/tracing/sampling/matcher.rb +68 -0
  597. data/lib/datadog/tracing/sampling/priority_sampler.rb +112 -0
  598. data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +97 -0
  599. data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +41 -0
  600. data/lib/datadog/tracing/sampling/rate_limiter.rb +185 -0
  601. data/lib/datadog/tracing/sampling/rate_sampler.rb +55 -0
  602. data/lib/datadog/tracing/sampling/rule.rb +76 -0
  603. data/lib/datadog/tracing/sampling/rule_sampler.rb +131 -0
  604. data/lib/datadog/tracing/sampling/sampler.rb +44 -0
  605. data/lib/datadog/tracing/span.rb +212 -0
  606. data/lib/datadog/tracing/span_operation.rb +520 -0
  607. data/lib/datadog/tracing/sync_writer.rb +69 -0
  608. data/lib/datadog/tracing/trace_digest.rb +60 -0
  609. data/lib/datadog/tracing/trace_operation.rb +431 -0
  610. data/lib/datadog/tracing/trace_segment.rb +207 -0
  611. data/lib/datadog/tracing/tracer.rb +505 -0
  612. data/lib/datadog/tracing/workers/trace_writer.rb +195 -0
  613. data/lib/datadog/tracing/workers.rb +125 -0
  614. data/lib/datadog/tracing/writer.rb +180 -0
  615. data/lib/datadog/tracing.rb +142 -0
  616. data/lib/ddtrace/auto_instrument.rb +9 -0
  617. data/lib/ddtrace/auto_instrument_base.rb +8 -0
  618. data/lib/ddtrace/profiling/preload.rb +4 -0
  619. data/lib/ddtrace/transport/ext.rb +35 -0
  620. data/lib/ddtrace/transport/http/adapters/net.rb +57 -12
  621. data/lib/ddtrace/transport/http/adapters/registry.rb +3 -0
  622. data/lib/ddtrace/transport/http/adapters/test.rb +12 -2
  623. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +30 -15
  624. data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
  625. data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
  626. data/lib/ddtrace/transport/http/api/instance.rb +2 -0
  627. data/lib/ddtrace/transport/http/api/map.rb +2 -0
  628. data/lib/ddtrace/transport/http/api/spec.rb +2 -0
  629. data/lib/ddtrace/transport/http/api.rb +6 -11
  630. data/lib/ddtrace/transport/http/builder.rb +22 -7
  631. data/lib/ddtrace/transport/http/client.rb +5 -1
  632. data/lib/ddtrace/transport/http/env.rb +10 -0
  633. data/lib/ddtrace/transport/http/response.rb +36 -4
  634. data/lib/ddtrace/transport/http/statistics.rb +18 -3
  635. data/lib/ddtrace/transport/http/traces.rb +9 -6
  636. data/lib/ddtrace/transport/http.rb +66 -39
  637. data/lib/ddtrace/transport/io/client.rb +20 -9
  638. data/lib/ddtrace/transport/io/response.rb +3 -3
  639. data/lib/ddtrace/transport/io/traces.rb +12 -2
  640. data/lib/ddtrace/transport/io.rb +5 -3
  641. data/lib/ddtrace/transport/parcel.rb +9 -0
  642. data/lib/ddtrace/transport/request.rb +2 -0
  643. data/lib/ddtrace/transport/response.rb +13 -0
  644. data/lib/ddtrace/transport/serializable_trace.rb +118 -0
  645. data/lib/ddtrace/transport/statistics.rb +7 -4
  646. data/lib/ddtrace/transport/trace_formatter.rb +187 -0
  647. data/lib/ddtrace/transport/traces.rb +43 -10
  648. data/lib/ddtrace/version.rb +20 -5
  649. data/lib/ddtrace.rb +10 -71
  650. metadata +643 -603
  651. data/.circleci/config.yml +0 -490
  652. data/.circleci/images/primary/Dockerfile-2.0.0 +0 -73
  653. data/.circleci/images/primary/Dockerfile-2.1.10 +0 -73
  654. data/.circleci/images/primary/Dockerfile-2.2.10 +0 -73
  655. data/.circleci/images/primary/Dockerfile-2.3.8 +0 -75
  656. data/.circleci/images/primary/Dockerfile-2.4.6 +0 -73
  657. data/.circleci/images/primary/Dockerfile-2.5.6 +0 -73
  658. data/.circleci/images/primary/Dockerfile-2.6.4 +0 -73
  659. data/.circleci/images/primary/Dockerfile-2.7.0 +0 -73
  660. data/.circleci/images/primary/Dockerfile-jruby-9.2 +0 -77
  661. data/.dockerignore +0 -1
  662. data/.env +0 -26
  663. data/.github/CODEOWNERS +0 -1
  664. data/.rspec +0 -1
  665. data/.rubocop.yml +0 -81
  666. data/.yardopts +0 -5
  667. data/Appraisals +0 -944
  668. data/Gemfile +0 -7
  669. data/Rakefile +0 -731
  670. data/benchmarks/postgres_database.yml +0 -9
  671. data/benchmarks/sidekiq_test.rb +0 -154
  672. data/docker-compose.yml +0 -335
  673. data/lib/ddtrace/analytics.rb +0 -36
  674. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  675. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  676. data/lib/ddtrace/augmentation/shim.rb +0 -102
  677. data/lib/ddtrace/augmentation.rb +0 -13
  678. data/lib/ddtrace/buffer.rb +0 -119
  679. data/lib/ddtrace/chunker.rb +0 -34
  680. data/lib/ddtrace/configuration/base.rb +0 -84
  681. data/lib/ddtrace/configuration/components.rb +0 -154
  682. data/lib/ddtrace/configuration/dependency_resolver.rb +0 -24
  683. data/lib/ddtrace/configuration/option.rb +0 -64
  684. data/lib/ddtrace/configuration/option_definition.rb +0 -123
  685. data/lib/ddtrace/configuration/option_definition_set.rb +0 -18
  686. data/lib/ddtrace/configuration/option_set.rb +0 -6
  687. data/lib/ddtrace/configuration/options.rb +0 -112
  688. data/lib/ddtrace/configuration/pin_setup.rb +0 -30
  689. data/lib/ddtrace/configuration/settings.rb +0 -255
  690. data/lib/ddtrace/configuration.rb +0 -53
  691. data/lib/ddtrace/context.rb +0 -305
  692. data/lib/ddtrace/context_flush.rb +0 -69
  693. data/lib/ddtrace/context_provider.rb +0 -50
  694. data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +0 -25
  695. data/lib/ddtrace/contrib/action_cable/event.rb +0 -65
  696. data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +0 -49
  697. data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +0 -55
  698. data/lib/ddtrace/contrib/action_cable/events/transmit.rb +0 -50
  699. data/lib/ddtrace/contrib/action_cable/events.rb +0 -33
  700. data/lib/ddtrace/contrib/action_cable/ext.rb +0 -23
  701. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +0 -31
  702. data/lib/ddtrace/contrib/action_cable/integration.rb +0 -38
  703. data/lib/ddtrace/contrib/action_cable/patcher.rb +0 -27
  704. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +0 -148
  705. data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +0 -25
  706. data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +0 -27
  707. data/lib/ddtrace/contrib/action_pack/ext.rb +0 -16
  708. data/lib/ddtrace/contrib/action_pack/integration.rb +0 -38
  709. data/lib/ddtrace/contrib/action_pack/patcher.rb +0 -23
  710. data/lib/ddtrace/contrib/action_pack/utils.rb +0 -36
  711. data/lib/ddtrace/contrib/action_view/configuration/settings.rb +0 -26
  712. data/lib/ddtrace/contrib/action_view/event.rb +0 -39
  713. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +0 -45
  714. data/lib/ddtrace/contrib/action_view/events/render_template.rb +0 -48
  715. data/lib/ddtrace/contrib/action_view/events.rb +0 -30
  716. data/lib/ddtrace/contrib/action_view/ext.rb +0 -17
  717. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +0 -74
  718. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +0 -167
  719. data/lib/ddtrace/contrib/action_view/integration.rb +0 -45
  720. data/lib/ddtrace/contrib/action_view/patcher.rb +0 -47
  721. data/lib/ddtrace/contrib/action_view/utils.rb +0 -32
  722. data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +0 -25
  723. data/lib/ddtrace/contrib/active_model_serializers/event.rb +0 -68
  724. data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +0 -32
  725. data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +0 -35
  726. data/lib/ddtrace/contrib/active_model_serializers/events.rb +0 -30
  727. data/lib/ddtrace/contrib/active_model_serializers/ext.rb +0 -17
  728. data/lib/ddtrace/contrib/active_model_serializers/integration.rb +0 -40
  729. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +0 -29
  730. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +0 -45
  731. data/lib/ddtrace/contrib/active_record/configuration/settings.rb +0 -30
  732. data/lib/ddtrace/contrib/active_record/event.rb +0 -30
  733. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +0 -60
  734. data/lib/ddtrace/contrib/active_record/events/sql.rb +0 -64
  735. data/lib/ddtrace/contrib/active_record/events.rb +0 -30
  736. data/lib/ddtrace/contrib/active_record/ext.rb +0 -21
  737. data/lib/ddtrace/contrib/active_record/integration.rb +0 -46
  738. data/lib/ddtrace/contrib/active_record/patcher.rb +0 -23
  739. data/lib/ddtrace/contrib/active_record/utils.rb +0 -76
  740. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +0 -157
  741. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +0 -48
  742. data/lib/ddtrace/contrib/active_support/cache/redis.rb +0 -47
  743. data/lib/ddtrace/contrib/active_support/configuration/settings.rb +0 -25
  744. data/lib/ddtrace/contrib/active_support/ext.rb +0 -21
  745. data/lib/ddtrace/contrib/active_support/integration.rb +0 -40
  746. data/lib/ddtrace/contrib/active_support/notifications/event.rb +0 -62
  747. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +0 -66
  748. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +0 -159
  749. data/lib/ddtrace/contrib/active_support/patcher.rb +0 -23
  750. data/lib/ddtrace/contrib/analytics.rb +0 -24
  751. data/lib/ddtrace/contrib/aws/configuration/settings.rb +0 -25
  752. data/lib/ddtrace/contrib/aws/ext.rb +0 -20
  753. data/lib/ddtrace/contrib/aws/instrumentation.rb +0 -56
  754. data/lib/ddtrace/contrib/aws/integration.rb +0 -42
  755. data/lib/ddtrace/contrib/aws/parsed_context.rb +0 -56
  756. data/lib/ddtrace/contrib/aws/patcher.rb +0 -49
  757. data/lib/ddtrace/contrib/aws/services.rb +0 -115
  758. data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +0 -15
  759. data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +0 -35
  760. data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +0 -11
  761. data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +0 -23
  762. data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +0 -38
  763. data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +0 -28
  764. data/lib/ddtrace/contrib/configurable.rb +0 -76
  765. data/lib/ddtrace/contrib/configuration/resolver.rb +0 -16
  766. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +0 -39
  767. data/lib/ddtrace/contrib/configuration/settings.rb +0 -35
  768. data/lib/ddtrace/contrib/dalli/configuration/settings.rb +0 -25
  769. data/lib/ddtrace/contrib/dalli/ext.rb +0 -17
  770. data/lib/ddtrace/contrib/dalli/instrumentation.rb +0 -50
  771. data/lib/ddtrace/contrib/dalli/integration.rb +0 -38
  772. data/lib/ddtrace/contrib/dalli/patcher.rb +0 -67
  773. data/lib/ddtrace/contrib/dalli/quantize.rb +0 -22
  774. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +0 -25
  775. data/lib/ddtrace/contrib/delayed_job/ext.rb +0 -18
  776. data/lib/ddtrace/contrib/delayed_job/integration.rb +0 -38
  777. data/lib/ddtrace/contrib/delayed_job/patcher.rb +0 -28
  778. data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -61
  779. data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +0 -26
  780. data/lib/ddtrace/contrib/elasticsearch/ext.rb +0 -19
  781. data/lib/ddtrace/contrib/elasticsearch/integration.rb +0 -39
  782. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +0 -118
  783. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +0 -80
  784. data/lib/ddtrace/contrib/ethon/configuration/settings.rb +0 -27
  785. data/lib/ddtrace/contrib/ethon/easy_patch.rb +0 -148
  786. data/lib/ddtrace/contrib/ethon/ext.rb +0 -15
  787. data/lib/ddtrace/contrib/ethon/integration.rb +0 -43
  788. data/lib/ddtrace/contrib/ethon/multi_patch.rb +0 -80
  789. data/lib/ddtrace/contrib/ethon/patcher.rb +0 -25
  790. data/lib/ddtrace/contrib/excon/configuration/settings.rb +0 -28
  791. data/lib/ddtrace/contrib/excon/ext.rb +0 -14
  792. data/lib/ddtrace/contrib/excon/integration.rb +0 -43
  793. data/lib/ddtrace/contrib/excon/middleware.rb +0 -157
  794. data/lib/ddtrace/contrib/excon/patcher.rb +0 -27
  795. data/lib/ddtrace/contrib/extensions.rb +0 -59
  796. data/lib/ddtrace/contrib/faraday/configuration/settings.rb +0 -33
  797. data/lib/ddtrace/contrib/faraday/connection.rb +0 -18
  798. data/lib/ddtrace/contrib/faraday/ext.rb +0 -14
  799. data/lib/ddtrace/contrib/faraday/integration.rb +0 -43
  800. data/lib/ddtrace/contrib/faraday/middleware.rb +0 -81
  801. data/lib/ddtrace/contrib/faraday/patcher.rb +0 -81
  802. data/lib/ddtrace/contrib/faraday/rack_builder.rb +0 -18
  803. data/lib/ddtrace/contrib/grape/configuration/settings.rb +0 -27
  804. data/lib/ddtrace/contrib/grape/endpoint.rb +0 -208
  805. data/lib/ddtrace/contrib/grape/ext.rb +0 -19
  806. data/lib/ddtrace/contrib/grape/instrumentation.rb +0 -33
  807. data/lib/ddtrace/contrib/grape/integration.rb +0 -39
  808. data/lib/ddtrace/contrib/grape/patcher.rb +0 -73
  809. data/lib/ddtrace/contrib/graphql/configuration/settings.rb +0 -27
  810. data/lib/ddtrace/contrib/graphql/ext.rb +0 -13
  811. data/lib/ddtrace/contrib/graphql/integration.rb +0 -39
  812. data/lib/ddtrace/contrib/graphql/patcher.rb +0 -57
  813. data/lib/ddtrace/contrib/grpc/configuration/settings.rb +0 -25
  814. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +0 -56
  815. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +0 -76
  816. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +0 -74
  817. data/lib/ddtrace/contrib/grpc/ext.rb +0 -15
  818. data/lib/ddtrace/contrib/grpc/integration.rb +0 -38
  819. data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +0 -49
  820. data/lib/ddtrace/contrib/grpc/patcher.rb +0 -72
  821. data/lib/ddtrace/contrib/http/circuit_breaker.rb +0 -39
  822. data/lib/ddtrace/contrib/http/configuration/settings.rb +0 -27
  823. data/lib/ddtrace/contrib/http/ext.rb +0 -14
  824. data/lib/ddtrace/contrib/http/instrumentation.rb +0 -170
  825. data/lib/ddtrace/contrib/http/integration.rb +0 -45
  826. data/lib/ddtrace/contrib/http/patcher.rb +0 -26
  827. data/lib/ddtrace/contrib/http_annotation_helper.rb +0 -10
  828. data/lib/ddtrace/contrib/integration.rb +0 -16
  829. data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +0 -28
  830. data/lib/ddtrace/contrib/mongodb/ext.rb +0 -20
  831. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +0 -68
  832. data/lib/ddtrace/contrib/mongodb/integration.rb +0 -38
  833. data/lib/ddtrace/contrib/mongodb/parsers.rb +0 -68
  834. data/lib/ddtrace/contrib/mongodb/patcher.rb +0 -31
  835. data/lib/ddtrace/contrib/mongodb/subscribers.rb +0 -108
  836. data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +0 -25
  837. data/lib/ddtrace/contrib/mysql2/ext.rb +0 -15
  838. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +0 -60
  839. data/lib/ddtrace/contrib/mysql2/integration.rb +0 -38
  840. data/lib/ddtrace/contrib/mysql2/patcher.rb +0 -27
  841. data/lib/ddtrace/contrib/patchable.rb +0 -59
  842. data/lib/ddtrace/contrib/patcher.rb +0 -56
  843. data/lib/ddtrace/contrib/presto/configuration/settings.rb +0 -25
  844. data/lib/ddtrace/contrib/presto/ext.rb +0 -25
  845. data/lib/ddtrace/contrib/presto/instrumentation.rb +0 -107
  846. data/lib/ddtrace/contrib/presto/integration.rb +0 -38
  847. data/lib/ddtrace/contrib/presto/patcher.rb +0 -30
  848. data/lib/ddtrace/contrib/racecar/configuration/settings.rb +0 -25
  849. data/lib/ddtrace/contrib/racecar/event.rb +0 -71
  850. data/lib/ddtrace/contrib/racecar/events/batch.rb +0 -27
  851. data/lib/ddtrace/contrib/racecar/events/message.rb +0 -27
  852. data/lib/ddtrace/contrib/racecar/events.rb +0 -30
  853. data/lib/ddtrace/contrib/racecar/ext.rb +0 -21
  854. data/lib/ddtrace/contrib/racecar/integration.rb +0 -39
  855. data/lib/ddtrace/contrib/racecar/patcher.rb +0 -26
  856. data/lib/ddtrace/contrib/rack/configuration/settings.rb +0 -41
  857. data/lib/ddtrace/contrib/rack/ext.rb +0 -18
  858. data/lib/ddtrace/contrib/rack/integration.rb +0 -38
  859. data/lib/ddtrace/contrib/rack/middlewares.rb +0 -287
  860. data/lib/ddtrace/contrib/rack/patcher.rb +0 -107
  861. data/lib/ddtrace/contrib/rack/request_queue.rb +0 -39
  862. data/lib/ddtrace/contrib/rails/configuration/settings.rb +0 -94
  863. data/lib/ddtrace/contrib/rails/ext.rb +0 -13
  864. data/lib/ddtrace/contrib/rails/framework.rb +0 -118
  865. data/lib/ddtrace/contrib/rails/integration.rb +0 -44
  866. data/lib/ddtrace/contrib/rails/middlewares.rb +0 -38
  867. data/lib/ddtrace/contrib/rails/patcher.rb +0 -74
  868. data/lib/ddtrace/contrib/rails/railtie.rb +0 -17
  869. data/lib/ddtrace/contrib/rails/utils.rb +0 -20
  870. data/lib/ddtrace/contrib/rake/configuration/settings.rb +0 -27
  871. data/lib/ddtrace/contrib/rake/ext.rb +0 -18
  872. data/lib/ddtrace/contrib/rake/instrumentation.rb +0 -88
  873. data/lib/ddtrace/contrib/rake/integration.rb +0 -38
  874. data/lib/ddtrace/contrib/rake/patcher.rb +0 -30
  875. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +0 -36
  876. data/lib/ddtrace/contrib/redis/configuration/settings.rb +0 -25
  877. data/lib/ddtrace/contrib/redis/ext.rb +0 -18
  878. data/lib/ddtrace/contrib/redis/integration.rb +0 -42
  879. data/lib/ddtrace/contrib/redis/patcher.rb +0 -97
  880. data/lib/ddtrace/contrib/redis/quantize.rb +0 -47
  881. data/lib/ddtrace/contrib/redis/tags.rb +0 -38
  882. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +0 -159
  883. data/lib/ddtrace/contrib/registerable.rb +0 -33
  884. data/lib/ddtrace/contrib/registry.rb +0 -42
  885. data/lib/ddtrace/contrib/resque/configuration/settings.rb +0 -26
  886. data/lib/ddtrace/contrib/resque/ext.rb +0 -14
  887. data/lib/ddtrace/contrib/resque/integration.rb +0 -47
  888. data/lib/ddtrace/contrib/resque/patcher.rb +0 -29
  889. data/lib/ddtrace/contrib/resque/resque_job.rb +0 -80
  890. data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +0 -26
  891. data/lib/ddtrace/contrib/rest_client/ext.rb +0 -14
  892. data/lib/ddtrace/contrib/rest_client/integration.rb +0 -38
  893. data/lib/ddtrace/contrib/rest_client/patcher.rb +0 -23
  894. data/lib/ddtrace/contrib/rest_client/request_patch.rb +0 -89
  895. data/lib/ddtrace/contrib/sequel/configuration/settings.rb +0 -23
  896. data/lib/ddtrace/contrib/sequel/database.rb +0 -61
  897. data/lib/ddtrace/contrib/sequel/dataset.rb +0 -62
  898. data/lib/ddtrace/contrib/sequel/ext.rb +0 -15
  899. data/lib/ddtrace/contrib/sequel/integration.rb +0 -38
  900. data/lib/ddtrace/contrib/sequel/patcher.rb +0 -33
  901. data/lib/ddtrace/contrib/sequel/utils.rb +0 -46
  902. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +0 -24
  903. data/lib/ddtrace/contrib/shoryuken/ext.rb +0 -18
  904. data/lib/ddtrace/contrib/shoryuken/integration.rb +0 -39
  905. data/lib/ddtrace/contrib/shoryuken/patcher.rb +0 -24
  906. data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -49
  907. data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +0 -43
  908. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +0 -31
  909. data/lib/ddtrace/contrib/sidekiq/ext.rb +0 -23
  910. data/lib/ddtrace/contrib/sidekiq/integration.rb +0 -38
  911. data/lib/ddtrace/contrib/sidekiq/patcher.rb +0 -34
  912. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +0 -66
  913. data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -45
  914. data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +0 -34
  915. data/lib/ddtrace/contrib/sinatra/env.rb +0 -58
  916. data/lib/ddtrace/contrib/sinatra/ext.rb +0 -24
  917. data/lib/ddtrace/contrib/sinatra/headers.rb +0 -31
  918. data/lib/ddtrace/contrib/sinatra/integration.rb +0 -38
  919. data/lib/ddtrace/contrib/sinatra/patcher.rb +0 -28
  920. data/lib/ddtrace/contrib/sinatra/tracer.rb +0 -150
  921. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +0 -78
  922. data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +0 -25
  923. data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +0 -26
  924. data/lib/ddtrace/contrib/sucker_punch/ext.rb +0 -18
  925. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +0 -84
  926. data/lib/ddtrace/contrib/sucker_punch/integration.rb +0 -38
  927. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +0 -42
  928. data/lib/ddtrace/correlation.rb +0 -38
  929. data/lib/ddtrace/diagnostics/health.rb +0 -33
  930. data/lib/ddtrace/distributed_tracing/headers/b3.rb +0 -44
  931. data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +0 -56
  932. data/lib/ddtrace/distributed_tracing/headers/datadog.rb +0 -42
  933. data/lib/ddtrace/distributed_tracing/headers/headers.rb +0 -70
  934. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +0 -45
  935. data/lib/ddtrace/encoding.rb +0 -69
  936. data/lib/ddtrace/environment.rb +0 -27
  937. data/lib/ddtrace/error.rb +0 -27
  938. data/lib/ddtrace/event.rb +0 -52
  939. data/lib/ddtrace/ext/analytics.rb +0 -12
  940. data/lib/ddtrace/ext/app_types.rb +0 -11
  941. data/lib/ddtrace/ext/correlation.rb +0 -11
  942. data/lib/ddtrace/ext/diagnostics.rb +0 -33
  943. data/lib/ddtrace/ext/distributed.rb +0 -33
  944. data/lib/ddtrace/ext/environment.rb +0 -14
  945. data/lib/ddtrace/ext/errors.rb +0 -10
  946. data/lib/ddtrace/ext/forced_tracing.rb +0 -25
  947. data/lib/ddtrace/ext/http.rb +0 -46
  948. data/lib/ddtrace/ext/manual_tracing.rb +0 -9
  949. data/lib/ddtrace/ext/metrics.rb +0 -15
  950. data/lib/ddtrace/ext/net.rb +0 -10
  951. data/lib/ddtrace/ext/priority.rb +0 -16
  952. data/lib/ddtrace/ext/runtime.rb +0 -26
  953. data/lib/ddtrace/ext/sampling.rb +0 -16
  954. data/lib/ddtrace/ext/sql.rb +0 -8
  955. data/lib/ddtrace/ext/transport.rb +0 -17
  956. data/lib/ddtrace/forced_tracing.rb +0 -36
  957. data/lib/ddtrace/logger.rb +0 -40
  958. data/lib/ddtrace/metrics.rb +0 -222
  959. data/lib/ddtrace/monkey.rb +0 -58
  960. data/lib/ddtrace/opentelemetry/extensions.rb +0 -13
  961. data/lib/ddtrace/opentelemetry/span.rb +0 -33
  962. data/lib/ddtrace/opentracer/binary_propagator.rb +0 -24
  963. data/lib/ddtrace/opentracer/carrier.rb +0 -6
  964. data/lib/ddtrace/opentracer/distributed_headers.rb +0 -52
  965. data/lib/ddtrace/opentracer/global_tracer.rb +0 -15
  966. data/lib/ddtrace/opentracer/propagator.rb +0 -22
  967. data/lib/ddtrace/opentracer/rack_propagator.rb +0 -60
  968. data/lib/ddtrace/opentracer/scope.rb +0 -15
  969. data/lib/ddtrace/opentracer/scope_manager.rb +0 -6
  970. data/lib/ddtrace/opentracer/span.rb +0 -98
  971. data/lib/ddtrace/opentracer/span_context.rb +0 -14
  972. data/lib/ddtrace/opentracer/span_context_factory.rb +0 -23
  973. data/lib/ddtrace/opentracer/text_map_propagator.rb +0 -75
  974. data/lib/ddtrace/opentracer/thread_local_scope.rb +0 -30
  975. data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +0 -40
  976. data/lib/ddtrace/opentracer/tracer.rb +0 -208
  977. data/lib/ddtrace/opentracer.rb +0 -40
  978. data/lib/ddtrace/patcher.rb +0 -47
  979. data/lib/ddtrace/pin.rb +0 -114
  980. data/lib/ddtrace/pipeline/span_filter.rb +0 -38
  981. data/lib/ddtrace/pipeline/span_processor.rb +0 -20
  982. data/lib/ddtrace/pipeline.rb +0 -46
  983. data/lib/ddtrace/propagation/grpc_propagator.rb +0 -61
  984. data/lib/ddtrace/propagation/http_propagator.rb +0 -75
  985. data/lib/ddtrace/quantization/hash.rb +0 -103
  986. data/lib/ddtrace/quantization/http.rb +0 -86
  987. data/lib/ddtrace/runtime/cgroup.rb +0 -44
  988. data/lib/ddtrace/runtime/class_count.rb +0 -17
  989. data/lib/ddtrace/runtime/container.rb +0 -73
  990. data/lib/ddtrace/runtime/gc.rb +0 -16
  991. data/lib/ddtrace/runtime/identity.rb +0 -41
  992. data/lib/ddtrace/runtime/metrics.rb +0 -96
  993. data/lib/ddtrace/runtime/object_space.rb +0 -19
  994. data/lib/ddtrace/runtime/socket.rb +0 -14
  995. data/lib/ddtrace/runtime/thread_count.rb +0 -16
  996. data/lib/ddtrace/sampler.rb +0 -290
  997. data/lib/ddtrace/sampling/matcher.rb +0 -57
  998. data/lib/ddtrace/sampling/rate_limiter.rb +0 -127
  999. data/lib/ddtrace/sampling/rule.rb +0 -61
  1000. data/lib/ddtrace/sampling/rule_sampler.rb +0 -125
  1001. data/lib/ddtrace/sampling.rb +0 -2
  1002. data/lib/ddtrace/span.rb +0 -297
  1003. data/lib/ddtrace/sync_writer.rb +0 -67
  1004. data/lib/ddtrace/tracer.rb +0 -432
  1005. data/lib/ddtrace/utils/database.rb +0 -25
  1006. data/lib/ddtrace/utils/time.rb +0 -14
  1007. data/lib/ddtrace/utils.rb +0 -65
  1008. data/lib/ddtrace/vendor/active_record/connection_specification.rb +0 -301
  1009. data/lib/ddtrace/worker.rb +0 -20
  1010. data/lib/ddtrace/workers/async.rb +0 -165
  1011. data/lib/ddtrace/workers/loop.rb +0 -105
  1012. data/lib/ddtrace/workers/polling.rb +0 -48
  1013. data/lib/ddtrace/workers/queue.rb +0 -39
  1014. data/lib/ddtrace/workers/runtime_metrics.rb +0 -47
  1015. data/lib/ddtrace/workers/trace_writer.rb +0 -199
  1016. data/lib/ddtrace/workers.rb +0 -117
  1017. data/lib/ddtrace/writer.rb +0 -154
  1018. data/tasks/release_gem.rake +0 -28
@@ -1,3 +1,5 @@
1
+ ***Version 1.0.0 has been released. Check out our [upgrade guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#from-0x-to-10) for more details.***
2
+
1
3
  # Datadog Ruby Trace Client
2
4
 
3
5
  `ddtrace` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
@@ -9,6 +11,8 @@ For the general APM documentation, see our [setup documentation][setup docs].
9
11
 
10
12
  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
13
 
14
+ For the library API documentation, see our [YARD documentation][yard docs].
15
+
12
16
  To contribute, check out the [contribution guidelines][contribution docs] and [development guide][development docs].
13
17
 
14
18
  [setup docs]: https://docs.datadoghq.com/tracing/
@@ -16,24 +20,32 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
16
20
  [visualization docs]: https://docs.datadoghq.com/tracing/visualization/
17
21
  [contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
18
22
  [development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
23
+ [yard docs]: https://www.rubydoc.info/gems/ddtrace/
19
24
 
20
25
  ## Table of Contents
21
26
 
22
27
  - [Compatibility](#compatibility)
23
28
  - [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)
29
+ - [Setup the Datadog Agent for tracing](#setup-the-datadog-agent-for-tracing)
30
+ - [Instrument your application](#instrument-your-application)
31
+ - [Rails applications](#rails-applications)
32
+ - [Ruby applications](#ruby-applications)
33
+ - [Configuring OpenTracing](#configuring-opentracing)
34
+ - [Configuring OpenTelemetry](#configuring-opentelemetry)
35
+ - [Connect your application to the Datadog Agent](#connect-your-application-to-the-datadog-agent)
27
36
  - [Manual instrumentation](#manual-instrumentation)
28
37
  - [Integration instrumentation](#integration-instrumentation)
29
38
  - [Action Cable](#action-cable)
39
+ - [Action Mailer](#action-mailer)
40
+ - [Action Pack](#action-pack)
30
41
  - [Action View](#action-view)
42
+ - [Active Job](#active-job)
31
43
  - [Active Model Serializers](#active-model-serializers)
32
- - [Action Pack](#action-pack)
33
44
  - [Active Record](#active-record)
34
45
  - [Active Support](#active-support)
35
46
  - [AWS](#aws)
36
47
  - [Concurrent Ruby](#concurrent-ruby)
48
+ - [Cucumber](#cucumber)
37
49
  - [Dalli](#dalli)
38
50
  - [DelayedJob](#delayedjob)
39
51
  - [Elasticsearch](#elasticsearch)
@@ -43,27 +55,36 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
43
55
  - [Grape](#grape)
44
56
  - [GraphQL](#graphql)
45
57
  - [gRPC](#grpc)
58
+ - [http.rb](#httprb)
59
+ - [httpclient](#httpclient)
60
+ - [httpx](#httpx)
61
+ - [Kafka](#kafka)
46
62
  - [MongoDB](#mongodb)
47
63
  - [MySQL2](#mysql2)
48
- - [Net/HTTP](#net-http)
64
+ - [Net/HTTP](#nethttp)
49
65
  - [Presto](#presto)
66
+ - [Qless](#qless)
67
+ - [Que](#que)
50
68
  - [Racecar](#racecar)
51
69
  - [Rack](#rack)
52
70
  - [Rails](#rails)
53
71
  - [Rake](#rake)
54
72
  - [Redis](#redis)
55
- - [Rest Client](#rest-client)
56
73
  - [Resque](#resque)
57
- - [Shoryuken](#shoryuken)
74
+ - [Rest Client](#rest-client)
75
+ - [RSpec](#rspec)
58
76
  - [Sequel](#sequel)
77
+ - [Shoryuken](#shoryuken)
59
78
  - [Sidekiq](#sidekiq)
60
79
  - [Sinatra](#sinatra)
80
+ - [Sneakers](#sneakers)
61
81
  - [Sucker Punch](#sucker-punch)
62
- - [Advanced configuration](#advanced-configuration)
63
- - [Tracer settings](#tracer-settings)
82
+ - [Additional configuration](#additional-configuration)
64
83
  - [Custom logging](#custom-logging)
65
84
  - [Environment and tags](#environment-and-tags)
85
+ - [Debugging and diagnostics](#debugging-and-diagnostics)
66
86
  - [Sampling](#sampling)
87
+ - [Application-side sampling](#application-side-sampling)
67
88
  - [Priority sampling](#priority-sampling)
68
89
  - [Distributed tracing](#distributed-tracing)
69
90
  - [HTTP request queuing](#http-request-queuing)
@@ -75,24 +96,39 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
75
96
  - [Metrics](#metrics)
76
97
  - [For application runtime](#for-application-runtime)
77
98
  - [OpenTracing](#opentracing)
99
+ - [Profiling](#profiling)
100
+ - [Troubleshooting](#troubleshooting)
101
+ - [Profiling Resque jobs](#profiling-resque-jobs)
102
+ - [Known issues and suggested configurations](#known-issues-and-suggested-configurations)
103
+ - [Payload too large](#payload-too-large)
104
+ - [Stack level too deep](#stack-level-too-deep)
78
105
 
79
106
  ## Compatibility
80
107
 
108
+ <!--
109
+ Note: Please replicate any changes to this section also to
110
+ https://github.com/datadog/documentation/blob/master/content/en/tracing/setup_overview/compatibility_requirements/ruby.md
111
+ so that they remain in sync.
112
+ -->
113
+
81
114
  **Supported Ruby interpreters**:
82
115
 
83
116
  | Type | Documentation | Version | Support type | Gem version support |
84
117
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
85
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
118
+ | MRI | https://www.ruby-lang.org/ | 3.1 | Full | Latest |
119
+ | | | 3.0 | Full | Latest |
120
+ | | | 2.7 | Full | Latest |
86
121
  | | | 2.6 | Full | Latest |
87
122
  | | | 2.5 | Full | Latest |
88
123
  | | | 2.4 | Full | Latest |
89
124
  | | | 2.3 | Full | Latest |
90
125
  | | | 2.2 | Full | Latest |
91
126
  | | | 2.1 | Full | Latest |
92
- | | | 2.0 | Full | Latest |
93
- | | | 1.9.3 | Maintenance (until August 6th, 2020) | < 0.27.0 |
94
- | | | 1.9.1 | Maintenance (until August 6th, 2020) | < 0.27.0 |
95
- | JRuby | http://jruby.org/ | 9.2.0.0 | Alpha | Latest |
127
+ | | | 2.0 | EOL since June 7th, 2021 | < 0.50.0 |
128
+ | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
129
+ | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
130
+ | JRuby | https://www.jruby.org | 9.3 | Full | Latest |
131
+ | | | 9.2 | Full | Latest |
96
132
 
97
133
  **Supported web servers**:
98
134
 
@@ -116,70 +152,152 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
116
152
 
117
153
  *EOL* indicates support is no longer provided.
118
154
 
155
+ ### Apple macOS support
156
+
157
+ Use of `ddtrace` on macOS is supported for development, but not for production deployments.
158
+
159
+ ### Microsoft Windows support
160
+
161
+ Using `ddtrace` on Microsoft Windows is currently unsupported. We'll still accept community contributions and issues,
162
+ but will consider them as having low priority.
163
+
119
164
  ## Installation
120
165
 
121
- The following steps will help you quickly start tracing your Ruby application.
166
+ Adding tracing to your Ruby application only takes a few quick steps:
167
+
168
+ 1. Setup the Datadog Agent for tracing
169
+ 2. Instrument your application
170
+ 3. Connect your application to the Datadog Agent
171
+
172
+ ### Setup the Datadog Agent for tracing
173
+
174
+ Before installing `ddtrace`, [install the Datadog Agent](https://docs.datadoghq.com/agent/), to which `ddtrace` will send trace data.
175
+
176
+ Then configure the Datadog Agent to accept traces. To do this, either:
177
+
178
+ - Set `DD_APM_ENABLED=true` in the agent's environment
179
+
180
+ OR
181
+
182
+ - Add `apm_enabled: true` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
183
+
184
+ *Additionally, in containerized environments...*
185
+
186
+ - Set `DD_APM_NON_LOCAL_TRAFFIC=true` in the agent's environment
187
+
188
+ OR
189
+
190
+ - Add `apm_non_local_traffic: true` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file).
191
+
192
+ 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.
193
+
194
+ #### Configuring trace data ingestion
195
+
196
+ The Datadog agent will listen for traces via HTTP on port `8126` by default.
197
+
198
+ You may change the protocol or port the agent listens for trace data using the following:
199
+
200
+ **For HTTP over TCP**:
201
+
202
+ - Set `DD_APM_RECEIVER_PORT=<port>` in the agent's environment
122
203
 
123
- ### Setup the Datadog Agent
204
+ OR
124
205
 
125
- Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
206
+ - Add `apm_config: receiver_port: <port>` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
126
207
 
127
- [Install and configure the Datadog Agent](https://docs.datadoghq.com/tracing/setup), see additional documentation for [tracing Docker applications](https://docs.datadoghq.com/tracing/setup/docker/).
208
+ **For Unix Domain Socket (UDS)**:
128
209
 
129
- ### Quickstart for Rails applications
210
+ - Set `DD_APM_RECEIVER_SOCKET=<path-to-socket-file>`
211
+
212
+ OR
213
+
214
+ - Add `apm_config: receiver_socket: <path-to-socket-file>` to the [agent's configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6v7#agent-main-configuration-file)
215
+
216
+ ### Instrument your application
217
+
218
+ #### Rails applications
130
219
 
131
220
  1. Add the `ddtrace` gem to your Gemfile:
132
221
 
133
222
  ```ruby
134
223
  source 'https://rubygems.org'
135
- gem 'ddtrace'
224
+ gem 'ddtrace', require: 'ddtrace/auto_instrument'
136
225
  ```
137
226
 
138
227
  2. Install the gem with `bundle install`
228
+
139
229
  3. Create a `config/initializers/datadog.rb` file containing:
140
230
 
141
231
  ```ruby
142
232
  Datadog.configure do |c|
143
- # This will activate auto-instrumentation for Rails
144
- c.use :rails
233
+ # Add additional configuration here.
234
+ # Activate integrations, change tracer settings, etc...
145
235
  end
146
236
  ```
147
237
 
148
- You can also activate additional integrations here (see [Integration instrumentation](#integration-instrumentation))
238
+ Using this block you can:
149
239
 
150
- ### Quickstart for Ruby applications
240
+ - [Add additional configuration settings](#additional-configuration)
241
+ - [Activate or reconfigure instrumentation](#integration-instrumentation)
151
242
 
152
- 1. Install the gem with `gem install ddtrace`
153
- 2. Add a configuration block to your Ruby application:
243
+ #### Ruby applications
244
+
245
+ 1. Add the `ddtrace` gem to your Gemfile:
246
+
247
+ ```ruby
248
+ source 'https://rubygems.org'
249
+ gem 'ddtrace'
250
+ ```
251
+
252
+ 2. Install the gem with `bundle install`
253
+ 3. `require` any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
254
+ 4. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
255
+
256
+ ```ruby
257
+ # Example frameworks and libraries
258
+ require 'sinatra'
259
+ require 'faraday'
260
+ require 'redis'
261
+
262
+ require 'ddtrace/auto_instrument'
263
+ ```
264
+
265
+ 5. Add a configuration block to your application:
154
266
 
155
267
  ```ruby
156
- require 'ddtrace'
157
268
  Datadog.configure do |c|
158
- # Configure the tracer here.
269
+ # Add additional configuration here.
159
270
  # Activate integrations, change tracer settings, etc...
160
- # By default without additional configuration, nothing will be traced.
161
271
  end
162
272
  ```
163
273
 
164
- 3. Add or activate instrumentation by doing either of the following:
165
- - Activate integration instrumentation (see [Integration instrumentation](#integration-instrumentation))
166
- - Add manual instrumentation around your code (see [Manual instrumentation](#manual-instrumentation))
274
+ Using this block you can:
275
+
276
+ - [Add additional configuration settings](#additional-configuration)
277
+ - [Activate or reconfigure instrumentation](#integration-instrumentation)
167
278
 
168
- ### Quickstart for OpenTracing
279
+ #### Configuring OpenTracing
280
+
281
+ 1. Add the `ddtrace` gem to your Gemfile:
282
+
283
+ ```ruby
284
+ source 'https://rubygems.org'
285
+ gem 'ddtrace'
286
+ ```
169
287
 
170
- 1. Install the gem with `gem install ddtrace`
171
- 2. To your OpenTracing configuration file, add the following:
288
+ 2. Install the gem with `bundle install`
289
+ 3. To your OpenTracing configuration file, add the following:
172
290
 
173
291
  ```ruby
174
292
  require 'opentracing'
175
- require 'ddtrace'
176
- require 'ddtrace/opentracer'
293
+ require 'datadog/tracing'
294
+ require 'datadog/opentracer'
177
295
 
178
296
  # Activate the Datadog tracer for OpenTracing
179
297
  OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new
180
298
  ```
181
299
 
182
- 3. (Optional) Add a configuration block to your Ruby application to configure Datadog with:
300
+ 4. Add a configuration block to your application:
183
301
 
184
302
  ```ruby
185
303
  Datadog.configure do |c|
@@ -191,9 +309,29 @@ Before downloading tracing on your application, install the Datadog Agent. The R
191
309
  end
192
310
  ```
193
311
 
194
- 4. (Optional) Add or activate additional instrumentation by doing either of the following:
195
- - Activate Datadog integration instrumentation (see [Integration instrumentation](#integration-instrumentation))
196
- - Add Datadog manual instrumentation around your code (see [Manual instrumentation](#manual-instrumentation))
312
+ Using this block you can:
313
+
314
+ - [Add additional Datadog configuration settings](#additional-configuration)
315
+ - [Activate or reconfigure Datadog instrumentation](#integration-instrumentation)
316
+
317
+ #### Configuring OpenTelemetry
318
+
319
+ You can send OpenTelemetry traces directly to the Datadog agent (without `ddtrace`) by using OTLP. Check out our documentation on [OTLP ingest in the Datadog Agent](https://docs.datadoghq.com/tracing/setup_overview/open_standards/#otlp-ingest-in-datadog-agent) for details.
320
+
321
+ ### Connect your application to the Datadog Agent
322
+
323
+ By default, `ddtrace` will connect to the agent using the first available settings in the listed priority:
324
+
325
+ 1. Via any explicitly provided configuration settings (hostname/port/transport)
326
+ 2. Via Unix Domain Socket (UDS) located at `/var/run/datadog/apm.socket`
327
+ 3. Via HTTP over TCP to `127.0.0.1:8126`
328
+
329
+ If your Datadog Agent is listening at any of these locations, no further configuration should be required.
330
+
331
+ If your agent runs on a different host or container than your application, or you would like to send traces via a different protocol, you will need to configure your application accordingly.
332
+
333
+ - [How to send trace data via HTTP over TCP to agent](#changing-default-agent-hostname-and-port)
334
+ - [How to send trace data via Unix Domain Socket (UDS) to agent](#using-the-unix-domain-socket-uds-adapter)
197
335
 
198
336
  ### Final steps for installation
199
337
 
@@ -203,10 +341,10 @@ After setting up, your services will appear on the [APM services page](https://a
203
341
 
204
342
  If you aren't using a supported framework instrumentation, you may want to manually instrument your code.
205
343
 
206
- To trace any Ruby code, you can use the `Datadog.tracer.trace` method:
344
+ To trace any Ruby code, you can use the `Datadog::Tracing.trace` method:
207
345
 
208
346
  ```ruby
209
- Datadog.tracer.trace(name, options) do |span|
347
+ Datadog::Tracing.trace(name, options) do |span, trace|
210
348
  # Wrap this block around the code you want to instrument
211
349
  # Additionally, you can modify the span here.
212
350
  # e.g. Change the resource name, set tags, etc...
@@ -218,14 +356,15 @@ Where `name` should be a `String` that describes the generic kind of operation b
218
356
  And `options` is an optional `Hash` that accepts the following parameters:
219
357
 
220
358
  | Key | Type | Description | Default |
221
- | --- | --- | --- | --- |
222
- | `service` | `String` | The service name which this span belongs (e.g. `'my-web-service'`) | Tracer `default-service`, `$PROGRAM_NAME` or `'ruby'` |
223
- | `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. |
224
- | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
225
- | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
226
- | `start_time` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
227
- | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
228
- | `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? }` |
359
+ | --------------- | ----------------------- | --- | --- |
360
+ | `autostart` | `Bool` | Whether the time measurement should be started automatically. If `false`, user must call `span.start`. | `true` |
361
+ | `continue_from` | `Datadog::TraceDigest` | Continues a trace that originated from another execution context. TraceDigest describes the continuation point. | `nil` |
362
+ | `on_error` | `Proc` | Overrides error handling behavior, when a span 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? }` |
363
+ | `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. |
364
+ | `service` | `String` | The service name which this span belongs (e.g. `'my-web-service'`) | Tracer `default-service`, `$PROGRAM_NAME` or `'ruby'` |
365
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
366
+ | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
367
+ | `type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
229
368
 
230
369
  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.
231
370
 
@@ -233,9 +372,9 @@ Example of manual instrumentation in action:
233
372
 
234
373
  ```ruby
235
374
  get '/posts' do
236
- Datadog.tracer.trace('web.request', service: 'my-blog', resource: 'GET /posts') do |span|
375
+ Datadog::Tracing.trace('web.request', service: 'my-blog', resource: 'GET /posts') do |span|
237
376
  # Trace the activerecord call
238
- Datadog.tracer.trace('posts.fetch') do
377
+ Datadog::Tracing.trace('posts.fetch') do
239
378
  @posts = Posts.order(created_at: :desc).limit(10)
240
379
  end
241
380
 
@@ -244,7 +383,7 @@ get '/posts' do
244
383
  span.set_tag('posts.count', @posts.length)
245
384
 
246
385
  # Trace the template rendering
247
- Datadog.tracer.trace('template.render') do
386
+ Datadog::Tracing.trace('template.render') do
248
387
  erb :index
249
388
  end
250
389
  end
@@ -253,37 +392,36 @@ end
253
392
 
254
393
  ### Asynchronous tracing
255
394
 
256
- 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.
395
+ It might not always be possible to wrap `Datadog::Tracing.trace` around a block of code. Some event or notification based instrumentation might only notify you when an event begins or ends.
257
396
 
258
- To trace these operations, you can trace code asynchronously by calling `Datadog.tracer.trace` without a block:
397
+ To trace these operations, you can trace code asynchronously by calling `Datadog::Tracing.trace` without a block:
259
398
 
260
399
  ```ruby
261
400
  # Some instrumentation framework calls this after an event finishes...
262
401
  def db_query(start, finish, query)
263
- span = Datadog.tracer.trace('database.query')
402
+ span = Datadog::Tracing.trace('database.query', start_time: start)
264
403
  span.resource = query
265
- span.start_time = start
266
404
  span.finish(finish)
267
405
  end
268
406
  ```
269
407
 
270
- 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`.
408
+ Calling `Datadog::Tracing.trace` without a block will cause the function to return a `Datadog::SpanOperation` that is started, but not finished. You can then modify this span however you wish, then close it `finish`.
271
409
 
272
410
  *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.
273
411
 
274
- To avoid this scenario when handling start/finish events, you can use `Datadog.tracer.active_span` to get the current active span.
412
+ To avoid this scenario when handling start/finish events, you can use `Datadog::Tracing.active_span` to get the current active span.
275
413
 
276
414
  ```ruby
277
415
  # e.g. ActiveSupport::Notifications calls this when an event starts
278
416
  def start(name, id, payload)
279
417
  # Start a span
280
- Datadog.tracer.trace(name)
418
+ Datadog::Tracing.trace(name)
281
419
  end
282
420
 
283
421
  # e.g. ActiveSupport::Notifications calls this when an event finishes
284
422
  def finish(name, id, payload)
285
423
  # Retrieve current active span (thread-safe)
286
- current_span = Datadog.tracer.active_span
424
+ current_span = Datadog::Tracing.active_span
287
425
  unless current_span.nil?
288
426
  current_span.resource = payload[:query]
289
427
  current_span.finish
@@ -297,17 +435,16 @@ You can tag additional information to the current active span from any method. N
297
435
  ```ruby
298
436
  # e.g. adding tag to active span
299
437
 
300
- current_span = Datadog.tracer.active_span
438
+ current_span = Datadog::Tracing.active_span
301
439
  current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
302
440
  ```
303
441
 
304
- 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.
442
+ You can also get the current active trace using the `active_trace` method. This method will return `nil` if there is no active trace.
305
443
 
306
444
  ```ruby
307
- # e.g. adding tag to active root span
445
+ # e.g. accessing active trace
308
446
 
309
- current_root_span = Datadog.tracer.active_root_span
310
- current_root_span.set_tag('my_tag', 'my_value') unless current_root_span.nil?
447
+ current_trace = Datadog::Tracing.active_trace
311
448
  ```
312
449
 
313
450
  ## Integration instrumentation
@@ -317,7 +454,7 @@ Many popular libraries and frameworks are supported out-of-the-box, which can be
317
454
  ```ruby
318
455
  Datadog.configure do |c|
319
456
  # Activates and configures an integration
320
- c.use :integration_name, options
457
+ c.tracing.instrument :integration_name, options
321
458
  end
322
459
  ```
323
460
 
@@ -325,41 +462,77 @@ end
325
462
 
326
463
  For a list of available integrations, and their configuration options, please refer to the following:
327
464
 
328
- | Name | Key | Versions Supported | How to configure | Gem source |
329
- | ------------------------ | -------------------------- | ------------------------ | ----------------------------------- | ------------------------------------------------------------------------------ |
330
- | Action Cable | `action_cable` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
331
- | Action View | `action_view` | `>= 3.0` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
332
- | Active Model Serializers | `active_model_serializers` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
333
- | Action Pack | `action_pack` | `>= 3.0` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
334
- | Active Record | `active_record` | `>= 3.0` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
335
- | Active Support | `active_support` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
336
- | AWS | `aws` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
337
- | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
338
- | Dalli | `dalli` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
339
- | DelayedJob | `delayed_job` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
340
- | Elasticsearch | `elasticsearch` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
341
- | Ethon | `ethon` | `>= 0.11` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
342
- | Excon | `excon` | `>= 0.50` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
343
- | Faraday | `faraday` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
344
- | Grape | `grape` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
345
- | GraphQL | `graphql` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
346
- | gRPC | `grpc` | `>= 1.7` | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
347
- | MongoDB | `mongo` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
348
- | MySQL2 | `mysql2` | `>= 0.3.21` | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
349
- | Net/HTTP | `http` | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
350
- | Presto | `presto` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
351
- | Racecar | `racecar` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
352
- | Rack | `rack` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
353
- | Rails | `rails` | `>= 3.0` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
354
- | Rake | `rake` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
355
- | Redis | `redis` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
356
- | Resque | `resque` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
357
- | Rest Client | `rest-client` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
358
- | Sequel | `sequel` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
359
- | Shoryuken | `shoryuken` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
360
- | Sidekiq | `sidekiq` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
361
- | Sinatra | `sinatra` | `>= 1.4` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
362
- | Sucker Punch | `sucker_punch` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
465
+ <!--
466
+ Note: Please replicate any changes to this section also to
467
+ https://github.com/datadog/documentation/blob/master/content/en/tracing/setup_overview/compatibility_requirements/ruby.md
468
+ so that they remain in sync.
469
+ -->
470
+
471
+ | Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
472
+ | -------------------------- | -------------------------- | ------------------------ | --------------------------| ----------------------------------- | ------------------------------------------------------------------------------ |
473
+ | Action Cable | `action_cable` | `>= 5.0` | `>= 5.0` | *[Link](#action-cable)* | *[Link](https://github.com/rails/rails/tree/master/actioncable)* |
474
+ | Action Mailer | `action_mailer` | `>= 5.0` | `>= 5.0` | *[Link](#action-mailer)* | *[Link](https://github.com/rails/rails/tree/master/actionmailer)* |
475
+ | Action Pack | `action_pack` | `>= 3.2` | `>= 3.2` | *[Link](#action-pack)* | *[Link](https://github.com/rails/rails/tree/master/actionpack)* |
476
+ | Action View | `action_view` | `>= 3.2` | `>= 3.2` | *[Link](#action-view)* | *[Link](https://github.com/rails/rails/tree/master/actionview)* |
477
+ | Active Job | `active_job` | `>= 4.2` | `>= 4.2` | *[Link](#active-job)* | *[Link](https://github.com/rails/rails/tree/master/activejob)* |
478
+ | Active Model Serializers | `active_model_serializers` | `>= 0.9` | `>= 0.9` | *[Link](#active-model-serializers)* | *[Link](https://github.com/rails-api/active_model_serializers)* |
479
+ | Active Record | `active_record` | `>= 3.2` | `>= 3.2` | *[Link](#active-record)* | *[Link](https://github.com/rails/rails/tree/master/activerecord)* |
480
+ | Active Support | `active_support` | `>= 3.2` | `>= 3.2` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
481
+ | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
482
+ | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
483
+ | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
484
+ | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
485
+ | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
486
+ | Ethon | `ethon` | `>= 0.11` | `>= 0.11` | *[Link](#ethon)* | *[Link](https://github.com/typhoeus/ethon)* |
487
+ | Excon | `excon` | `>= 0.50` | `>= 0.50` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
488
+ | Faraday | `faraday` | `>= 0.14` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
489
+ | Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
490
+ | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
491
+ | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
492
+ | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#httprb)* | *[Link](https://github.com/httprb/http)* |
493
+ | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
494
+ | httpx | `httpx` | `>= 0.11` | `>= 0.11` | *[Link](#httpx)* | *[Link](https://gitlab.com/honeyryderchuck/httpx)* |
495
+ | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
496
+ | Makara (via Active Record) | `makara` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#active-record)* | *[Link](https://github.com/instacart/makara)* |
497
+ | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
498
+ | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
499
+ | 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)* |
500
+ | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
501
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
502
+ | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
503
+ | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
504
+ | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
505
+ | Rails | `rails` | `>= 3.2` | `>= 3.2` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
506
+ | Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
507
+ | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
508
+ | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
509
+ | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
510
+ | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
511
+ | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
512
+ | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
513
+ | Sinatra | `sinatra` | `>= 1.4` | `>= 1.4` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
514
+ | Sneakers | `sneakers` | `>= 2.12.0` | `>= 2.12.0` | *[Link](#sneakers)* | *[Link](https://github.com/jondot/sneakers)* |
515
+ | Sucker Punch | `sucker_punch` | `>= 2.0` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
516
+
517
+ #### CI Visibility
518
+
519
+ For Datadog CI Visibility, library instrumentation can be activated and configured by using the following `Datadog.configure` API:
520
+
521
+ ```ruby
522
+ Datadog.configure do |c|
523
+ # Activates and configures an integration
524
+ c.ci.instrument :integration_name, options
525
+ end
526
+ ```
527
+
528
+ `options` is a `Hash` of integration-specific configuration settings.
529
+
530
+ These are the available CI Visibility integrations:
531
+
532
+ | Name | Key | Versions Supported: MRI | Versions Supported: JRuby | How to configure | Gem source |
533
+ |-----------|------------|-------------------------|---------------------------|---------------------|-----------------------------------------------------|
534
+ | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
535
+ | RSpec | `rspec` | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)* | *[Link](https://github.com/rspec/rspec)* |
363
536
 
364
537
  ### Action Cable
365
538
 
@@ -371,7 +544,20 @@ You can enable it through `Datadog.configure`:
371
544
  require 'ddtrace'
372
545
 
373
546
  Datadog.configure do |c|
374
- c.use :action_cable, options
547
+ c.tracing.instrument :action_cable
548
+ end
549
+ ```
550
+
551
+ ### Action Mailer
552
+
553
+ The Action Mailer integration provides tracing for Rails 5 ActionMailer actions.
554
+
555
+ You can enable it through `Datadog.configure`:
556
+
557
+ ```ruby
558
+ require 'ddtrace'
559
+ Datadog.configure do |c|
560
+ c.tracing.instrument :action_mailer, options
375
561
  end
376
562
  ```
377
563
 
@@ -380,19 +566,31 @@ Where `options` is an optional `Hash` that accepts the following parameters:
380
566
  | Key | Description | Default |
381
567
  | --- | ----------- | ------- |
382
568
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
383
- | `service_name` | Service name used for `action_cable` instrumentation | `'action_cable'` |
384
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
569
+ | `email_data` | Whether or not to append additional email payload metadata to `action_mailer.deliver` spans. Fields include `['subject', 'to', 'from', 'bcc', 'cc', 'date', 'perform_deliveries']`. | `false` |
570
+
571
+ ### Action Pack
572
+
573
+ Most of the time, Action Pack is set up as part of Rails, but it can be activated separately:
574
+
575
+ ```ruby
576
+ require 'actionpack'
577
+ require 'ddtrace'
578
+
579
+ Datadog.configure do |c|
580
+ c.tracing.instrument :action_pack
581
+ end
582
+ ```
385
583
 
386
584
  ### Action View
387
585
 
388
- Most of the time, Active Support is set up as part of Rails, but it can be activated separately:
586
+ Most of the time, Action View is set up as part of Rails, but it can be activated separately:
389
587
 
390
588
  ```ruby
391
589
  require 'actionview'
392
590
  require 'ddtrace'
393
591
 
394
592
  Datadog.configure do |c|
395
- c.use :action_view, options
593
+ c.tracing.instrument :action_view, options
396
594
  end
397
595
  ```
398
596
 
@@ -400,53 +598,38 @@ Where `options` is an optional `Hash` that accepts the following parameters:
400
598
 
401
599
  | Key | Description | Default |
402
600
  | ---| --- | --- |
403
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
404
- | `service_name` | Service name used for rendering instrumentation. | `action_view` |
405
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
406
601
  | `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/'` |
407
602
 
408
- ### Active Model Serializers
603
+ ### Active Job
409
604
 
410
- The Active Model Serializers integration traces the `serialize` event for version 0.9+ and the `render` event for version 0.10+.
605
+ Most of the time, Active Job is set up as part of Rails, but it can be activated separately:
411
606
 
412
607
  ```ruby
413
- require 'active_model_serializers'
608
+ require 'active_job'
414
609
  require 'ddtrace'
415
610
 
416
611
  Datadog.configure do |c|
417
- c.use :active_model_serializers, options
612
+ c.tracing.instrument :active_job
418
613
  end
419
614
 
420
- my_object = MyModel.new(name: 'my object')
421
- ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
615
+ ExampleJob.perform_later
422
616
  ```
423
617
 
424
- | Key | Description | Default |
425
- | --- | ----------- | ------- |
426
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
427
- | `service_name` | Service name used for `active_model_serializers` instrumentation. | `'active_model_serializers'` |
428
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
429
-
430
- ### Action Pack
618
+ ### Active Model Serializers
431
619
 
432
- Most of the time, Action Pack is set up as part of Rails, but it can be activated separately:
620
+ The Active Model Serializers integration traces the `serialize` event for version 0.9+ and the `render` event for version 0.10+.
433
621
 
434
622
  ```ruby
435
- require 'actionpack'
623
+ require 'active_model_serializers'
436
624
  require 'ddtrace'
437
625
 
438
626
  Datadog.configure do |c|
439
- c.use :action_pack, options
627
+ c.tracing.instrument :active_model_serializers
440
628
  end
441
- ```
442
-
443
- Where `options` is an optional `Hash` that accepts the following parameters:
444
629
 
445
- | Key | Description | Default |
446
- | ---| --- | --- |
447
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
448
- | `service_name` | Service name used for rendering instrumentation. | `action_pack` |
449
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
630
+ my_object = MyModel.new(name: 'my object')
631
+ ActiveModelSerializers::SerializableResource.new(test_obj).serializable_hash
632
+ ```
450
633
 
451
634
  ### Active Record
452
635
 
@@ -459,7 +642,7 @@ require 'active_record'
459
642
  require 'ddtrace'
460
643
 
461
644
  Datadog.configure do |c|
462
- c.use :active_record, options
645
+ c.tracing.instrument :active_record, options
463
646
  end
464
647
 
465
648
  Dir::Tmpname.create(['test', '.sqlite']) do |db|
@@ -473,10 +656,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
473
656
 
474
657
  | Key | Description | Default |
475
658
  | ---| --- | --- |
476
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
477
- | `orm_service_name` | Service name used for the Ruby ORM portion of `active_record` instrumentation. Overrides service name for ORM spans if explicitly set, which otherwise inherit their service from their parent. | `'active_record'` |
478
659
  | `service_name` | Service name used for database portion of `active_record` instrumentation. | Name of database adapter (e.g. `'mysql2'`) |
479
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
480
660
 
481
661
  **Configuring trace settings per database**
482
662
 
@@ -491,19 +671,22 @@ You can configure trace settings per database connection by using the `describes
491
671
  Datadog.configure do |c|
492
672
  # Symbol matching your database connection in config/database.yml
493
673
  # Only available if you are using Rails with ActiveRecord.
494
- c.use :active_record, describes: :secondary_database, service_name: 'secondary-db'
674
+ c.tracing.instrument :active_record, describes: :secondary_database, service_name: 'secondary-db'
495
675
 
496
- c.use :active_record, describes: :secondary_database do |second_db|
676
+ # Block configuration pattern.
677
+ c.tracing.instrument :active_record, describes: :secondary_database do |second_db|
497
678
  second_db.service_name = 'secondary-db'
498
679
  end
499
680
 
500
681
  # Connection string with the following connection settings:
501
- # Adapter, user, host, port, database
502
- c.use :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
503
-
504
- # Hash with following connection settings
505
- # Adapter, user, host, port, database
506
- c.use :active_record, describes: {
682
+ # adapter, username, host, port, database
683
+ # Other fields are ignored.
684
+ c.tracing.instrument :active_record, describes: 'mysql2://root@127.0.0.1:3306/mysql', service_name: 'secondary-db'
685
+
686
+ # Hash with following connection settings:
687
+ # adapter, username, host, port, database
688
+ # Other fields are ignored.
689
+ c.tracing.instrument :active_record, describes: {
507
690
  adapter: 'mysql2',
508
691
  host: '127.0.0.1',
509
692
  port: '3306',
@@ -511,10 +694,35 @@ Datadog.configure do |c|
511
694
  username: 'root'
512
695
  },
513
696
  service_name: 'secondary-db'
697
+
698
+ # If using the `makara` gem, it's possible to match on connection `role`:
699
+ c.tracing.instrument :active_record, describes: { makara_role: 'primary' }, service_name: 'primary-db'
700
+ c.tracing.instrument :active_record, describes: { makara_role: 'replica' }, service_name: 'secondary-db'
701
+ end
702
+ ```
703
+
704
+ You can also create configurations based on partial matching of database connection fields:
705
+
706
+ ```ruby
707
+ Datadog.configure do |c|
708
+ # Matches any connection on host `127.0.0.1`.
709
+ c.tracing.instrument :active_record, describes: { host: '127.0.0.1' }, service_name: 'local-db'
710
+
711
+ # Matches any `mysql2` connection.
712
+ c.tracing.instrument :active_record, describes: { adapter: 'mysql2'}, service_name: 'mysql-db'
713
+
714
+ # Matches any `mysql2` connection to the `reports` database.
715
+ #
716
+ # In case of multiple matching `describe` configurations, the latest one applies.
717
+ # In this case a connection with both adapter `mysql` and database `reports`
718
+ # will be configured `service_name: 'reports-db'`, not `service_name: 'mysql-db'`.
719
+ c.tracing.instrument :active_record, describes: { adapter: 'mysql2', database: 'reports'}, service_name: 'reports-db'
514
720
  end
515
721
  ```
516
722
 
517
- 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.
723
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
724
+
725
+ 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.tracing.instrument :active_record` instead.
518
726
 
519
727
  ### Active Support
520
728
 
@@ -525,7 +733,7 @@ require 'activesupport'
525
733
  require 'ddtrace'
526
734
 
527
735
  Datadog.configure do |c|
528
- c.use :active_support, options
736
+ c.tracing.instrument :active_support, options
529
737
  end
530
738
 
531
739
  cache = ActiveSupport::Cache::MemoryStore.new
@@ -536,9 +744,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
536
744
 
537
745
  | Key | Description | Default |
538
746
  | ---| --- | --- |
539
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
540
747
  | `cache_service` | Service name used for caching with `active_support` instrumentation. | `active_support-cache` |
541
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
542
748
 
543
749
  ### AWS
544
750
 
@@ -549,7 +755,7 @@ require 'aws-sdk'
549
755
  require 'ddtrace'
550
756
 
551
757
  Datadog.configure do |c|
552
- c.use :aws, options
758
+ c.tracing.instrument :aws, options
553
759
  end
554
760
 
555
761
  # Perform traced call
@@ -560,9 +766,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
560
766
 
561
767
  | Key | Description | Default |
562
768
  | --- | ----------- | ------- |
563
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
564
769
  | `service_name` | Service name used for `aws` instrumentation | `'aws'` |
565
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
566
770
 
567
771
  ### Concurrent Ruby
568
772
 
@@ -575,12 +779,39 @@ To activate your integration, use the `Datadog.configure` method:
575
779
  # Inside Rails initializer or equivalent
576
780
  Datadog.configure do |c|
577
781
  # Patches ::Concurrent::Future to use ExecutorService that propagates context
578
- c.use :concurrent_ruby, options
782
+ c.tracing.instrument :concurrent_ruby
579
783
  end
580
784
 
581
785
  # Pass context into code executed within Concurrent::Future
582
- Datadog.tracer.trace('outer') do
583
- Concurrent::Future.execute { Datadog.tracer.trace('inner') { } }.wait
786
+ Datadog::Tracing.trace('outer') do
787
+ Concurrent::Future.execute { Datadog::Tracing.trace('inner') { } }.wait
788
+ end
789
+ ```
790
+
791
+ ### Cucumber
792
+
793
+ Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
794
+
795
+ To activate your integration, use the `Datadog.configure` method:
796
+
797
+ ```ruby
798
+ require 'cucumber'
799
+ require 'ddtrace'
800
+
801
+ # Configure default Cucumber integration
802
+ Datadog.configure do |c|
803
+ c.ci.instrument :cucumber, options
804
+ end
805
+
806
+ # Example of how to attach tags from scenario to active span
807
+ Around do |scenario, block|
808
+ active_span = Datadog.configuration[:cucumber][:tracer].active_span
809
+ unless active_span.nil?
810
+ scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
811
+ active_span.set_tag(*tag.name.split(':', 2))
812
+ end
813
+ end
814
+ block.call
584
815
  end
585
816
  ```
586
817
 
@@ -588,8 +819,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
588
819
 
589
820
  | Key | Description | Default |
590
821
  | --- | ----------- | ------- |
591
- | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
592
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
822
+ | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
823
+ | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
824
+ | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
593
825
 
594
826
  ### Dalli
595
827
 
@@ -601,7 +833,7 @@ require 'ddtrace'
601
833
 
602
834
  # Configure default Dalli tracing behavior
603
835
  Datadog.configure do |c|
604
- c.use :dalli, options
836
+ c.tracing.instrument :dalli, options
605
837
  end
606
838
 
607
839
  # Configure Dalli tracing behavior for single client
@@ -613,13 +845,11 @@ Where `options` is an optional `Hash` that accepts the following parameters:
613
845
 
614
846
  | Key | Description | Default |
615
847
  | --- | ----------- | ------- |
616
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
617
848
  | `service_name` | Service name used for `dalli` instrumentation | `'memcached'` |
618
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
619
849
 
620
850
  ### DelayedJob
621
851
 
622
- The DelayedJob integration uses lifecycle hooks to trace the job executions.
852
+ The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
623
853
 
624
854
  You can enable it through `Datadog.configure`:
625
855
 
@@ -627,7 +857,7 @@ You can enable it through `Datadog.configure`:
627
857
  require 'ddtrace'
628
858
 
629
859
  Datadog.configure do |c|
630
- c.use :delayed_job, options
860
+ c.tracing.instrument :delayed_job, options
631
861
  end
632
862
  ```
633
863
 
@@ -635,9 +865,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
635
865
 
636
866
  | Key | Description | Default |
637
867
  | --- | ----------- | ------- |
638
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
639
- | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
640
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
868
+ | `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? }` |
641
869
 
642
870
  ### Elasticsearch
643
871
 
@@ -648,22 +876,23 @@ require 'elasticsearch/transport'
648
876
  require 'ddtrace'
649
877
 
650
878
  Datadog.configure do |c|
651
- c.use :elasticsearch, options
879
+ c.tracing.instrument :elasticsearch, options
652
880
  end
653
881
 
654
882
  # Perform a query to Elasticsearch
655
883
  client = Elasticsearch::Client.new url: 'http://127.0.0.1:9200'
656
884
  response = client.perform_request 'GET', '_cluster/health'
885
+
886
+ # In case you want to override the global configuration for a certain client instance
887
+ Datadog.configure_onto(client.transport, **options)
657
888
  ```
658
889
 
659
890
  Where `options` is an optional `Hash` that accepts the following parameters:
660
891
 
661
892
  | Key | Description | Default |
662
893
  | --- | ----------- | ------- |
663
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
664
894
  | `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. | `{}` |
665
895
  | `service_name` | Service name used for `elasticsearch` instrumentation | `'elasticsearch'` |
666
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
667
896
 
668
897
  ### Ethon
669
898
 
@@ -673,10 +902,10 @@ The `ethon` integration will trace any HTTP request through `Easy` or `Multi` ob
673
902
  require 'ddtrace'
674
903
 
675
904
  Datadog.configure do |c|
676
- c.use :ethon, options
905
+ c.tracing.instrument :ethon, options
677
906
 
678
907
  # optionally, specify a different service name for hostnames matching a regex
679
- c.use :ethon, describes: /user-[^.]+\.example\.com/ do |ethon|
908
+ c.tracing.instrument :ethon, describes: /user-[^.]+\.example\.com/ do |ethon|
680
909
  ethon.service_name = 'user.example.com'
681
910
  ethon.split_by_domain = false # Only necessary if split_by_domain is true by default
682
911
  end
@@ -687,11 +916,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
687
916
 
688
917
  | Key | Description | Default |
689
918
  | --- | ----------- | ------- |
690
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
691
919
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
692
920
  | `service_name` | Service name for `ethon` instrumentation. | `'ethon'` |
693
921
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
694
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
695
922
 
696
923
  ### Excon
697
924
 
@@ -703,10 +930,10 @@ require 'ddtrace'
703
930
 
704
931
  # Configure default Excon tracing behavior
705
932
  Datadog.configure do |c|
706
- c.use :excon, options
933
+ c.tracing.instrument :excon, options
707
934
 
708
935
  # optionally, specify a different service name for hostnames matching a regex
709
- c.use :excon, describes: /user-[^.]+\.example\.com/ do |excon|
936
+ c.tracing.instrument :excon, describes: /user-[^.]+\.example\.com/ do |excon|
710
937
  excon.service_name = 'user.example.com'
711
938
  excon.split_by_domain = false # Only necessary if split_by_domain is true by default
712
939
  end
@@ -720,12 +947,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
720
947
 
721
948
  | Key | Description | Default |
722
949
  | --- | ----------- | ------- |
723
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
724
950
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
725
951
  | `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` |
726
952
  | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
727
953
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
728
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
729
954
 
730
955
  **Configuring connections to use different settings**
731
956
 
@@ -735,7 +960,7 @@ If you use multiple connections with Excon, you can give each of them different
735
960
  # Wrap the Datadog tracing middleware around the default middleware stack
736
961
  Excon.new(
737
962
  'http://example.com',
738
- middlewares: Datadog::Contrib::Excon::Middleware.with(options).around_default_stack
963
+ middlewares: Datadog::Tracing::Contrib::Excon::Middleware.with(options).around_default_stack
739
964
  )
740
965
 
741
966
  # Insert the middleware into a custom middleware stack.
@@ -744,7 +969,7 @@ Excon.new(
744
969
  'http://example.com',
745
970
  middlewares: [
746
971
  Excon::Middleware::ResponseParser,
747
- Datadog::Contrib::Excon::Middleware.with(options),
972
+ Datadog::Tracing::Contrib::Excon::Middleware.with(options),
748
973
  Excon::Middleware::Idempotent
749
974
  ]
750
975
  )
@@ -762,10 +987,10 @@ require 'ddtrace'
762
987
 
763
988
  # Configure default Faraday tracing behavior
764
989
  Datadog.configure do |c|
765
- c.use :faraday, options
990
+ c.tracing.instrument :faraday, options
766
991
 
767
992
  # optionally, specify a different service name for hostnames matching a regex
768
- c.use :faraday, describes: /user-[^.]+\.example\.com/ do |faraday|
993
+ c.tracing.instrument :faraday, describes: /user-[^.]+\.example\.com/ do |faraday|
769
994
  faraday.service_name = 'user.example.com'
770
995
  faraday.split_by_domain = false # Only necessary if split_by_domain is true by default
771
996
  end
@@ -784,12 +1009,10 @@ Where `options` is an optional `Hash` that accepts the following parameters:
784
1009
 
785
1010
  | Key | Description | Default |
786
1011
  | --- | ----------- | ------- |
787
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
788
1012
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
789
1013
  | `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` |
790
1014
  | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
791
1015
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
792
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
793
1016
 
794
1017
  ### Grape
795
1018
 
@@ -803,7 +1026,7 @@ require 'grape'
803
1026
  require 'ddtrace'
804
1027
 
805
1028
  Datadog.configure do |c|
806
- c.use :grape, options
1029
+ c.tracing.instrument :grape, options
807
1030
  end
808
1031
 
809
1032
  # Then define your application
@@ -819,10 +1042,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
819
1042
 
820
1043
  | Key | Description | Default |
821
1044
  | --- | ----------- | ------- |
822
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
823
1045
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
824
- | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
825
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1046
+ | `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` |
826
1047
 
827
1048
  ### GraphQL
828
1049
 
@@ -833,7 +1054,7 @@ To activate your integration, use the `Datadog.configure` method:
833
1054
  ```ruby
834
1055
  # Inside Rails initializer or equivalent
835
1056
  Datadog.configure do |c|
836
- c.use :graphql, schemas: [YourSchema], options
1057
+ c.tracing.instrument :graphql, schemas: [YourSchema], options
837
1058
  end
838
1059
 
839
1060
  # Then run a GraphQL query
@@ -844,10 +1065,7 @@ The `use :graphql` method accepts the following parameters. Additional options c
844
1065
 
845
1066
  | Key | Description | Default |
846
1067
  | --- | ----------- | ------- |
847
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
848
- | `service_name` | Service name used for `graphql` instrumentation | `'ruby-graphql'` |
849
1068
  | `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. | `[]` |
850
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
851
1069
 
852
1070
  **Manually configuring GraphQL schemas**
853
1071
 
@@ -906,7 +1124,7 @@ require 'grpc'
906
1124
  require 'ddtrace'
907
1125
 
908
1126
  Datadog.configure do |c|
909
- c.use :grpc, options
1127
+ c.tracing.instrument :grpc, options
910
1128
  end
911
1129
 
912
1130
  # Server side
@@ -924,16 +1142,15 @@ Where `options` is an optional `Hash` that accepts the following parameters:
924
1142
 
925
1143
  | Key | Description | Default |
926
1144
  | --- | ----------- | ------- |
927
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
928
1145
  | `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
929
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1146
+ | `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? }` |
930
1147
 
931
1148
  **Configuring clients to use different settings**
932
1149
 
933
1150
  In situations where you have multiple clients calling multiple distinct services, you may pass the Datadog interceptor directly, like so
934
1151
 
935
1152
  ```ruby
936
- configured_interceptor = Datadog::Contrib::GRPC::DatadogInterceptor::Client.new do |c|
1153
+ configured_interceptor = Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Client.new do |c|
937
1154
  c.service_name = "Alternate"
938
1155
  end
939
1156
 
@@ -946,6 +1163,91 @@ alternate_client = Demo::Echo::Service.rpc_stub_class.new(
946
1163
 
947
1164
  The integration will ensure that the `configured_interceptor` establishes a unique tracing setup for that client instance.
948
1165
 
1166
+ ### http.rb
1167
+
1168
+ The http.rb integration will trace any HTTP call using the Http.rb gem.
1169
+
1170
+ ```ruby
1171
+ require 'http'
1172
+ require 'ddtrace'
1173
+ Datadog.configure do |c|
1174
+ c.tracing.instrument :httprb, options
1175
+ # optionally, specify a different service name for hostnames matching a regex
1176
+ c.tracing.instrument :httprb, describes: /user-[^.]+\.example\.com/ do |httprb|
1177
+ httprb.service_name = 'user.example.com'
1178
+ httprb.split_by_domain = false # Only necessary if split_by_domain is true by default
1179
+ end
1180
+ end
1181
+ ```
1182
+
1183
+ Where `options` is an optional `Hash` that accepts the following parameters:
1184
+
1185
+ | Key | Description | Default |
1186
+ | --- | ----------- | ------- |
1187
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1188
+ | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
1189
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1190
+
1191
+ ### httpclient
1192
+
1193
+ The httpclient integration will trace any HTTP call using the httpclient gem.
1194
+
1195
+ ```ruby
1196
+ require 'httpclient'
1197
+ require 'ddtrace'
1198
+ Datadog.configure do |c|
1199
+ c.tracing.instrument :httpclient, options
1200
+ # optionally, specify a different service name for hostnames matching a regex
1201
+ c.tracing.instrument :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1202
+ httpclient.service_name = 'user.example.com'
1203
+ httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1204
+ end
1205
+ end
1206
+ ```
1207
+
1208
+ Where `options` is an optional `Hash` that accepts the following parameters:
1209
+
1210
+ | Key | Description | Default |
1211
+ | --- | ----------- | ------- |
1212
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1213
+ | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1214
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1215
+
1216
+ ### httpx
1217
+
1218
+ `httpx` maintains its [own integration with `ddtrace`](https://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter):
1219
+
1220
+ ```ruby
1221
+ require "ddtrace"
1222
+ require "httpx/adapters/datadog"
1223
+
1224
+ Datadog.configure do |c|
1225
+ c.tracing.instrument :httpx
1226
+
1227
+ # optionally, specify a different service name for hostnames matching a regex
1228
+ c.tracing.instrument :httpx, describes: /user-[^.]+\.example\.com/ do |http|
1229
+ http.service_name = 'user.example.com'
1230
+ http.split_by_domain = false # Only necessary if split_by_domain is true by default
1231
+ end
1232
+ end
1233
+ ```
1234
+
1235
+ ### Kafka
1236
+
1237
+ The Kafka integration provides tracing of the `ruby-kafka` gem:
1238
+
1239
+ You can enable it through `Datadog.configure`:
1240
+
1241
+ ```ruby
1242
+ require 'active_support/notifications' # required to enable 'ruby-kafka' instrumentation
1243
+ require 'kafka'
1244
+ require 'ddtrace'
1245
+
1246
+ Datadog.configure do |c|
1247
+ c.tracing.instrument :kafka
1248
+ end
1249
+ ```
1250
+
949
1251
  ### MongoDB
950
1252
 
951
1253
  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:
@@ -955,7 +1257,7 @@ require 'mongo'
955
1257
  require 'ddtrace'
956
1258
 
957
1259
  Datadog.configure do |c|
958
- c.use :mongo, options
1260
+ c.tracing.instrument :mongo, options
959
1261
  end
960
1262
 
961
1263
  # Create a MongoDB client and use it as usual
@@ -964,17 +1266,46 @@ collection = client[:people]
964
1266
  collection.insert_one({ name: 'Steve' })
965
1267
 
966
1268
  # In case you want to override the global configuration for a certain client instance
967
- Datadog.configure(client, options)
1269
+ Datadog.configure_onto(client, **options)
968
1270
  ```
969
1271
 
970
1272
  Where `options` is an optional `Hash` that accepts the following parameters:
971
1273
 
972
1274
  | Key | Description | Default |
973
1275
  | --- | ----------- | ------- |
974
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
975
1276
  | `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] }` |
976
1277
  | `service_name` | Service name used for `mongo` instrumentation | `'mongodb'` |
977
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1278
+
1279
+ **Configuring trace settings per connection**
1280
+
1281
+ You can configure trace settings per connection by using the `describes` option:
1282
+
1283
+ ```ruby
1284
+ # Provide a `:describes` option with a connection key.
1285
+ # Any of the following keys are acceptable and equivalent to one another.
1286
+ # If a block is provided, it yields a Settings object that
1287
+ # accepts any of the configuration options listed above.
1288
+
1289
+ Datadog.configure do |c|
1290
+ # Network connection string
1291
+ c.tracing.instrument :mongo, describes: '127.0.0.1:27017', service_name: 'mongo-primary'
1292
+
1293
+ # Network connection regular expression
1294
+ c.tracing.instrument :mongo, describes: /localhost.*/, service_name: 'mongo-secondary'
1295
+ end
1296
+
1297
+ client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
1298
+ collection = client[:people]
1299
+ collection.insert_one({ name: 'Steve' })
1300
+ # Traced call will belong to `mongo-primary` service
1301
+
1302
+ client = Mongo::Client.new([ 'localhost:27017' ], :database => 'artists')
1303
+ collection = client[:people]
1304
+ collection.insert_one({ name: 'Steve' })
1305
+ # Traced call will belong to `mongo-secondary` service
1306
+ ```
1307
+
1308
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
978
1309
 
979
1310
  ### MySQL2
980
1311
 
@@ -985,7 +1316,7 @@ require 'mysql2'
985
1316
  require 'ddtrace'
986
1317
 
987
1318
  Datadog.configure do |c|
988
- c.use :mysql2, options
1319
+ c.tracing.instrument :mysql2, options
989
1320
  end
990
1321
 
991
1322
  client = Mysql2::Client.new(:host => "localhost", :username => "root")
@@ -996,9 +1327,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
996
1327
 
997
1328
  | Key | Description | Default |
998
1329
  | --- | ----------- | ------- |
999
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1000
1330
  | `service_name` | Service name used for `mysql2` instrumentation | `'mysql2'` |
1001
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1002
1331
 
1003
1332
  ### Net/HTTP
1004
1333
 
@@ -1009,10 +1338,10 @@ require 'net/http'
1009
1338
  require 'ddtrace'
1010
1339
 
1011
1340
  Datadog.configure do |c|
1012
- c.use :http, options
1341
+ c.tracing.instrument :http, options
1013
1342
 
1014
1343
  # optionally, specify a different service name for hostnames matching a regex
1015
- c.use :http, describes: /user-[^.]+\.example\.com/ do |http|
1344
+ c.tracing.instrument :http, describes: /user-[^.]+\.example\.com/ do |http|
1016
1345
  http.service_name = 'user.example.com'
1017
1346
  http.split_by_domain = false # Only necessary if split_by_domain is true by default
1018
1347
  end
@@ -1030,17 +1359,15 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1030
1359
 
1031
1360
  | Key | Description | Default |
1032
1361
  | --- | ----------- | ------- |
1033
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1034
1362
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1035
1363
  | `service_name` | Service name used for `http` instrumentation | `'net/http'` |
1036
1364
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1037
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1038
1365
 
1039
- If you wish to configure each connection object individually, you may use the `Datadog.configure` as it follows:
1366
+ If you wish to configure each connection object individually, you may use the `Datadog.configure_onto` as it follows:
1040
1367
 
1041
1368
  ```ruby
1042
1369
  client = Net::HTTP.new(host, port)
1043
- Datadog.configure(client, options)
1370
+ Datadog.configure_onto(client, **options)
1044
1371
  ```
1045
1372
 
1046
1373
  ### Presto
@@ -1052,7 +1379,7 @@ require 'presto-client'
1052
1379
  require 'ddtrace'
1053
1380
 
1054
1381
  Datadog.configure do |c|
1055
- c.use :presto, options
1382
+ c.tracing.instrument :presto, options
1056
1383
  end
1057
1384
 
1058
1385
  client = Presto::Client.new(
@@ -1072,9 +1399,51 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1072
1399
 
1073
1400
  | Key | Description | Default |
1074
1401
  | --- | ----------- | ------- |
1075
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1076
1402
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1077
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1403
+
1404
+ ### Qless
1405
+
1406
+ The Qless integration uses lifecycle hooks to trace job executions.
1407
+
1408
+ To add tracing to a Qless job:
1409
+
1410
+ ```ruby
1411
+ require 'ddtrace'
1412
+
1413
+ Datadog.configure do |c|
1414
+ c.tracing.instrument :qless, options
1415
+ end
1416
+ ```
1417
+
1418
+ Where `options` is an optional `Hash` that accepts the following parameters:
1419
+
1420
+ | Key | Description | Default |
1421
+ | --- | ----------- | ------- |
1422
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1423
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1424
+
1425
+ ### Que
1426
+
1427
+ The Que integration is a middleware which will trace job executions.
1428
+
1429
+ You can enable it through `Datadog.configure`:
1430
+
1431
+ ```ruby
1432
+ require 'ddtrace'
1433
+
1434
+ Datadog.configure do |c|
1435
+ c.tracing.instrument :que, options
1436
+ end
1437
+ ```
1438
+
1439
+ Where `options` is an optional `Hash` that accepts the following parameters:
1440
+
1441
+ | Key | Description | Default |
1442
+ | --- | ----------- | ------- |
1443
+ | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1444
+ | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1445
+ | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1446
+ | `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? }` |
1078
1447
 
1079
1448
  ### Racecar
1080
1449
 
@@ -1086,7 +1455,7 @@ You can enable it through `Datadog.configure`:
1086
1455
  require 'ddtrace'
1087
1456
 
1088
1457
  Datadog.configure do |c|
1089
- c.use :racecar, options
1458
+ c.tracing.instrument :racecar, options
1090
1459
  end
1091
1460
  ```
1092
1461
 
@@ -1094,9 +1463,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1094
1463
 
1095
1464
  | Key | Description | Default |
1096
1465
  | --- | ----------- | ------- |
1097
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1098
1466
  | `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
1099
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1100
1467
 
1101
1468
  ### Rack
1102
1469
 
@@ -1109,10 +1476,10 @@ This integration is automatically activated with web frameworks like Rails. If y
1109
1476
  require 'ddtrace'
1110
1477
 
1111
1478
  Datadog.configure do |c|
1112
- c.use :rack, options
1479
+ c.tracing.instrument :rack, options
1113
1480
  end
1114
1481
 
1115
- use Datadog::Contrib::Rack::TraceMiddleware
1482
+ use Datadog::Tracing::Contrib::Rack::TraceMiddleware
1116
1483
 
1117
1484
  app = proc do |env|
1118
1485
  [ 200, {'Content-Type' => 'text/plain'}, ['OK'] ]
@@ -1125,22 +1492,18 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1125
1492
 
1126
1493
  | Key | Description | Default |
1127
1494
  | --- | ----------- | ------- |
1128
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1129
1495
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1130
1496
  | `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` |
1131
1497
  | `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'] }` |
1132
- | `middleware_names` | Enable this if you want to use the middleware classes as the resource names for `rack` spans. Requires `application` option to use. | `false` |
1498
+ | `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` |
1133
1499
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1134
1500
  | `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. | `{}` |
1135
1501
  | `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` |
1136
1502
  | `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` |
1137
1503
  | `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` |
1138
1504
  | `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` |
1139
- | `service_name` | Service name used for `rack` instrumentation | `'rack'` |
1140
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1141
1505
  | `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
1142
1506
 
1143
-
1144
1507
  **Configuring URL quantization behavior**
1145
1508
 
1146
1509
  ```ruby
@@ -1151,23 +1514,23 @@ Datadog.configure do |c|
1151
1514
 
1152
1515
  # Show values for any query string parameter matching 'category_id' exactly
1153
1516
  # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by
1154
- c.use :rack, quantize: { query: { show: ['category_id'] } }
1517
+ c.tracing.instrument :rack, quantize: { query: { show: ['category_id'] } }
1155
1518
 
1156
1519
  # Show all values for all query string parameters
1157
1520
  # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id=1&sort_by=asc
1158
- c.use :rack, quantize: { query: { show: :all } }
1521
+ c.tracing.instrument :rack, quantize: { query: { show: :all } }
1159
1522
 
1160
1523
  # Totally exclude any query string parameter matching 'sort_by' exactly
1161
1524
  # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id
1162
- c.use :rack, quantize: { query: { exclude: ['sort_by'] } }
1525
+ c.tracing.instrument :rack, quantize: { query: { exclude: ['sort_by'] } }
1163
1526
 
1164
1527
  # Remove the query string entirely
1165
1528
  # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path
1166
- c.use :rack, quantize: { query: { exclude: :all } }
1529
+ c.tracing.instrument :rack, quantize: { query: { exclude: :all } }
1167
1530
 
1168
1531
  # Show URL fragments
1169
1532
  # http://example.com/path?category_id=1&sort_by=asc#featured --> http://example.com/path?category_id&sort_by#featured
1170
- c.use :rack, quantize: { fragment: :show }
1533
+ c.tracing.instrument :rack, quantize: { fragment: :show }
1171
1534
  end
1172
1535
  ```
1173
1536
 
@@ -1182,7 +1545,7 @@ To enable the Rails instrumentation, create an initializer file in your `config/
1182
1545
  require 'ddtrace'
1183
1546
 
1184
1547
  Datadog.configure do |c|
1185
- c.use :rails, options
1548
+ c.tracing.instrument :rails, options
1186
1549
  end
1187
1550
  ```
1188
1551
 
@@ -1190,9 +1553,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1190
1553
 
1191
1554
  | Key | Description | Default |
1192
1555
  | --- | ----------- | ------- |
1193
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `nil` |
1194
1556
  | `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
1195
- | `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
1196
1557
  | `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
1197
1558
  | `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` |
1198
1559
  | `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` |
@@ -1200,18 +1561,17 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1200
1561
  | `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
1201
1562
  | `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
1202
1563
  | `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/'` |
1203
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1204
1564
 
1205
1565
  **Supported versions**
1206
1566
 
1207
- | Ruby Versions | Supported Rails Versions |
1208
- | ------------- | ------------------------ |
1209
- | 2.0 | 3.0 - 3.2 |
1210
- | 2.1 | 3.0 - 4.2 |
1211
- | 2.2 - 2.3 | 3.0 - 5.2 |
1212
- | 2.4 | 4.2.8 - 5.2 |
1213
- | 2.5 | 4.2.8 - 6.0 |
1214
- | 2.6 - 2.7 | 5.0 - 6.0 |
1567
+ | MRI Versions | JRuby Versions | Rails Versions |
1568
+ | ------------- | -------------- | -------------- |
1569
+ | 2.1 | | 3.2 - 4.2 |
1570
+ | 2.2 - 2.3 | | 3.2 - 5.2 |
1571
+ | 2.4 | | 4.2.8 - 5.2 |
1572
+ | 2.5 | | 4.2.8 - 6.1 |
1573
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1574
+ | 3.0 | | 6.1 |
1215
1575
 
1216
1576
  ### Rake
1217
1577
 
@@ -1225,7 +1585,7 @@ require 'rake'
1225
1585
  require 'ddtrace'
1226
1586
 
1227
1587
  Datadog.configure do |c|
1228
- c.use :rake, options
1588
+ c.tracing.instrument :rake, options
1229
1589
  end
1230
1590
 
1231
1591
  task :my_task do
@@ -1239,11 +1599,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1239
1599
 
1240
1600
  | Key | Description | Default |
1241
1601
  | --- | ----------- | ------- |
1242
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1243
1602
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1244
1603
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1245
1604
  | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
1246
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1247
1605
 
1248
1606
  **Configuring task quantization behavior**
1249
1607
 
@@ -1255,27 +1613,27 @@ Datadog.configure do |c|
1255
1613
  # Default behavior: all arguments are quantized.
1256
1614
  # `rake.invoke.args` tag --> ['?']
1257
1615
  # `rake.execute.args` tag --> { one: '?', two: '?', three: '?' }
1258
- c.use :rake
1616
+ c.tracing.instrument :rake
1259
1617
 
1260
1618
  # Show values for any argument matching :two exactly
1261
1619
  # `rake.invoke.args` tag --> ['?']
1262
1620
  # `rake.execute.args` tag --> { one: '?', two: 'bar', three: '?' }
1263
- c.use :rake, quantize: { args: { show: [:two] } }
1621
+ c.tracing.instrument :rake, quantize: { args: { show: [:two] } }
1264
1622
 
1265
1623
  # Show all values for all arguments.
1266
1624
  # `rake.invoke.args` tag --> ['foo', 'bar', 'baz']
1267
1625
  # `rake.execute.args` tag --> { one: 'foo', two: 'bar', three: 'baz' }
1268
- c.use :rake, quantize: { args: { show: :all } }
1626
+ c.tracing.instrument :rake, quantize: { args: { show: :all } }
1269
1627
 
1270
1628
  # Totally exclude any argument matching :three exactly
1271
1629
  # `rake.invoke.args` tag --> ['?']
1272
1630
  # `rake.execute.args` tag --> { one: '?', two: '?' }
1273
- c.use :rake, quantize: { args: { exclude: [:three] } }
1631
+ c.tracing.instrument :rake, quantize: { args: { exclude: [:three] } }
1274
1632
 
1275
1633
  # Remove the arguments entirely
1276
1634
  # `rake.invoke.args` tag --> ['?']
1277
1635
  # `rake.execute.args` tag --> {}
1278
- c.use :rake, quantize: { args: { exclude: :all } }
1636
+ c.tracing.instrument :rake, quantize: { args: { exclude: :all } }
1279
1637
  end
1280
1638
  ```
1281
1639
 
@@ -1288,7 +1646,7 @@ require 'redis'
1288
1646
  require 'ddtrace'
1289
1647
 
1290
1648
  Datadog.configure do |c|
1291
- c.use :redis, options
1649
+ c.tracing.instrument :redis, options
1292
1650
  end
1293
1651
 
1294
1652
  # Perform Redis commands
@@ -1300,18 +1658,24 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1300
1658
 
1301
1659
  | Key | Description | Default |
1302
1660
  | --- | ----------- | ------- |
1303
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1304
1661
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1305
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1662
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1306
1663
 
1307
1664
  You can also set *per-instance* configuration as it follows:
1308
1665
 
1309
1666
  ```ruby
1667
+ require 'redis'
1668
+ require 'ddtrace'
1669
+
1670
+ Datadog.configure do |c|
1671
+ c.tracing.instrument :redis # Enabling integration instrumentation is still required
1672
+ end
1673
+
1310
1674
  customer_cache = Redis.new
1311
1675
  invoice_cache = Redis.new
1312
1676
 
1313
- Datadog.configure(customer_cache, service_name: 'customer-cache')
1314
- Datadog.configure(invoice_cache, service_name: 'invoice-cache')
1677
+ Datadog.configure_onto(customer_cache, service_name: 'customer-cache')
1678
+ Datadog.configure_onto(invoice_cache, service_name: 'invoice-cache')
1315
1679
 
1316
1680
  # Traced call will belong to `customer-cache` service
1317
1681
  customer_cache.get(...)
@@ -1331,21 +1695,28 @@ You can configure trace settings per connection by using the `describes` option:
1331
1695
 
1332
1696
  Datadog.configure do |c|
1333
1697
  # The default configuration for any redis client
1334
- c.use :redis, service_name: 'redis-default'
1698
+ c.tracing.instrument :redis, service_name: 'redis-default'
1335
1699
 
1336
- # The configuration matching a given unix socket
1337
- c.use :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1700
+ # The configuration matching a given unix socket.
1701
+ c.tracing.instrument :redis, describes: { url: 'unix://path/to/file' }, service_name: 'redis-unix'
1338
1702
 
1339
- # Connection string
1340
- c.use :redis, describes: { url: 'redis://127.0.0.1:6379/0' }, service_name: 'redis-connection-string'
1341
- # Client host, port, db, scheme
1342
- c.use :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1703
+ # For network connections, only these fields are considered during matching:
1704
+ # scheme, host, port, db
1705
+ # Other fields are ignored.
1706
+
1707
+ # Network connection string
1708
+ c.tracing.instrument :redis, describes: 'redis://127.0.0.1:6379/0', service_name: 'redis-connection-string'
1709
+ c.tracing.instrument :redis, describes: { url: 'redis://127.0.0.1:6379/1' }, service_name: 'redis-connection-url'
1710
+ # Network client hash
1711
+ c.tracing.instrument :redis, describes: { host: 'my-host.com', port: 6379, db: 1, scheme: 'redis' }, service_name: 'redis-connection-hash'
1343
1712
  # Only a subset of the connection hash
1344
- c.use :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
1345
- c.use :redis, describes: { host: ENV['SIDEKIQ_CACHE_HOST'] }, service_name: 'redis-sidekiq'
1713
+ c.tracing.instrument :redis, describes: { host: ENV['APP_CACHE_HOST'], port: ENV['APP_CACHE_PORT'] }, service_name: 'redis-cache'
1714
+ c.tracing.instrument :redis, describes: { host: ENV['SIDEKIQ_CACHE_HOST'] }, service_name: 'redis-sidekiq'
1346
1715
  end
1347
1716
  ```
1348
1717
 
1718
+ When multiple `describes` configurations match a connection, the latest configured rule that matches will be applied.
1719
+
1349
1720
  ### Resque
1350
1721
 
1351
1722
  The Resque integration uses Resque hooks that wraps the `perform` method.
@@ -1353,16 +1724,11 @@ The Resque integration uses Resque hooks that wraps the `perform` method.
1353
1724
  To add tracing to a Resque job:
1354
1725
 
1355
1726
  ```ruby
1727
+ require 'resque'
1356
1728
  require 'ddtrace'
1357
1729
 
1358
- class MyJob
1359
- def self.perform(*args)
1360
- # do_something
1361
- end
1362
- end
1363
-
1364
1730
  Datadog.configure do |c|
1365
- c.use :resque, options
1731
+ c.tracing.instrument :resque, **options
1366
1732
  end
1367
1733
  ```
1368
1734
 
@@ -1370,10 +1736,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1370
1736
 
1371
1737
  | Key | Description | Default |
1372
1738
  | --- | ----------- | ------- |
1373
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1374
- | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1375
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually, you don't need to set this. | `Datadog.tracer` |
1376
- | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1739
+ | `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? }` |
1377
1740
 
1378
1741
  ### Rest Client
1379
1742
 
@@ -1384,7 +1747,7 @@ require 'rest_client'
1384
1747
  require 'ddtrace'
1385
1748
 
1386
1749
  Datadog.configure do |c|
1387
- c.use :rest_client, options
1750
+ c.tracing.instrument :rest_client, options
1388
1751
  end
1389
1752
  ```
1390
1753
 
@@ -1392,10 +1755,32 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1392
1755
 
1393
1756
  | Key | Description | Default |
1394
1757
  | --- | ----------- | ------- |
1395
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1396
1758
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1397
1759
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1398
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1760
+
1761
+ ### RSpec
1762
+
1763
+ RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1764
+
1765
+ To activate your integration, use the `Datadog.configure` method:
1766
+
1767
+ ```ruby
1768
+ require 'rspec'
1769
+ require 'ddtrace'
1770
+
1771
+ # Configure default RSpec integration
1772
+ Datadog.configure do |c|
1773
+ c.ci.instrument :rspec, options
1774
+ end
1775
+ ```
1776
+
1777
+ Where `options` is an optional `Hash` that accepts the following parameters:
1778
+
1779
+ | Key | Description | Default |
1780
+ | --- | ----------- | ------- |
1781
+ | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1782
+ | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1783
+ | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1399
1784
 
1400
1785
  ### Sequel
1401
1786
 
@@ -1415,7 +1800,7 @@ database.create_table :articles do
1415
1800
  end
1416
1801
 
1417
1802
  Datadog.configure do |c|
1418
- c.use :sequel, options
1803
+ c.tracing.instrument :sequel, options
1419
1804
  end
1420
1805
 
1421
1806
  # Perform a query
@@ -1427,11 +1812,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1427
1812
 
1428
1813
  | Key | Description | Default |
1429
1814
  | --- | ----------- | ------- |
1430
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1431
1815
  | `service_name` | Service name for `sequel` instrumentation | Name of database adapter (e.g. `'mysql2'`) |
1432
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1433
-
1434
- Only Ruby 2.0+ is supported.
1435
1816
 
1436
1817
  **Configuring databases to use different settings**
1437
1818
 
@@ -1442,8 +1823,8 @@ sqlite_database = Sequel.sqlite
1442
1823
  postgres_database = Sequel.connect('postgres://user:password@host:port/database_name')
1443
1824
 
1444
1825
  # Configure each database with different service names
1445
- Datadog.configure(sqlite_database, service_name: 'my-sqlite-db')
1446
- Datadog.configure(postgres_database, service_name: 'my-postgres-db')
1826
+ Datadog.configure_onto(sqlite_database, service_name: 'my-sqlite-db')
1827
+ Datadog.configure_onto(postgres_database, service_name: 'my-postgres-db')
1447
1828
  ```
1448
1829
 
1449
1830
  ### Shoryuken
@@ -1456,7 +1837,7 @@ You can enable it through `Datadog.configure`:
1456
1837
  require 'ddtrace'
1457
1838
 
1458
1839
  Datadog.configure do |c|
1459
- c.use :shoryuken, options
1840
+ c.tracing.instrument :shoryuken, options
1460
1841
  end
1461
1842
  ```
1462
1843
 
@@ -1464,9 +1845,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1464
1845
 
1465
1846
  | Key | Description | Default |
1466
1847
  | --- | ----------- | ------- |
1467
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1468
- | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1469
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1848
+ | `tag_body` | Tag spans with the SQS message body `true` or `false` | `false` |
1849
+ | `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? }` |
1470
1850
 
1471
1851
  ### Sidekiq
1472
1852
 
@@ -1478,7 +1858,7 @@ You can enable it through `Datadog.configure`:
1478
1858
  require 'ddtrace'
1479
1859
 
1480
1860
  Datadog.configure do |c|
1481
- c.use :sidekiq, options
1861
+ c.tracing.instrument :sidekiq, options
1482
1862
  end
1483
1863
  ```
1484
1864
 
@@ -1486,11 +1866,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1486
1866
 
1487
1867
  | Key | Description | Default |
1488
1868
  | --- | ----------- | ------- |
1489
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1490
- | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1491
- | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1492
1869
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1493
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1870
+ | `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? }` |
1871
+ | `quantize` | Hash containing options for quantization of job arguments. | `{}` |
1494
1872
 
1495
1873
  ### Sinatra
1496
1874
 
@@ -1505,7 +1883,7 @@ require 'sinatra'
1505
1883
  require 'ddtrace'
1506
1884
 
1507
1885
  Datadog.configure do |c|
1508
- c.use :sinatra, options
1886
+ c.tracing.instrument :sinatra, options
1509
1887
  end
1510
1888
 
1511
1889
  get '/' do
@@ -1520,11 +1898,11 @@ require 'sinatra/base'
1520
1898
  require 'ddtrace'
1521
1899
 
1522
1900
  Datadog.configure do |c|
1523
- c.use :sinatra, options
1901
+ c.tracing.instrument :sinatra, options
1524
1902
  end
1525
1903
 
1526
1904
  class NestedApp < Sinatra::Base
1527
- register Datadog::Contrib::Sinatra::Tracer
1905
+ register Datadog::Tracing::Contrib::Sinatra::Tracer
1528
1906
 
1529
1907
  get '/nested' do
1530
1908
  'Hello from nested app!'
@@ -1532,7 +1910,7 @@ class NestedApp < Sinatra::Base
1532
1910
  end
1533
1911
 
1534
1912
  class App < Sinatra::Base
1535
- register Datadog::Contrib::Sinatra::Tracer
1913
+ register Datadog::Tracing::Contrib::Sinatra::Tracer
1536
1914
 
1537
1915
  use NestedApp
1538
1916
 
@@ -1542,7 +1920,7 @@ class App < Sinatra::Base
1542
1920
  end
1543
1921
  ```
1544
1922
 
1545
- Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before you mount your nested applications.
1923
+ Ensure you register `Datadog::Tracing::Contrib::Sinatra::Tracer` as a middleware before you mount your nested applications.
1546
1924
 
1547
1925
  #### Instrumentation options
1548
1926
 
@@ -1550,68 +1928,91 @@ Ensure you register `Datadog::Contrib::Sinatra::Tracer` as a middleware before y
1550
1928
 
1551
1929
  | Key | Description | Default |
1552
1930
  | --- | ----------- | ------- |
1553
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
1554
1931
  | `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` |
1555
1932
  | `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'] }` |
1556
1933
  | `resource_script_names` | Prepend resource names with script name | `false` |
1557
- | `service_name` | Service name used for `sinatra` instrumentation | `'sinatra'` |
1558
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1559
1934
 
1560
- ### Sucker Punch
1935
+ ### Sneakers
1561
1936
 
1562
- The `sucker_punch` integration traces all scheduled jobs:
1937
+ The Sneakers integration is a server-side middleware which will trace job executions.
1938
+
1939
+ You can enable it through `Datadog.configure`:
1563
1940
 
1564
1941
  ```ruby
1565
1942
  require 'ddtrace'
1566
1943
 
1567
1944
  Datadog.configure do |c|
1568
- c.use :sucker_punch, options
1945
+ c.tracing.instrument :sneakers, options
1569
1946
  end
1570
-
1571
- # Execution of this job is traced
1572
- LogJob.perform_async('login')
1573
1947
  ```
1574
1948
 
1575
1949
  Where `options` is an optional `Hash` that accepts the following parameters:
1576
1950
 
1577
1951
  | Key | Description | Default |
1578
1952
  | --- | ----------- | ------- |
1579
- | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1580
- | `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
1581
- | `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
1582
-
1583
- ## Advanced configuration
1953
+ | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1954
+ | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1955
+ | `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? }` |
1584
1956
 
1585
- ### Tracer settings
1957
+ ### Sucker Punch
1586
1958
 
1587
- To change the default behavior of the Datadog tracer, you can provide custom options inside the `Datadog.configure` block as in:
1959
+ The `sucker_punch` integration traces all scheduled jobs:
1588
1960
 
1589
1961
  ```ruby
1590
- # config/initializers/datadog-tracer.rb
1962
+ require 'ddtrace'
1591
1963
 
1592
1964
  Datadog.configure do |c|
1593
- c.tracer.enabled = true
1594
- c.tracer.hostname = 'my-agent'
1595
- c.tracer.port = 8126
1596
- c.tracer.partial_flush.enabled = false
1597
- c.tracer.sampler = Datadog::AllSampler.new
1598
-
1599
- # OR for advanced use cases, you can specify your own tracer:
1600
- c.tracer.instance = Datadog::Tracer.new
1601
-
1602
- # To enable debug mode:
1603
- c.diagnostics.debug = true
1965
+ c.tracing.instrument :sucker_punch
1604
1966
  end
1967
+
1968
+ # Execution of this job is traced
1969
+ LogJob.perform_async('login')
1605
1970
  ```
1606
1971
 
1607
- Available options are:
1972
+ ## Additional configuration
1608
1973
 
1609
- - `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.
1610
- - `hostname`: set the hostname of the trace agent.
1611
- - `instance`: set to a custom `Datadog::Tracer` instance. If provided, other trace settings are ignored (you must configure it manually.)
1612
- - `partial_flush.enabled`: set to `true` to enable partial trace flushing (for long running traces.) Disabled by default. *Experimental.*
1613
- - `port`: set the port the trace agent is listening on.
1614
- - `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
1974
+ To change the default behavior of Datadog tracing, you can set environment variables, or provide custom options inside a `Datadog.configure` block, e.g.:
1975
+
1976
+ ```ruby
1977
+ Datadog.configure do |c|
1978
+ c.service = 'billing-api'
1979
+ c.env = ENV['RACK_ENV']
1980
+
1981
+ c.tracing.report_hostname = true
1982
+ c.tracing.test_mode.enabled = (ENV['RACK_ENV'] == 'test')
1983
+ end
1984
+ ```
1985
+
1986
+ **Available configuration options:**
1987
+
1988
+ | Setting | Env Var | Default | Description |
1989
+ |---------------------------------------------------------|--------------------------------|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1990
+ | **Global** | | | |
1991
+ | `agent.host` | `DD_AGENT_HOST` | `127.0.0.1` | Hostname of agent to where trace data will be sent. |
1992
+ | `agent.port` | `DD_TRACE_AGENT_PORT` | `8126` | Port of agent host to where trace data will be sent. |
1993
+ | | `DD_TRACE_AGENT_URL` | `nil` | Sets the URL endpoint where traces are sent. Has priority over `agent.host` and `agent.port`. |
1994
+ | `diagnostics.debug` | `DD_TRACE_DEBUG` | `false` | Enables or disables debug mode. Prints verbose logs. **NOT recommended for production or other sensitive environments.** See [Debugging and diagnostics](#debugging-and-diagnostics) for more details. |
1995
+ | `diagnostics.startup_logs.enabled` | `DD_TRACE_STARTUP_LOGS` | `nil` | Prints startup configuration and diagnostics to log. For assessing state of tracing at application startup. See [Debugging and diagnostics](#debugging-and-diagnostics) for more details. |
1996
+ | `env` | `DD_ENV` | `nil` | Your application environment. (e.g. `production`, `staging`, etc.) This value is set as a tag on all traces. |
1997
+ | `service` | `DD_SERVICE` | *Ruby filename* | Your application's default service name. (e.g. `billing-api`) This value is set as a tag on all traces. |
1998
+ | `tags` | `DD_TAGS` | `nil` | Custom tags in value pairs separated by `,` (e.g. `layer:api,team:intake`) These tags are set on all traces. See [Environment and tags](#environment-and-tags) for more details. |
1999
+ | `time_now_provider` | | `->{ Time.now }` | Changes how time is retrieved. See [Setting the time provider](#Setting the time provider) for more details. |
2000
+ | `version` | `DD_VERSION` | `nil` | Your application version (e.g. `2.5`, `202003181415`, `1.3-alpha`, etc.) This value is set as a tag on all traces. |
2001
+ | **Tracing** | | | |
2002
+ | `tracing.analytics.enabled` | `DD_TRACE_ANALYTICS_ENABLED` | `nil` | Enables or disables trace analytics. See [Sampling](#sampling) for more details. |
2003
+ | `tracing.distributed_tracing.propagation_extract_style` | `DD_PROPAGATION_STYLE_EXTRACT` | `['Datadog','B3','B3 single header']` | Distributed tracing header formats to extract. See [Distributed Tracing](#distributed-tracing) for more details. |
2004
+ | `tracing.distributed_tracing.propagation_inject_style` | `DD_PROPAGATION_STYLE_INJECT` | `['Datadog']` | Distributed tracing header formats to inject. See [Distributed Tracing](#distributed-tracing) for more details. |
2005
+ | `tracing.enabled` | `DD_TRACE_ENABLED` | `true` | Enables or disables tracing. If set to `false` instrumentation will still run, but no traces are sent to the trace agent. |
2006
+ | `tracing.instrument(<integration-name>, <options...>)` | | | Activates instrumentation for a specific library. See [Integration instrumentation](#integration-instrumentation) for more details. |
2007
+ | `tracing.log_injection` | `DD_LOGS_INJECTION` | `true` | Injects [Trace Correlation](#trace-correlation) information into Rails logs if present. Supports the default logger (`ActiveSupport::TaggedLogging`), `lograge`, and `semantic_logger`. |
2008
+ | `tracing.partial_flush.enabled` | | `false` | Enables or disables partial flushing. Partial flushing submits completed portions of a trace to the agent. Used when tracing instruments long running tasks (e.g. jobs) with many spans. |
2009
+ | `tracing.partial_flush.min_spans_threshold` | | `500` | The number of spans that must be completed in a trace before partial flushing submits those completed spans. |
2010
+ | `tracing.sampler` | | `nil` | Advanced usage only. Sets a custom `Datadog::Tracing::Sampling::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior. See [Application-side sampling](#application-side-sampling) for details. |
2011
+ | `tracing.sampling.default_rate` | `DD_TRACE_SAMPLE_RATE` | `nil` | Sets the trace sampling rate between `0.0` (0%) and `1.0` (100%). See [Application-side sampling](#application-side-sampling) for details. |
2012
+ | `tracing.sampling.rate_limit` | `DD_TRACE_RATE_LIMIT` | `100` (per second) | Sets a maximum number of traces per second to sample. Set a rate limit to avoid the ingestion volume overages in the case of traffic spikes. |
2013
+ | `tracing.report_hostname` | `DD_TRACE_REPORT_HOSTNAME` | `false` | Adds hostname tag to traces. |
2014
+ | `tracing.test_mode.enabled` | `DD_TRACE_TEST_MODE_ENABLED` | `false` | Enables or disables test mode, for use of tracing in test suites. |
2015
+ | `tracing.test_mode.trace_flush` | | `nil` | Object that determines trace flushing behavior. |
1615
2016
 
1616
2017
  #### Custom logging
1617
2018
 
@@ -1624,18 +2025,16 @@ Additionally, it is possible to override the default logger and replace it by a
1624
2025
  ```ruby
1625
2026
  f = File.new("my-custom.log", "w+") # Log messages should go there
1626
2027
  Datadog.configure do |c|
1627
- c.logger = Logger.new(f) # Overriding the default logger
2028
+ c.logger.instance = Logger.new(f) # Overriding the default logger
1628
2029
  c.logger.level = ::Logger::INFO
1629
2030
  end
1630
2031
 
1631
2032
  Datadog.logger.info { "this is typically called by tracing code" }
1632
2033
  ```
1633
2034
 
1634
- ### Environment and tags
2035
+ #### Environment and tags
1635
2036
 
1636
- 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.
1637
-
1638
- You can configure the application to automatically tag your traces and metrics, using the following environment variables:
2037
+ 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. You can configure the application to automatically tag your traces and metrics, using the following environment variables:
1639
2038
 
1640
2039
  - `DD_ENV`: Your application environment (e.g. `production`, `staging`, etc.)
1641
2040
  - `DD_SERVICE`: Your application's default service name (e.g. `billing-api`)
@@ -1659,50 +2058,100 @@ This enables you to set this value on a per application basis, so you can have f
1659
2058
 
1660
2059
  Tags can also be set directly on individual spans, which will supersede any conflicting tags defined at the application level.
1661
2060
 
2061
+ #### Debugging and diagnostics
2062
+
2063
+ There are two different suggested means of producing diagnostics for tracing:
2064
+
2065
+ ##### Enabling debug mode
2066
+
2067
+ Switching the library into debug mode will produce verbose, detailed logs about tracing activity, including any suppressed errors. This output can be helpful in identifying errors, or confirming trace output to the agent.
2068
+
2069
+ You can enable this via `diagnostics.debug = true` or `DD_TRACE_DEBUG`.
2070
+
2071
+ ```ruby
2072
+ Datadog.configure { |c| c.diagnostics.debug = true }
2073
+ ```
2074
+
2075
+ **We do NOT recommend use of this feature in production or other sensitive environments**, as it can be very verbose under load. It's best to use this in a controlled environment where you can control application load.
2076
+
2077
+ ##### Enabling startup logs
2078
+
2079
+ Startup logs produce a report of tracing state when the application is initially configured. This can be helpful for confirming that configuration and instrumentation is activated correctly.
2080
+
2081
+ You can enable this via `diagnostics.startup_logs.enabled = true` or `DD_TRACE_STARTUP_LOGS`.
2082
+
2083
+ ```ruby
2084
+ Datadog.configure { |c| c.diagnostics.startup_logs.enabled = true }
2085
+ ```
2086
+
2087
+ By default, this will be activated whenever `ddtrace` detects the application is running in a non-development environment.
2088
+
1662
2089
  ### Sampling
1663
2090
 
1664
- `ddtrace` can perform trace sampling. While the trace agent already samples traces to reduce bandwidth usage, client sampling reduces the performance overhead.
2091
+ #### Application-side sampling
1665
2092
 
1666
- `Datadog::RateSampler` samples a ratio of the traces. For example:
2093
+ While the trace agent can sample traces to reduce bandwidth usage, application-side sampling reduces the performance overhead.
2094
+
2095
+ The default sampling rate can be set between `0.0` (0%) and `1.0` (100%). Configure the rate in order to control the volume of traces sent to Datadog. When this configuration is not set, the Datadog agent will distribute a default sampling rate of 10 traces per second.
2096
+
2097
+ Set this value via `DD_TRACE_SAMPLE_RATE` or `Datadog.configure { |c| c.tracing.sampling.default_rate = <value> }`.
2098
+
2099
+ Alternatively, you may provide your own sampler. The `Datadog::Tracing::Sampling::RateSampler` samples a ratio of the traces. For example:
1667
2100
 
1668
2101
  ```ruby
1669
2102
  # Sample rate is between 0 (nothing sampled) to 1 (everything sampled).
1670
- sampler = Datadog::RateSampler.new(0.5) # sample 50% of the traces
2103
+ sampler = Datadog::Tracing::Sampling::RateSampler.new(0.5) # sample 50% of the traces
1671
2104
 
1672
2105
  Datadog.configure do |c|
1673
- c.tracer.sampler = sampler
2106
+ c.tracing.sampler = sampler
1674
2107
  end
1675
2108
  ```
1676
2109
 
2110
+ See [Additional Configuration](#additional-configuration) for more details about these settings.
2111
+
1677
2112
  #### Priority sampling
1678
2113
 
1679
2114
  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.
1680
2115
 
1681
2116
  The sampler can set the priority to the following values:
1682
2117
 
1683
- - `Datadog::Ext::Priority::AUTO_REJECT`: the sampler automatically decided to reject the trace.
1684
- - `Datadog::Ext::Priority::AUTO_KEEP`: the sampler automatically decided to keep the trace.
2118
+ - `Datadog::Tracing::Sampling::Ext::Priority::AUTO_REJECT`: the sampler automatically decided to reject the trace.
2119
+ - `Datadog::Tracing::Sampling::Ext::Priority::AUTO_KEEP`: the sampler automatically decided to keep the trace.
1685
2120
 
1686
2121
  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.
1687
2122
 
1688
- 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:
2123
+ You can also set this priority manually to either drop a non-interesting trace or to keep an important one. For that, set the `TraceOperation#sampling_priority` to:
1689
2124
 
1690
- - `Datadog::Ext::Priority::USER_REJECT`: the user asked to reject the trace.
1691
- - `Datadog::Ext::Priority::USER_KEEP`: the user asked to keep the trace.
2125
+ - `Datadog::Tracing::Sampling::Ext::Priority::USER_REJECT`: the user asked to reject the trace.
2126
+ - `Datadog::Tracing::Sampling::Ext::Priority::USER_KEEP`: the user asked to keep the trace.
1692
2127
 
1693
2128
  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.
1694
2129
 
1695
- If you change the priority, we recommend you do it as soon as possible - when the root span has just been created.
2130
+ For this reason, if you change the priority, we recommend you do it as early as possible.
2131
+
2132
+ To change the sampling priority, you can use the following methods:
2133
+
2134
+ ```ruby
2135
+ # Rejects the active trace
2136
+ Datadog::Tracing.reject!
2137
+
2138
+ # Keeps the active trace
2139
+ Datadog::Tracing.keep!
2140
+ ```
2141
+
2142
+ It's safe to use `Datadog::Tracing.reject!` and `Datadog::Tracing.keep!` when no trace is active.
2143
+
2144
+ You can also reject a specific trace instance:
1696
2145
 
1697
2146
  ```ruby
1698
2147
  # First, grab the active span
1699
- span = Datadog.tracer.active_span
2148
+ trace = Datadog::Tracing.active_trace
1700
2149
 
1701
- # Indicate to reject the trace
1702
- span.context.sampling_priority = Datadog::Ext::Priority::USER_REJECT
2150
+ # Rejects the trace
2151
+ trace.reject!
1703
2152
 
1704
- # Indicate to keep the trace
1705
- span.context.sampling_priority = Datadog::Ext::Priority::USER_KEEP
2153
+ # Keeps the trace
2154
+ trace.keep!
1706
2155
  ```
1707
2156
 
1708
2157
  ### Distributed Tracing
@@ -1807,9 +2256,36 @@ Service C:
1807
2256
  Priority: 1
1808
2257
  ```
1809
2258
 
2259
+ **Distributed header formats**
2260
+
2261
+ Tracing supports the following distributed trace formats:
2262
+
2263
+ - `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG` (Default)
2264
+ - `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3`
2265
+ - `Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER`
2266
+
2267
+ You can enable/disable the use of these formats via `Datadog.configure`:
2268
+
2269
+ ```ruby
2270
+ Datadog.configure do |c|
2271
+ # List of header formats that should be extracted
2272
+ c.tracing.distributed_tracing.propagation_extract_style = [
2273
+ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
2274
+ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3,
2275
+ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_B3_SINGLE_HEADER
2276
+
2277
+ ]
2278
+
2279
+ # List of header formats that should be injected
2280
+ c.tracing.distributed_tracing.propagation_inject_style = [
2281
+ Datadog::Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG
2282
+ ]
2283
+ end
2284
+ ```
2285
+
1810
2286
  **Activating distributed tracing for integrations**
1811
2287
 
1812
- Many integrations included in `ddtrace` support distributed tracing. Distributed tracing is enabled by default, but can be activated via configuration settings.
2288
+ 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.
1813
2289
 
1814
2290
  - 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)
1815
2291
  - 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)
@@ -1819,32 +2295,35 @@ For more details on how to activate distributed tracing for integrations, see th
1819
2295
 
1820
2296
  - [Excon](#excon)
1821
2297
  - [Faraday](#faraday)
1822
- - [Rest Client](#restclient)
2298
+ - [Rest Client](#rest-client)
1823
2299
  - [Net/HTTP](#nethttp)
1824
2300
  - [Rack](#rack)
1825
2301
  - [Rails](#rails)
1826
2302
  - [Sinatra](#sinatra)
2303
+ - [http.rb](#httprb)
2304
+ - [httpclient](#httpclient)
2305
+ - [httpx](#httpx)
1827
2306
 
1828
2307
  **Using the HTTP propagator**
1829
2308
 
1830
- To make the process of propagating this metadata easier, you can use the `Datadog::HTTPPropagator` module.
2309
+ To make the process of propagating this metadata easier, you can use the `Datadog::Tracing::Propagation::HTTP` module.
1831
2310
 
1832
2311
  On the client:
1833
2312
 
1834
2313
  ```ruby
1835
- Datadog.tracer.trace('web.call') do |span|
1836
- # Inject span context into headers (`env` must be a Hash)
1837
- Datadog::HTTPPropagator.inject!(span.context, env)
2314
+ Datadog::Tracing.trace('web.call') do |span, trace|
2315
+ # Inject trace headers into request headers (`env` must be a Hash)
2316
+ Datadog::Tracing::Propagation::HTTP.inject!(trace.to_digest, env)
1838
2317
  end
1839
2318
  ```
1840
2319
 
1841
2320
  On the server:
1842
2321
 
1843
2322
  ```ruby
1844
- Datadog.tracer.trace('web.work') do |span|
1845
- # Build a context from headers (`env` must be a Hash)
1846
- context = HTTPPropagator.extract(request.env)
1847
- Datadog.tracer.provider.context = context if context.trace_id
2323
+ trace_digest = Datadog::Tracing::Propagation::HTTP.extract(request.env)
2324
+
2325
+ Datadog::Tracing.trace('web.work', continue_from: trace_digest) do |span|
2326
+ # Do web work...
1848
2327
  end
1849
2328
  ```
1850
2329
 
@@ -1852,9 +2331,7 @@ end
1852
2331
 
1853
2332
  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.
1854
2333
 
1855
- This functionality is **experimental** and deactivated by default.
1856
-
1857
- To activate this feature, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
2334
+ 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:
1858
2335
 
1859
2336
  ```
1860
2337
  # /etc/nginx/conf.d/ruby_service.conf
@@ -1868,163 +2345,91 @@ server {
1868
2345
  }
1869
2346
  ```
1870
2347
 
1871
- Then you must enable the request queuing feature in the integration handling the request.
1872
-
1873
- For Rack-based applications, see the [documentation](#rack) for details for enabling this feature.
2348
+ 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.
1874
2349
 
1875
2350
  ### Processing Pipeline
1876
2351
 
1877
- 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.
1878
-
1879
- Processors can be any object that responds to `#call` accepting `trace` as an argument (which is an `Array` of `Datadog::Span`s.)
1880
-
1881
- For example:
1882
-
1883
- ```ruby
1884
- lambda_processor = ->(trace) do
1885
- # Processing logic...
1886
- trace
1887
- end
1888
-
1889
- class MyCustomProcessor
1890
- def call(trace)
1891
- # Processing logic...
1892
- trace
1893
- end
1894
- end
1895
- custom_processor = MyFancyProcessor.new
1896
- ```
1897
-
1898
- `#call` blocks of processors *must* return the `trace` object; this return value will be passed to the next processor in the pipeline.
1899
-
1900
- These processors must then be added to the pipeline via `Datadog::Pipeline.before_flush`:
1901
-
1902
- ```ruby
1903
- Datadog::Pipeline.before_flush(lambda_processor, custom_processor)
1904
- ```
1905
-
1906
- You can also define processors using the short-hand block syntax for `Datadog::Pipeline.before_flush`:
1907
-
1908
- ```ruby
1909
- Datadog::Pipeline.before_flush do |trace|
1910
- trace.delete_if { |span| span.name =~ /forbidden/ }
1911
- end
1912
- ```
2352
+ Some applications might require that traces be altered or filtered out before they are sent to Datadog. The processing pipeline allows you to create *processors* to define such behavior.
1913
2353
 
1914
2354
  #### Filtering
1915
2355
 
1916
- You can use the `Datadog::Pipeline::SpanFilter` processor to remove spans, when the block evaluates as truthy:
2356
+ You can use the `Datadog::Tracing::Pipeline::SpanFilter` processor to remove spans, when the block evaluates as truthy:
1917
2357
 
1918
2358
  ```ruby
1919
- Datadog::Pipeline.before_flush(
2359
+ Datadog::Tracing.before_flush(
1920
2360
  # Remove spans that match a particular resource
1921
- Datadog::Pipeline::SpanFilter.new { |span| span.resource =~ /PingController/ },
2361
+ Datadog::Tracing::Pipeline::SpanFilter.new { |span| span.resource =~ /PingController/ },
1922
2362
  # Remove spans that are trafficked to localhost
1923
- Datadog::Pipeline::SpanFilter.new { |span| span.get_tag('host') == 'localhost' }
2363
+ Datadog::Tracing::Pipeline::SpanFilter.new { |span| span.get_tag('host') == 'localhost' }
1924
2364
  )
1925
2365
  ```
1926
2366
 
1927
2367
  #### Processing
1928
2368
 
1929
- You can use the `Datadog::Pipeline::SpanProcessor` processor to modify spans:
2369
+ You can use the `Datadog::Tracing::Pipeline::SpanProcessor` processor to modify spans:
1930
2370
 
1931
2371
  ```ruby
1932
- Datadog::Pipeline.before_flush(
2372
+ Datadog::Tracing.before_flush(
1933
2373
  # Strip matching text from the resource field
1934
- Datadog::Pipeline::SpanProcessor.new { |span| span.resource.gsub!(/password=.*/, '') }
2374
+ Datadog::Tracing::Pipeline::SpanProcessor.new { |span| span.resource.gsub!(/password=.*/, '') }
1935
2375
  )
1936
2376
  ```
1937
2377
 
1938
- ### Trace correlation
2378
+ #### Custom processor
1939
2379
 
1940
- In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing. The tracer can produce a correlation identifier for the currently active trace via `active_correlation`, which can be used to decorate these other data sources.
2380
+ Processors can be any object that responds to `#call` accepting `trace` as an argument (which is an `Array` of `Datadog::Span`s.)
2381
+
2382
+ For example, using the short-hand block syntax:
1941
2383
 
1942
2384
  ```ruby
1943
- # When a trace is active...
1944
- Datadog.tracer.trace('correlation.example') do
1945
- # Returns #<Datadog::Correlation::Identifier>
1946
- correlation = Datadog.tracer.active_correlation
1947
- correlation.trace_id # => 5963550561812073440
1948
- correlation.span_id # => 2232727802607726424
1949
- correlation.env # => 'production' (derived from DD_ENV)
1950
- correlation.service # => 'billing-api' (derived from DD_SERVICE)
1951
- correlation.version # => '2.5.17' (derived from DD_VERSION)
2385
+ Datadog::Tracing.before_flush do |trace|
2386
+ # Processing logic...
2387
+ trace
1952
2388
  end
1953
-
1954
- # When a trace isn't active...
1955
- correlation = Datadog.tracer.active_correlation
1956
- # Returns #<Datadog::Correlation::Identifier>
1957
- correlation = Datadog.tracer.active_correlation
1958
- correlation.trace_id # => 0
1959
- correlation.span_id # => 0
1960
- correlation.env # => 'production' (derived from DD_ENV)
1961
- correlation.service # => 'billing-api' (derived from DD_SERVICE)
1962
- correlation.version # => '2.5.17' (derived from DD_VERSION)
1963
2389
  ```
1964
2390
 
1965
- #### For logging in Rails applications using Lograge (recommended)
1966
-
1967
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs:
2391
+ For a custom processor class:
1968
2392
 
1969
2393
  ```ruby
1970
- config.lograge.custom_options = lambda do |event|
1971
- # Retrieves trace information for current thread
1972
- correlation = Datadog.tracer.active_correlation
1973
-
1974
- {
1975
- # Adds IDs as tags to log output
1976
- :dd => {
1977
- # To preserve precision during JSON serialization, use strings for large numbers
1978
- :trace_id => correlation.trace_id.to_s,
1979
- :span_id => correlation.span_id.to_s,
1980
- :env => correlation.env.to_s,
1981
- :service => correlation.service.to_s,
1982
- :version => correlation.version.to_s
1983
- },
1984
- :ddsource => ["ruby"],
1985
- :params => event.payload[:params].reject { |k| %w(controller action).include? k }
1986
- }
2394
+ class MyCustomProcessor
2395
+ def call(trace)
2396
+ # Processing logic...
2397
+ trace
2398
+ end
1987
2399
  end
2400
+
2401
+ Datadog::Tracing.before_flush(MyCustomProcessor.new)
1988
2402
  ```
1989
2403
 
1990
- #### For logging in Rails applications
2404
+ In both cases, the processor method *must* return the `trace` object; this return value will be passed to the next processor in the pipeline.
1991
2405
 
1992
- Rails applications which are configured with an `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. The default Rails logger implements this tagged logging, making it easier to add correlation tags.
2406
+ ### Trace correlation
1993
2407
 
1994
- In your Rails environment configuration file, add the following:
2408
+ In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing.
1995
2409
 
1996
- ```ruby
1997
- Rails.application.configure do
1998
- config.log_tags = [proc { Datadog.tracer.active_correlation.to_s }]
1999
- end
2410
+ #### For logging in Rails applications
2000
2411
 
2001
- # Given:
2002
- # DD_ENV = 'production' (The name of the environment your application is running in.)
2003
- # DD_SERVICE = 'billing-api' (Default service name of your application.)
2004
- # DD_VERSION = '2.5.17' (The version of your application.)
2412
+ ##### Automatic
2005
2413
 
2006
- # Web requests will produce:
2007
- # [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
2008
- # [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 */*
2009
- # [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"
2010
- # [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)
2011
- ```
2414
+ For Rails applications using the default logger (`ActiveSupport::TaggedLogging`), `lograge` or `semantic_logger`, trace correlation injection is enabled by default.
2415
+
2416
+ It can be disabled by setting the environment variable `DD_LOGS_INJECTION=false`.
2012
2417
 
2013
2418
  #### For logging in Ruby applications
2014
2419
 
2015
- 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.
2420
+ To add correlation IDs to your logger, add a log formatter which retrieves the correlation IDs with `Datadog::Tracing.correlation`, then add them to the message.
2016
2421
 
2017
2422
  To properly correlate with Datadog logging, be sure the following is present in the log message, in order as they appear:
2018
2423
 
2019
- - `dd.env=<ENV>`: Where `<ENV>` is equal to `Datadog.tracer.active_correlation.env`. Omit if no environment is configured.
2020
- - `dd.service=<SERVICE>`: Where `<SERVICE>` is equal to `Datadog.tracer.active_correlation.service`. Omit if no default service name is configured.
2021
- - `dd.version=<VERSION>`: Where `<VERSION>` is equal to `Datadog.tracer.active_correlation.version`. Omit if no application version is configured.
2022
- - `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.
2023
- - `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.
2424
+ - `dd.env=<ENV>`: Where `<ENV>` is equal to `Datadog::Tracing.correlation.env`. Omit if no environment is configured.
2425
+ - `dd.service=<SERVICE>`: Where `<SERVICE>` is equal to `Datadog::Tracing.correlation.service`. Omit if no default service name is configured.
2426
+ - `dd.version=<VERSION>`: Where `<VERSION>` is equal to `Datadog::Tracing.correlation.version`. Omit if no application version is configured.
2427
+ - `dd.trace_id=<TRACE_ID>`: Where `<TRACE_ID>` is equal to `Datadog::Tracing.correlation.trace_id` or `0` if no trace is active during logging.
2428
+ - `dd.span_id=<SPAN_ID>`: Where `<SPAN_ID>` is equal to `Datadog::Tracing.correlation.span_id` or `0` if no trace is active during logging.
2024
2429
 
2025
- 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>`.
2430
+ `Datadog::Tracing.log_correlation` will return `dd.env=<ENV> dd.service=<SERVICE> dd.version=<VERSION> dd.trace_id=<TRACE_ID> dd.span_id=<SPAN_ID>`.
2026
2431
 
2027
- 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=`.
2432
+ If a trace is not active and the application environment & version is not configured, it will return `dd.env= dd.service= dd.version= dd.trace_id=0 dd.span_id=0`.
2028
2433
 
2029
2434
  An example of this in practice:
2030
2435
 
@@ -2039,7 +2444,7 @@ ENV['DD_VERSION'] = '2.5.17'
2039
2444
  logger = Logger.new(STDOUT)
2040
2445
  logger.progname = 'my_app'
2041
2446
  logger.formatter = proc do |severity, datetime, progname, msg|
2042
- "[#{datetime}][#{progname}][#{severity}][#{Datadog.tracer.active_correlation}] #{msg}\n"
2447
+ "[#{datetime}][#{progname}][#{severity}][#{Datadog::Tracing.log_correlation}] #{msg}\n"
2043
2448
  end
2044
2449
 
2045
2450
  # When no trace is active
@@ -2047,15 +2452,34 @@ logger.warn('This is an untraced operation.')
2047
2452
  # [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.
2048
2453
 
2049
2454
  # When a trace is active
2050
- Datadog.tracer.trace('my.operation') { logger.warn('This is a traced operation.') }
2455
+ Datadog::Tracing.trace('my.operation') { logger.warn('This is a traced operation.') }
2051
2456
  # [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.
2052
2457
  ```
2053
2458
 
2054
2459
  ### Configuring the transport layer
2055
2460
 
2056
- 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.
2461
+ By default, `ddtrace` will connect to the agent using the first available settings in the listed priority:
2462
+
2463
+ 1. Via any explicitly provided configuration settings (hostname/port/transport)
2464
+ 2. Via Unix Domain Socket (UDS) located at `/var/run/datadog/apm.socket`
2465
+ 3. Via HTTP over TCP to `127.0.0.1:8126`
2466
+
2467
+ However, the tracer can be configured to send its trace data to alternative destinations, or by alternative protocols.
2057
2468
 
2058
- Some basic settings, such as hostname and port, can be configured using [tracer settings](#tracer-settings).
2469
+ #### Changing default agent hostname and port
2470
+
2471
+ To change the agent host or port, provide `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
2472
+
2473
+ OR within a `Datadog.configure` block, provide the following settings:
2474
+
2475
+ ```ruby
2476
+ Datadog.configure do |c|
2477
+ c.agent.host = '127.0.0.1'
2478
+ c.agent.port = 8126
2479
+ end
2480
+ ```
2481
+
2482
+ See [Additional Configuration](#additional-configuration) for more details.
2059
2483
 
2060
2484
  #### Using the Net::HTTP adapter
2061
2485
 
@@ -2063,14 +2487,14 @@ The `Net` adapter submits traces using `Net::HTTP` over TCP. It is the default t
2063
2487
 
2064
2488
  ```ruby
2065
2489
  Datadog.configure do |c|
2066
- c.tracer.transport_options = proc { |t|
2490
+ c.tracing.transport_options = proc { |t|
2067
2491
  # Hostname, port, and additional options. :timeout is in seconds.
2068
2492
  t.adapter :net_http, '127.0.0.1', 8126, { timeout: 1 }
2069
2493
  }
2070
2494
  end
2071
2495
  ```
2072
2496
 
2073
- #### Using the Unix socket adapter
2497
+ #### Using the Unix Domain Socket (UDS) adapter
2074
2498
 
2075
2499
  The `UnixSocket` adapter submits traces using `Net::HTTP` over Unix socket.
2076
2500
 
@@ -2078,8 +2502,8 @@ To use, first configure your trace agent to listen by Unix socket, then configur
2078
2502
 
2079
2503
  ```ruby
2080
2504
  Datadog.configure do |c|
2081
- c.tracer.transport_options = proc { |t|
2082
- # Provide filepath to trace agent Unix socket
2505
+ c.tracing.transport_options = proc { |t|
2506
+ # Provide local path to trace agent Unix socket
2083
2507
  t.adapter :unix, '/tmp/ddagent/trace.sock'
2084
2508
  }
2085
2509
  end
@@ -2091,7 +2515,7 @@ The `Test` adapter is a no-op transport that can optionally buffer requests. For
2091
2515
 
2092
2516
  ```ruby
2093
2517
  Datadog.configure do |c|
2094
- c.tracer.transport_options = proc { |t|
2518
+ c.tracing.transport_options = proc { |t|
2095
2519
  # Set transport to no-op mode. Does not retain traces.
2096
2520
  t.adapter :test
2097
2521
 
@@ -2108,7 +2532,7 @@ Custom adapters can be configured with:
2108
2532
 
2109
2533
  ```ruby
2110
2534
  Datadog.configure do |c|
2111
- c.tracer.transport_options = proc { |t|
2535
+ c.tracing.transport_options = proc { |t|
2112
2536
  # Initialize and pass an instance of the adapter
2113
2537
  custom_adapter = CustomAdapter.new
2114
2538
  t.adapter custom_adapter
@@ -2116,6 +2540,23 @@ Datadog.configure do |c|
2116
2540
  end
2117
2541
  ```
2118
2542
 
2543
+ ### Setting the time provider
2544
+
2545
+ By default, tracing uses a monotonic clock to measure the duration of spans, and timestamps (`->{ Time.now }`) for the start and end time.
2546
+
2547
+ When testing, it might be helpful to use a different time provider.
2548
+
2549
+ To change the function that provides timestamps, configure the following:
2550
+
2551
+ ```ruby
2552
+ Datadog.configure do |c|
2553
+ # For Timecop, for example, `->{ Time.now_without_mock_time }` allows the tracer to use the real wall time.
2554
+ c.time_now_provider = -> { Time.now_without_mock_time }
2555
+ end
2556
+ ```
2557
+
2558
+ Span duration calculation will still use the system monotonic clock when available, thus not being affected by this setting.
2559
+
2119
2560
  ### Metrics
2120
2561
 
2121
2562
  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.
@@ -2123,7 +2564,7 @@ The tracer and its integrations can produce some additional metrics that can pro
2123
2564
  To configure your application for metrics collection:
2124
2565
 
2125
2566
  1. [Configure your Datadog agent for StatsD](https://docs.datadoghq.com/developers/dogstatsd/#setup)
2126
- 2. Add `gem 'dogstatsd-ruby'` to your Gemfile
2567
+ 2. Add `gem 'dogstatsd-ruby', '~> 5.3'` to your Gemfile
2127
2568
 
2128
2569
  #### For application runtime
2129
2570
 
@@ -2150,13 +2591,15 @@ end
2150
2591
 
2151
2592
  See the [Dogstatsd documentation](https://www.rubydoc.info/github/DataDog/dogstatsd-ruby/master/frames) for more details about configuring `Datadog::Statsd`.
2152
2593
 
2153
- The stats sent will include:
2594
+ The stats are VM specific and will include:
2154
2595
 
2155
- | Name | Type | Description |
2156
- | -------------------------- | ------- | -------------------------------------------------------- |
2157
- | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. |
2158
- | `runtime.ruby.thread_count` | `gauge` | Number of threads. |
2159
- | `runtime.ruby.gc.*`. | `gauge` | Garbage collection statistics (one per value in GC.stat) |
2596
+ | Name | Type | Description | Available on |
2597
+ | -------------------------- | ------- | -------------------------------------------------------- | ------------ |
2598
+ | `runtime.ruby.class_count` | `gauge` | Number of classes in memory space. | CRuby |
2599
+ | `runtime.ruby.gc.*` | `gauge` | Garbage collection statistics: collected from `GC.stat`. | All runtimes |
2600
+ | `runtime.ruby.thread_count` | `gauge` | Number of threads. | All runtimes |
2601
+ | `runtime.ruby.global_constant_state` | `gauge` | Global constant cache generation. | CRuby |
2602
+ | `runtime.ruby.global_method_state` | `gauge` | [Global method cache generation.](https://tenderlovemaking.com/2015/12/23/inline-caching-in-mri.html) | [CRuby < 3.0.0](https://docs.ruby-lang.org/en/3.0.0/NEWS_md.html#label-Implementation+improvements) |
2160
2603
 
2161
2604
  In addition, all metrics include the following tags:
2162
2605
 
@@ -2167,7 +2610,7 @@ In addition, all metrics include the following tags:
2167
2610
 
2168
2611
  ### OpenTracing
2169
2612
 
2170
- For setting up Datadog with OpenTracing, see out [Quickstart for OpenTracing](#quickstart-for-opentracing) section for details.
2613
+ For setting up Datadog with OpenTracing, see our [Configuring OpenTracing](#configuring-opentracing) section for details.
2171
2614
 
2172
2615
  **Configuring Datadog tracer settings**
2173
2616
 
@@ -2175,10 +2618,10 @@ The underlying Datadog tracer can be configured by passing options (which match
2175
2618
 
2176
2619
  ```ruby
2177
2620
  # Where `options` is a Hash of options provided to Datadog::Tracer
2178
- OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new(options)
2621
+ OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new(**options)
2179
2622
  ```
2180
2623
 
2181
- It can also be configured by using `Datadog.configure` described in the [Tracer settings](#tracer-settings) section.
2624
+ It can also be configured by using `Datadog.configure` described in the [Additional Configuration](#additional-configuration) section.
2182
2625
 
2183
2626
  **Activating and configuring integrations**
2184
2627
 
@@ -2193,3 +2636,53 @@ However, additional instrumentation provided by Datadog can be activated alongsi
2193
2636
  | `OpenTracing::FORMAT_TEXT_MAP` | Yes | |
2194
2637
  | `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. |
2195
2638
  | `OpenTracing::FORMAT_BINARY` | No | |
2639
+
2640
+ ### Profiling
2641
+
2642
+ *Currently available as BETA feature.*
2643
+
2644
+ `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.
2645
+
2646
+ **Setup**
2647
+
2648
+ To get started with profiling, follow the [Enabling the Ruby Profiler](https://docs.datadoghq.com/tracing/profiler/enabling/ruby/) guide.
2649
+
2650
+ #### Troubleshooting
2651
+
2652
+ If you run into issues with profiling, please check the [Profiler Troubleshooting Guide](https://docs.datadoghq.com/tracing/profiler/profiler_troubleshooting/?code-lang=ruby).
2653
+
2654
+ #### Profiling Resque jobs
2655
+
2656
+ 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.
2657
+
2658
+ 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.
2659
+
2660
+ ## Known issues and suggested configurations
2661
+
2662
+ ### Payload too large
2663
+
2664
+ 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.
2665
+
2666
+ If traces are missing, enable [debug mode](#debugging-and-diagnostics) to check if messages containing `"Dropping trace. Payload too large"` are logged.
2667
+
2668
+ 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.
2669
+
2670
+ If you have confirmed that traces are dropped due to large payloads, then enable the [partial_flush](#additional-configuration) setting to break down large traces into smaller chunks.
2671
+
2672
+ ### Stack level too deep
2673
+
2674
+ 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.
2675
+
2676
+ 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.)
2677
+
2678
+ 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.
2679
+
2680
+ Datadog instrumentation almost exclusively uses the `Module#prepend` feature to add instrumentation non-destructively. However, some other 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.
2681
+
2682
+ As the implementation of `alias_method` exists within those libraries, Datadog generally cannot fix them. However, some libraries have known workarounds:
2683
+
2684
+ * `rack-mini-profiler`: [Net::HTTP stack level too deep errors](https://github.com/MiniProfiler/rack-mini-profiler#nethttp-stack-level-too-deep-errors).
2685
+
2686
+ For libraries without a known workaround, consider removing the library using `alias` or `Module#alias_method` or separating libraries into different environments for testing.
2687
+
2688
+ For any further questions or to report an occurence of this issue, please [reach out to Datadog support](https://docs.datadoghq.com/help)