ddtrace 1.10.0 → 1.11.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (360) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -2
  3. data/LICENSE-3rdparty.csv +1 -0
  4. data/README.md +8 -9
  5. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +76 -11
  6. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +26 -3
  7. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -0
  8. data/lib/datadog/appsec/component.rb +41 -7
  9. data/lib/datadog/appsec/configuration/settings.rb +20 -4
  10. data/lib/datadog/appsec/configuration.rb +8 -0
  11. data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -0
  12. data/lib/datadog/appsec/contrib/configuration/settings.rb +2 -0
  13. data/lib/datadog/appsec/contrib/integration.rb +2 -0
  14. data/lib/datadog/appsec/contrib/patcher.rb +2 -0
  15. data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -0
  16. data/lib/datadog/appsec/contrib/rack/gateway/request.rb +7 -25
  17. data/lib/datadog/appsec/contrib/rack/gateway/response.rb +1 -1
  18. data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -0
  19. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -0
  20. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +17 -3
  21. data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -0
  22. data/lib/datadog/appsec/contrib/rails/framework.rb +2 -0
  23. data/lib/datadog/appsec/contrib/rails/gateway/request.rb +1 -1
  24. data/lib/datadog/appsec/contrib/rails/request.rb +2 -0
  25. data/lib/datadog/appsec/contrib/rails/request_middleware.rb +2 -0
  26. data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -0
  27. data/lib/datadog/appsec/contrib/sinatra/framework.rb +2 -0
  28. data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +1 -1
  29. data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +2 -0
  30. data/lib/datadog/appsec/extensions.rb +2 -0
  31. data/lib/datadog/appsec/instrumentation/gateway/argument.rb +2 -4
  32. data/lib/datadog/appsec/processor/rule_loader.rb +63 -0
  33. data/lib/datadog/appsec/processor/rule_merger.rb +146 -0
  34. data/lib/datadog/appsec/processor.rb +15 -70
  35. data/lib/datadog/appsec/remote.rb +121 -0
  36. data/lib/datadog/appsec/utils/http.rb +2 -0
  37. data/lib/datadog/appsec/utils.rb +2 -0
  38. data/lib/datadog/appsec.rb +18 -4
  39. data/lib/datadog/ci/configuration/components.rb +2 -0
  40. data/lib/datadog/ci/configuration/settings.rb +2 -0
  41. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -0
  42. data/lib/datadog/ci/contrib/cucumber/formatter.rb +2 -0
  43. data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -0
  44. data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -0
  45. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -0
  46. data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -0
  47. data/lib/datadog/ci/ext/environment.rb +2 -20
  48. data/lib/datadog/ci/extensions.rb +2 -0
  49. data/lib/datadog/ci/flush.rb +2 -0
  50. data/lib/datadog/ci.rb +2 -0
  51. data/lib/datadog/core/buffer/cruby.rb +2 -0
  52. data/lib/datadog/core/buffer/random.rb +2 -0
  53. data/lib/datadog/core/buffer/thread_safe.rb +2 -0
  54. data/lib/datadog/core/chunker.rb +2 -0
  55. data/lib/datadog/core/configuration/agent_settings_resolver.rb +6 -6
  56. data/lib/datadog/core/configuration/components.rb +12 -15
  57. data/lib/datadog/core/configuration/dependency_resolver.rb +2 -0
  58. data/lib/datadog/core/configuration/option.rb +2 -0
  59. data/lib/datadog/core/configuration/option_definition.rb +2 -0
  60. data/lib/datadog/core/configuration/option_definition_set.rb +2 -0
  61. data/lib/datadog/core/configuration/option_set.rb +2 -0
  62. data/lib/datadog/core/configuration/settings.rb +68 -13
  63. data/lib/datadog/core/diagnostics/health.rb +2 -0
  64. data/lib/datadog/core/environment/class_count.rb +2 -0
  65. data/lib/datadog/core/environment/gc.rb +2 -0
  66. data/lib/datadog/core/environment/identity.rb +2 -0
  67. data/lib/datadog/core/environment/socket.rb +2 -0
  68. data/lib/datadog/core/environment/thread_count.rb +2 -0
  69. data/lib/datadog/core/environment/variable_helpers.rb +10 -2
  70. data/lib/datadog/core/environment/vm_cache.rb +2 -0
  71. data/lib/datadog/core/extensions.rb +2 -0
  72. data/lib/datadog/core/header_collection.rb +2 -0
  73. data/lib/datadog/core/metrics/helpers.rb +2 -0
  74. data/lib/datadog/core/metrics/metric.rb +2 -0
  75. data/lib/datadog/core/remote/client/capabilities.rb +57 -0
  76. data/lib/datadog/core/remote/client.rb +146 -0
  77. data/lib/datadog/core/remote/component.rb +150 -0
  78. data/lib/datadog/core/remote/configuration/content.rb +82 -0
  79. data/lib/datadog/core/remote/configuration/digest.rb +62 -0
  80. data/lib/datadog/core/remote/configuration/path.rb +90 -0
  81. data/lib/datadog/core/remote/configuration/repository.rb +278 -0
  82. data/lib/datadog/core/remote/configuration/target.rb +72 -0
  83. data/lib/datadog/core/remote/configuration.rb +18 -0
  84. data/lib/datadog/core/remote/dispatcher.rb +59 -0
  85. data/lib/datadog/core/remote/ext.rb +12 -0
  86. data/lib/datadog/core/remote/worker.rb +96 -0
  87. data/lib/datadog/core/remote.rb +24 -0
  88. data/lib/datadog/core/telemetry/collector.rb +8 -9
  89. data/lib/datadog/core/telemetry/heartbeat.rb +2 -0
  90. data/lib/datadog/core/telemetry/http/env.rb +2 -0
  91. data/lib/datadog/core/telemetry/http/transport.rb +2 -0
  92. data/lib/datadog/core/telemetry/v1/app_event.rb +2 -0
  93. data/lib/datadog/core/telemetry/v1/application.rb +7 -1
  94. data/lib/datadog/core/telemetry/v1/dependency.rb +7 -1
  95. data/lib/datadog/core/telemetry/v1/host.rb +9 -1
  96. data/lib/datadog/core/telemetry/v1/integration.rb +7 -1
  97. data/lib/datadog/core/telemetry/v1/product.rb +9 -1
  98. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +7 -1
  99. data/lib/datadog/core/transport/config.rb +58 -0
  100. data/lib/datadog/core/transport/http/api/instance.rb +37 -0
  101. data/lib/datadog/core/transport/http/api/spec.rb +19 -0
  102. data/lib/datadog/core/transport/http/api.rb +57 -0
  103. data/lib/datadog/core/transport/http/builder.rb +217 -0
  104. data/lib/datadog/core/transport/http/client.rb +45 -0
  105. data/lib/datadog/core/transport/http/config.rb +268 -0
  106. data/lib/datadog/core/transport/http/negotiation.rb +144 -0
  107. data/lib/datadog/core/transport/http.rb +169 -0
  108. data/lib/datadog/core/transport/negotiation.rb +60 -0
  109. data/lib/datadog/core/utils/compression.rb +2 -0
  110. data/lib/datadog/core/utils/hash.rb +32 -0
  111. data/lib/datadog/core/utils/network.rb +140 -0
  112. data/lib/datadog/core/utils/object_set.rb +2 -0
  113. data/lib/datadog/core/utils/safe_dup.rb +20 -2
  114. data/lib/datadog/core/utils/sequence.rb +2 -0
  115. data/lib/datadog/core/utils/time.rb +2 -0
  116. data/lib/datadog/core/vendor/ipaddr.rb +78 -0
  117. data/lib/datadog/core/worker.rb +2 -0
  118. data/lib/datadog/core/workers/interval_loop.rb +2 -0
  119. data/lib/datadog/core/workers/queue.rb +2 -0
  120. data/lib/datadog/core/workers/runtime_metrics.rb +2 -0
  121. data/lib/datadog/kit/appsec/events.rb +1 -1
  122. data/lib/datadog/kit.rb +2 -0
  123. data/lib/datadog/opentracer/binary_propagator.rb +2 -0
  124. data/lib/datadog/opentracer/carrier.rb +2 -0
  125. data/lib/datadog/opentracer/global_tracer.rb +2 -0
  126. data/lib/datadog/opentracer/propagator.rb +2 -0
  127. data/lib/datadog/opentracer/scope.rb +2 -0
  128. data/lib/datadog/opentracer/scope_manager.rb +2 -0
  129. data/lib/datadog/opentracer/span_context.rb +2 -0
  130. data/lib/datadog/opentracer/span_context_factory.rb +2 -0
  131. data/lib/datadog/opentracer/thread_local_scope.rb +2 -0
  132. data/lib/datadog/opentracer.rb +2 -0
  133. data/lib/datadog/profiling/backtrace_location.rb +2 -0
  134. data/lib/datadog/profiling/buffer.rb +2 -0
  135. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +19 -3
  136. data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +2 -0
  137. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
  138. data/lib/datadog/profiling/collectors/stack.rb +2 -0
  139. data/lib/datadog/profiling/collectors/thread_context.rb +2 -2
  140. data/lib/datadog/profiling/component.rb +103 -29
  141. data/lib/datadog/profiling/event.rb +2 -0
  142. data/lib/datadog/profiling/events/stack.rb +2 -0
  143. data/lib/datadog/profiling/ext.rb +28 -26
  144. data/lib/datadog/profiling/flush.rb +2 -0
  145. data/lib/datadog/profiling/native_extension.rb +2 -0
  146. data/lib/datadog/profiling/pprof/message_set.rb +2 -0
  147. data/lib/datadog/profiling/pprof/payload.rb +2 -0
  148. data/lib/datadog/profiling/pprof/string_table.rb +2 -0
  149. data/lib/datadog/profiling/preload.rb +2 -0
  150. data/lib/datadog/profiling/scheduler.rb +3 -1
  151. data/lib/datadog/profiling/stack_recorder.rb +0 -18
  152. data/lib/datadog/profiling/tag_builder.rb +2 -0
  153. data/lib/datadog/profiling/tasks/setup.rb +0 -26
  154. data/lib/datadog/profiling.rb +2 -1
  155. data/lib/datadog/tracing/analytics.rb +2 -0
  156. data/lib/datadog/tracing/client_ip.rb +39 -140
  157. data/lib/datadog/tracing/configuration/ext.rb +7 -0
  158. data/lib/datadog/tracing/configuration/settings.rb +14 -0
  159. data/lib/datadog/tracing/context.rb +2 -0
  160. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -0
  161. data/lib/datadog/tracing/contrib/action_cable/event.rb +2 -0
  162. data/lib/datadog/tracing/contrib/action_cable/events.rb +2 -0
  163. data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -0
  164. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -0
  165. data/lib/datadog/tracing/contrib/action_mailer/event.rb +2 -0
  166. data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -0
  167. data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -0
  168. data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -24
  169. data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -0
  170. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +14 -1
  171. data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
  172. data/lib/datadog/tracing/contrib/action_view/event.rb +2 -0
  173. data/lib/datadog/tracing/contrib/action_view/events.rb +2 -0
  174. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +2 -0
  175. data/lib/datadog/tracing/contrib/active_job/event.rb +2 -0
  176. data/lib/datadog/tracing/contrib/active_job/events.rb +2 -0
  177. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +2 -0
  178. data/lib/datadog/tracing/contrib/active_job/patcher.rb +2 -0
  179. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -0
  180. data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +2 -0
  181. data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -0
  182. data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +2 -0
  183. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +2 -0
  184. data/lib/datadog/tracing/contrib/active_record/event.rb +2 -0
  185. data/lib/datadog/tracing/contrib/active_record/events.rb +2 -0
  186. data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -0
  187. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +2 -0
  188. data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -0
  189. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -0
  190. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -0
  191. data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +2 -0
  192. data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -0
  193. data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -0
  194. data/lib/datadog/tracing/contrib/analytics.rb +2 -0
  195. data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -0
  196. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +9 -1
  197. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +8 -2
  198. data/lib/datadog/tracing/contrib/aws/patcher.rb +2 -0
  199. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -0
  200. data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +2 -0
  201. data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +2 -0
  202. data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -0
  203. data/lib/datadog/tracing/contrib/configurable.rb +2 -0
  204. data/lib/datadog/tracing/contrib/configuration/resolver.rb +2 -0
  205. data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
  206. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +2 -0
  207. data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -0
  208. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +2 -0
  209. data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +2 -0
  210. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -0
  211. data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +2 -0
  212. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +2 -0
  213. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +2 -0
  214. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +2 -0
  215. data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -0
  216. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +2 -0
  217. data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -0
  218. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +2 -0
  219. data/lib/datadog/tracing/contrib/faraday/connection.rb +2 -0
  220. data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +2 -0
  221. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +2 -0
  222. data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -0
  223. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -0
  224. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +2 -0
  225. data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +2 -0
  226. data/lib/datadog/tracing/contrib/grpc/patcher.rb +2 -0
  227. data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +2 -0
  228. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +2 -0
  229. data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -0
  230. data/lib/datadog/tracing/contrib/hanami/plugin.rb +2 -0
  231. data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +2 -0
  232. data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +2 -0
  233. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +2 -0
  234. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +2 -0
  235. data/lib/datadog/tracing/contrib/http/integration.rb +2 -0
  236. data/lib/datadog/tracing/contrib/http/patcher.rb +2 -0
  237. data/lib/datadog/tracing/contrib/http_annotation_helper.rb +2 -0
  238. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -0
  239. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -0
  240. data/lib/datadog/tracing/contrib/integration.rb +2 -0
  241. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -0
  242. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +2 -0
  243. data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +2 -0
  244. data/lib/datadog/tracing/contrib/kafka/event.rb +2 -0
  245. data/lib/datadog/tracing/contrib/kafka/events.rb +2 -0
  246. data/lib/datadog/tracing/contrib/kafka/patcher.rb +2 -0
  247. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -0
  248. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -0
  249. data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -0
  250. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -0
  251. data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +2 -0
  252. data/lib/datadog/tracing/contrib/mongodb/patcher.rb +2 -0
  253. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -0
  254. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -0
  255. data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -0
  256. data/lib/datadog/tracing/contrib/patchable.rb +2 -0
  257. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -0
  258. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +2 -0
  259. data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -0
  260. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -0
  261. data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +2 -0
  262. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -0
  263. data/lib/datadog/tracing/contrib/qless/patcher.rb +2 -0
  264. data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +2 -0
  265. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -0
  266. data/lib/datadog/tracing/contrib/racecar/event.rb +2 -0
  267. data/lib/datadog/tracing/contrib/racecar/events.rb +2 -0
  268. data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -0
  269. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +9 -2
  270. data/lib/datadog/tracing/contrib/rails/framework.rb +2 -0
  271. data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -0
  272. data/lib/datadog/tracing/contrib/rails/utils.rb +3 -1
  273. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +2 -0
  274. data/lib/datadog/tracing/contrib/rake/patcher.rb +2 -0
  275. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -0
  276. data/lib/datadog/tracing/contrib/redis/tags.rb +2 -0
  277. data/lib/datadog/tracing/contrib/registerable.rb +2 -0
  278. data/lib/datadog/tracing/contrib/registry.rb +2 -0
  279. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +2 -0
  280. data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -0
  281. data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
  282. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -0
  283. data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -0
  284. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
  285. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +34 -0
  286. data/lib/datadog/tracing/contrib/roda/ext.rb +18 -0
  287. data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
  288. data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
  289. data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
  290. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -0
  291. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -0
  292. data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -0
  293. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -0
  294. data/lib/datadog/tracing/contrib/sequel/dataset.rb +2 -0
  295. data/lib/datadog/tracing/contrib/sequel/patcher.rb +2 -0
  296. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +2 -0
  297. data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -0
  298. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
  299. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +12 -3
  300. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -0
  301. data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +38 -0
  302. data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +2 -0
  303. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +2 -0
  304. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +2 -0
  305. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +2 -0
  306. data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +2 -0
  307. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +18 -2
  308. data/lib/datadog/tracing/contrib/sidekiq/{tracing.rb → utils.rb} +3 -1
  309. data/lib/datadog/tracing/contrib/sinatra/headers.rb +2 -0
  310. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -0
  311. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +2 -0
  312. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +28 -0
  313. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -0
  314. data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +2 -0
  315. data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +2 -0
  316. data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
  317. data/lib/datadog/tracing/contrib.rb +3 -0
  318. data/lib/datadog/tracing/correlation.rb +10 -10
  319. data/lib/datadog/tracing/diagnostics/health.rb +2 -0
  320. data/lib/datadog/tracing/distributed/trace_context.rb +22 -15
  321. data/lib/datadog/tracing/flush.rb +2 -0
  322. data/lib/datadog/tracing/metadata/analytics.rb +2 -0
  323. data/lib/datadog/tracing/metadata/errors.rb +2 -0
  324. data/lib/datadog/tracing/metadata/ext.rb +6 -0
  325. data/lib/datadog/tracing/metadata.rb +2 -0
  326. data/lib/datadog/tracing/pipeline/span_filter.rb +2 -0
  327. data/lib/datadog/tracing/pipeline/span_processor.rb +2 -0
  328. data/lib/datadog/tracing/propagation/http.rb +2 -0
  329. data/lib/datadog/tracing/runtime/metrics.rb +2 -0
  330. data/lib/datadog/tracing/sampling/all_sampler.rb +2 -0
  331. data/lib/datadog/tracing/sampling/matcher.rb +2 -0
  332. data/lib/datadog/tracing/sampling/priority_sampler.rb +2 -0
  333. data/lib/datadog/tracing/sampling/span/sampler.rb +2 -0
  334. data/lib/datadog/tracing/sync_writer.rb +2 -0
  335. data/lib/datadog/tracing/trace_digest.rb +2 -0
  336. data/lib/datadog/tracing/utils.rb +2 -0
  337. data/lib/datadog/tracing.rb +2 -0
  338. data/lib/ddtrace/auto_instrument.rb +2 -0
  339. data/lib/ddtrace/auto_instrument_base.rb +2 -0
  340. data/lib/ddtrace/transport/http/adapters/net.rb +12 -0
  341. data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
  342. data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
  343. data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
  344. data/lib/ddtrace/transport/http/api/instance.rb +2 -0
  345. data/lib/ddtrace/transport/http/api/map.rb +2 -0
  346. data/lib/ddtrace/transport/http/api/spec.rb +2 -0
  347. data/lib/ddtrace/transport/http/env.rb +2 -0
  348. data/lib/ddtrace/transport/http/response.rb +2 -0
  349. data/lib/ddtrace/transport/http/traces.rb +1 -1
  350. data/lib/ddtrace/transport/io/response.rb +2 -0
  351. data/lib/ddtrace/transport/io/traces.rb +2 -0
  352. data/lib/ddtrace/transport/io.rb +2 -0
  353. data/lib/ddtrace/transport/parcel.rb +2 -0
  354. data/lib/ddtrace/transport/request.rb +3 -1
  355. data/lib/ddtrace/transport/statistics.rb +2 -0
  356. data/lib/ddtrace/transport/trace_formatter.rb +2 -0
  357. data/lib/ddtrace/transport/traces.rb +1 -1
  358. data/lib/ddtrace/version.rb +6 -4
  359. data/lib/ddtrace.rb +2 -0
  360. metadata +45 -9
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ipaddr'
4
+ require_relative '../vendor/ipaddr'
5
+
6
+ module Datadog
7
+ module Core
8
+ module Utils
9
+ # Common Network utility functions.
10
+ module Network
11
+ DEFAULT_IP_HEADERS_NAMES = %w[
12
+ x-forwarded-for
13
+ x-real-ip
14
+ true-client-ip
15
+ x-client-ip
16
+ x-forwarded
17
+ forwarded-for
18
+ x-cluster-client-ip
19
+ fastly-client-ip
20
+ cf-connecting-ip
21
+ cf-connecting-ipv6
22
+ ].freeze
23
+
24
+ class << self
25
+ # Returns a client IP associated with the request if it was
26
+ # retrieved successfully.
27
+ #
28
+ #
29
+ # @param [Datadog::Core::HeaderCollection, #get, nil] headers The request headers
30
+ # @param [Array<String>] list of headers to check.
31
+ # @return [String] IP value without the port and the zone indentifier.
32
+ # @return [nil] when no valid IP value found.
33
+ def stripped_ip_from_request_headers(headers, ip_headers_to_check: DEFAULT_IP_HEADERS_NAMES)
34
+ ip = ip_header(headers, ip_headers_to_check)
35
+
36
+ ip ? ip.to_s : nil
37
+ end
38
+
39
+ # @param [String] IP value.
40
+ # @return [String] IP value without the port and the zone indentifier.
41
+ # @return [nil] when no valid IP value found.
42
+ def stripped_ip(ip)
43
+ ip = ip_to_ipaddr(ip)
44
+ ip ? ip.to_s : nil
45
+ end
46
+
47
+ private
48
+
49
+ # @param [String] IP value.
50
+ # @return [IPaddr]
51
+ # @return [nil] when no valid IP value found.
52
+ def ip_to_ipaddr(ip)
53
+ return unless ip
54
+
55
+ clean_ip = if likely_ipv4?(ip)
56
+ strip_ipv4_port(ip)
57
+ else
58
+ strip_zone_specifier(strip_ipv6_port(ip))
59
+ end
60
+
61
+ begin
62
+ IPAddr.new(clean_ip)
63
+ rescue IPAddr::Error
64
+ nil
65
+ end
66
+ end
67
+
68
+ def ip_header(headers, ip_headers_to_check)
69
+ return unless headers
70
+
71
+ ip_headers_to_check.each do |name|
72
+ value = headers.get(name)
73
+
74
+ next unless value
75
+
76
+ ips = value.split(',')
77
+ ips.each do |ip|
78
+ parsed_ip = ip_to_ipaddr(ip.strip)
79
+
80
+ return parsed_ip if global_ip?(parsed_ip)
81
+ end
82
+ end
83
+
84
+ nil
85
+ end
86
+
87
+ # Returns whether the given value is more likely to be an IPv4 than an IPv6 address.
88
+ #
89
+ # This is done by checking if a dot (`'.'`) character appears before a colon (`':'`) in the value.
90
+ # The rationale is that in valid IPv6 addresses, colons will always preced dots,
91
+ # and in valid IPv4 addresses dots will always preced colons.
92
+ def likely_ipv4?(value)
93
+ dot_index = value.index('.') || value.size
94
+ colon_index = value.index(':') || value.size
95
+
96
+ dot_index < colon_index
97
+ end
98
+
99
+ def strip_zone_specifier(ipv6)
100
+ ipv6.gsub(/%.*/, '')
101
+ end
102
+
103
+ def strip_ipv6_port(ip)
104
+ if /\[(.*)\](?::\d+)?/ =~ ip
105
+ Regexp.last_match(1)
106
+ else
107
+ ip
108
+ end
109
+ end
110
+
111
+ def strip_ipv4_port(ip)
112
+ ip.gsub(/:\d+\z/, '')
113
+ end
114
+
115
+ def global_ip?(parsed_ip)
116
+ parsed_ip && !private?(parsed_ip) && !loopback?(parsed_ip) && !link_local?(parsed_ip)
117
+ end
118
+
119
+ # TODO: remove once we drop support for ruby 2.1, 2.2, 2.3, 2.4
120
+ # replace with ip.private?
121
+ def private?(ip)
122
+ Datadog::Core::Vendor::IPAddr.private?(ip)
123
+ end
124
+
125
+ # TODO: remove once we drop support for ruby 2.1, 2.2, 2.3, 2.4
126
+ # replace with ip.link_local?
127
+ def link_local?(ip)
128
+ Datadog::Core::Vendor::IPAddr.link_local?(ip)
129
+ end
130
+
131
+ # TODO: remove once we drop support for ruby 2.1, 2.2, 2.3, 2.4
132
+ # replace with ip.loopback
133
+ def loopback?(ip)
134
+ Datadog::Core::Vendor::IPAddr.loopback?(ip)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'sequence'
2
4
 
3
5
  module Datadog
@@ -16,8 +16,26 @@ module Datadog
16
16
  using RefineNil
17
17
  end
18
18
 
19
- def self.frozen_or_dup(v)
20
- v.frozen? ? v : v.dup
19
+ # String#+@ was introduced in Ruby 2.3
20
+ if String.method_defined?(:+@) && String.method_defined?(:-@)
21
+ def self.frozen_or_dup(v)
22
+ # If the string is not frozen, the +(-v) will:
23
+ # - first create a frozen deduplicated copy with -v
24
+ # - then it will dup it more efficiently with +v
25
+ v.frozen? ? v : +(-v)
26
+ end
27
+
28
+ def self.frozen_dup(v)
29
+ -v if v
30
+ end
31
+ else
32
+ def self.frozen_or_dup(v)
33
+ v.frozen? ? v : v.dup
34
+ end
35
+
36
+ def self.frozen_dup(v)
37
+ v.frozen? ? v : v.dup.freeze
38
+ end
21
39
  end
22
40
  end
23
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Utils
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Utils
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org>
2
+ # Copyright (c) 2007-2017 Akinori MUSHA <knu@iDaemons.org>
3
+
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions
6
+ # are met:
7
+ # 1. Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+
13
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
+ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
+ # SUCH DAMAGE.
24
+
25
+ module Datadog
26
+ module Core
27
+ module Vendor
28
+ # vendor code from https://github.com/ruby/ipaddr/blob/master/lib/ipaddr.rb
29
+ # Ruby version below 2.5 does not have the IpAddr#private? method
30
+ # We have to vendor the code because ruby versions below 2.5 did not extract ipaddr as a gem
31
+ # So we can not specify a specific version for ipaddr for ruby versions: 2.1, 2.2, 2.3, 2.4
32
+ module IPAddr
33
+ class << self
34
+ def private?(ip)
35
+ addr = ip.instance_variable_get(:@addr)
36
+
37
+ case ip.family
38
+ when Socket::AF_INET
39
+ addr & 0xff000000 == 0x0a000000 || # 10.0.0.0/8
40
+ addr & 0xfff00000 == 0xac100000 || # 172.16.0.0/12
41
+ addr & 0xffff0000 == 0xc0a80000 # 192.168.0.0/16
42
+ when Socket::AF_INET6
43
+ addr & 0xfe00_0000_0000_0000_0000_0000_0000_0000 == 0xfc00_0000_0000_0000_0000_0000_0000_0000
44
+ else
45
+ raise ::IPAddr::AddressFamilyError, 'unsupported address family'
46
+ end
47
+ end
48
+
49
+ def link_local?(ip)
50
+ addr = ip.instance_variable_get(:@addr)
51
+
52
+ case ip.family
53
+ when Socket::AF_INET
54
+ addr & 0xffff0000 == 0xa9fe0000 # 169.254.0.0/16
55
+ when Socket::AF_INET6
56
+ addr & 0xffc0_0000_0000_0000_0000_0000_0000_0000 == 0xfe80_0000_0000_0000_0000_0000_0000_0000
57
+ else
58
+ raise ::IPAddr::AddressFamilyError, 'unsupported address family'
59
+ end
60
+ end
61
+
62
+ def loopback?(ip)
63
+ addr = ip.instance_variable_get(:@addr)
64
+
65
+ case ip.family
66
+ when Socket::AF_INET
67
+ addr & 0xff000000 == 0x7f000000
68
+ when Socket::AF_INET6
69
+ addr == 1
70
+ else
71
+ raise ::IPAddr::AddressFamilyError, 'unsupported address family'
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  # Base class for work tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Workers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Core
3
5
  module Workers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../runtime/metrics'
2
4
 
3
5
  require_relative '../worker'
@@ -23,7 +23,7 @@ module Datadog
23
23
  track(LOGIN_SUCCESS_EVENT, trace, **others)
24
24
 
25
25
  user_options = user.dup
26
- user_id = user.delete(:id)
26
+ user_id = user_options.delete(:id)
27
27
 
28
28
  raise ArgumentError, 'missing required key: :user => { :id }' if user_id.nil?
29
29
 
data/lib/datadog/kit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  # Datadog::Kit holds public-facing APIs for higher level user-facing
3
5
  # features, these features not belonging to a specific product. Contrary to
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # OpenTracing propagator for Datadog::OpenTracer::Tracer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # @public_api
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # Patch for OpenTracing module
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # OpenTracing propagator for Datadog::OpenTracer::Tracer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # OpenTracing adapter for scope
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # @public_api
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # OpenTracing adapter for SpanContext
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # Creates new Datadog::OpenTracer::SpanContext
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module OpenTracer
3
5
  # OpenTracing adapter for thread local scopes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'opentracing'
2
4
  require 'opentracing/carrier'
3
5
  require_relative 'tracing'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Profiling
3
5
  # Entity class used to represent an entry in a stack trace.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../core/buffer/thread_safe'
2
4
  require_relative '../core/utils/object_set'
3
5
  require_relative '../core/utils/string_table'
@@ -17,17 +17,33 @@ module Datadog
17
17
  recorder:,
18
18
  max_frames:,
19
19
  tracer:,
20
+ endpoint_collection_enabled:,
20
21
  gc_profiling_enabled:,
21
22
  allocation_counting_enabled:,
22
- thread_context_collector: ThreadContext.new(recorder: recorder, max_frames: max_frames, tracer: tracer),
23
- idle_sampling_helper: IdleSamplingHelper.new
23
+ thread_context_collector: ThreadContext.new(
24
+ recorder: recorder,
25
+ max_frames: max_frames,
26
+ tracer: tracer,
27
+ endpoint_collection_enabled: endpoint_collection_enabled,
28
+ ),
29
+ idle_sampling_helper: IdleSamplingHelper.new,
30
+ # **NOTE**: This should only be used for testing; disabling the dynamic sampling rate will increase the
31
+ # profiler overhead!
32
+ dynamic_sampling_rate_enabled: true
24
33
  )
34
+ unless dynamic_sampling_rate_enabled
35
+ Datadog.logger.warn(
36
+ 'Profiling dynamic sampling rate disabled. This should only be used for testing, and will increase overhead!'
37
+ )
38
+ end
39
+
25
40
  self.class._native_initialize(
26
41
  self,
27
42
  thread_context_collector,
28
43
  gc_profiling_enabled,
29
44
  idle_sampling_helper,
30
- allocation_counting_enabled
45
+ allocation_counting_enabled,
46
+ dynamic_sampling_rate_enabled,
31
47
  )
32
48
  @worker_thread = nil
33
49
  @failure_exception = nil
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Profiling
3
5
  module Collectors
@@ -47,7 +47,7 @@ module Datadog
47
47
  true
48
48
  end
49
49
 
50
- def stop(*_)
50
+ def stop(*_unused)
51
51
  @start_stop_mutex.synchronize do
52
52
  Datadog.logger.debug('Requesting IdleSamplingHelper thread shut down')
53
53
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Profiling
3
5
  module Collectors
@@ -14,9 +14,9 @@ module Datadog
14
14
  #
15
15
  # Methods prefixed with _native_ are implemented in `collectors_thread_context.c`
16
16
  class ThreadContext
17
- def initialize(recorder:, max_frames:, tracer:)
17
+ def initialize(recorder:, max_frames:, tracer:, endpoint_collection_enabled:)
18
18
  tracer_context_key = safely_extract_context_key_from(tracer)
19
- self.class._native_initialize(self, recorder, max_frames, tracer_context_key)
19
+ self.class._native_initialize(self, recorder, max_frames, tracer_context_key, endpoint_collection_enabled)
20
20
  end
21
21
 
22
22
  def inspect