ddtrace 1.12.1 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +129 -9
  3. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +97 -14
  4. data/ext/ddtrace_profiling_native_extension/extconf.rb +6 -0
  5. data/ext/ddtrace_profiling_native_extension/http_transport.c +19 -6
  6. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -1
  7. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +41 -2
  8. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +6 -0
  9. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +6 -10
  10. data/ext/ddtrace_profiling_native_extension/time_helpers.c +40 -4
  11. data/ext/ddtrace_profiling_native_extension/time_helpers.h +14 -0
  12. data/lib/datadog/appsec/component.rb +9 -0
  13. data/lib/datadog/appsec/configuration/settings.rb +104 -195
  14. data/lib/datadog/appsec/configuration.rb +0 -79
  15. data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -4
  16. data/lib/datadog/appsec/contrib/devise/event.rb +57 -0
  17. data/lib/datadog/appsec/contrib/devise/ext.rb +13 -0
  18. data/lib/datadog/appsec/contrib/devise/integration.rb +42 -0
  19. data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +76 -0
  20. data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +52 -0
  21. data/lib/datadog/appsec/contrib/devise/patcher.rb +45 -0
  22. data/lib/datadog/appsec/contrib/devise/resource.rb +35 -0
  23. data/lib/datadog/appsec/contrib/devise/tracking.rb +49 -0
  24. data/lib/datadog/appsec/contrib/rack/ext.rb +2 -1
  25. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +1 -1
  26. data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +1 -1
  27. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +1 -1
  28. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +12 -7
  29. data/lib/datadog/appsec/contrib/rails/ext.rb +3 -2
  30. data/lib/datadog/appsec/contrib/rails/framework.rb +1 -3
  31. data/lib/datadog/appsec/contrib/rails/patcher.rb +8 -8
  32. data/lib/datadog/appsec/contrib/rails/reactive/action.rb +1 -1
  33. data/lib/datadog/appsec/contrib/sinatra/ext.rb +2 -1
  34. data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -3
  35. data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +1 -1
  36. data/lib/datadog/appsec/event.rb +1 -1
  37. data/lib/datadog/appsec/extensions.rb +1 -130
  38. data/lib/datadog/appsec/monitor/reactive/set_user.rb +1 -1
  39. data/lib/datadog/appsec/processor.rb +1 -1
  40. data/lib/datadog/appsec/rate_limiter.rb +1 -1
  41. data/lib/datadog/appsec/remote.rb +1 -1
  42. data/lib/datadog/appsec.rb +1 -2
  43. data/lib/datadog/ci/configuration/settings.rb +6 -8
  44. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +7 -5
  45. data/lib/datadog/ci/contrib/cucumber/ext.rb +10 -8
  46. data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +35 -0
  47. data/lib/datadog/ci/contrib/minitest/ext.rb +21 -0
  48. data/lib/datadog/ci/contrib/minitest/integration.rb +49 -0
  49. data/lib/datadog/ci/contrib/minitest/patcher.rb +27 -0
  50. data/lib/datadog/ci/contrib/minitest/test_helper.rb +68 -0
  51. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +7 -5
  52. data/lib/datadog/ci/contrib/rspec/ext.rb +9 -7
  53. data/lib/datadog/ci.rb +1 -0
  54. data/lib/datadog/core/backport.rb +51 -0
  55. data/lib/datadog/core/configuration/agent_settings_resolver.rb +9 -5
  56. data/lib/datadog/core/configuration/base.rb +5 -5
  57. data/lib/datadog/core/configuration/components.rb +6 -1
  58. data/lib/datadog/core/configuration/ext.rb +7 -5
  59. data/lib/datadog/core/configuration/option.rb +269 -19
  60. data/lib/datadog/core/configuration/option_definition.rb +76 -11
  61. data/lib/datadog/core/configuration/options.rb +22 -10
  62. data/lib/datadog/core/configuration/settings.rb +139 -61
  63. data/lib/datadog/core/environment/execution.rb +55 -0
  64. data/lib/datadog/core/environment/ext.rb +13 -11
  65. data/lib/datadog/core/environment/yjit.rb +58 -0
  66. data/lib/datadog/core/git/ext.rb +24 -22
  67. data/lib/datadog/core/logging/ext.rb +3 -1
  68. data/lib/datadog/core/metrics/ext.rb +7 -5
  69. data/lib/datadog/core/remote/client/capabilities.rb +5 -0
  70. data/lib/datadog/core/remote/client.rb +3 -0
  71. data/lib/datadog/core/remote/component.rb +25 -34
  72. data/lib/datadog/core/remote/configuration/content.rb +28 -1
  73. data/lib/datadog/core/remote/configuration/repository.rb +3 -1
  74. data/lib/datadog/core/remote/ext.rb +1 -1
  75. data/lib/datadog/core/remote/negotiation.rb +17 -4
  76. data/lib/datadog/core/runtime/ext.rb +22 -12
  77. data/lib/datadog/core/runtime/metrics.rb +43 -0
  78. data/lib/datadog/core/telemetry/client.rb +12 -2
  79. data/lib/datadog/core/telemetry/emitter.rb +4 -2
  80. data/lib/datadog/core/telemetry/event.rb +19 -4
  81. data/lib/datadog/core/telemetry/ext.rb +4 -1
  82. data/lib/datadog/core/telemetry/heartbeat.rb +2 -4
  83. data/lib/datadog/core/telemetry/http/ext.rb +10 -8
  84. data/lib/datadog/core/telemetry/http/transport.rb +1 -0
  85. data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
  86. data/lib/datadog/core/telemetry/v2/request.rb +29 -0
  87. data/lib/datadog/core/transport/http/client.rb +1 -1
  88. data/lib/datadog/core/transport/http/config.rb +10 -0
  89. data/lib/datadog/core/utils/duration.rb +52 -0
  90. data/lib/datadog/core/utils/hash.rb +47 -0
  91. data/lib/datadog/core/utils/network.rb +1 -1
  92. data/lib/datadog/core/utils/safe_dup.rb +27 -20
  93. data/lib/datadog/core/utils.rb +1 -1
  94. data/lib/datadog/core/workers/async.rb +2 -2
  95. data/lib/datadog/kit/appsec/events.rb +139 -89
  96. data/lib/datadog/kit/identity.rb +80 -65
  97. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +3 -0
  98. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
  99. data/lib/datadog/profiling/collectors/thread_context.rb +9 -2
  100. data/lib/datadog/profiling/component.rb +41 -9
  101. data/lib/datadog/profiling/exporter.rb +5 -1
  102. data/lib/datadog/profiling/flush.rb +9 -2
  103. data/lib/datadog/profiling/http_transport.rb +13 -3
  104. data/lib/datadog/profiling/load_native_extension.rb +7 -1
  105. data/lib/datadog/profiling.rb +11 -1
  106. data/lib/datadog/tracing/component.rb +58 -6
  107. data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
  108. data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
  109. data/lib/datadog/tracing/configuration/ext.rb +35 -32
  110. data/lib/datadog/tracing/configuration/http.rb +74 -0
  111. data/lib/datadog/tracing/configuration/settings.rb +106 -92
  112. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +9 -6
  113. data/lib/datadog/tracing/contrib/action_cable/ext.rb +20 -18
  114. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +9 -6
  115. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +20 -18
  116. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +8 -6
  117. data/lib/datadog/tracing/contrib/action_pack/ext.rb +10 -8
  118. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +9 -6
  119. data/lib/datadog/tracing/contrib/action_view/ext.rb +12 -10
  120. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +13 -7
  121. data/lib/datadog/tracing/contrib/active_job/ext.rb +25 -23
  122. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +1 -1
  123. data/lib/datadog/tracing/contrib/active_job/patcher.rb +1 -1
  124. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +9 -6
  125. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +12 -10
  126. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +9 -7
  127. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +0 -8
  128. data/lib/datadog/tracing/contrib/active_record/ext.rb +17 -15
  129. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +0 -5
  130. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -7
  131. data/lib/datadog/tracing/contrib/active_support/ext.rb +18 -16
  132. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +14 -7
  133. data/lib/datadog/tracing/contrib/aws/ext.rb +37 -24
  134. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +9 -5
  135. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +3 -2
  136. data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +4 -2
  137. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +14 -7
  138. data/lib/datadog/tracing/contrib/dalli/ext.rb +19 -11
  139. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +8 -6
  140. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +13 -7
  141. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +16 -14
  142. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +14 -7
  143. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +21 -15
  144. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +8 -5
  145. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +16 -9
  146. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +43 -3
  147. data/lib/datadog/tracing/contrib/ethon/ext.rb +19 -11
  148. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +0 -5
  149. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +19 -10
  150. data/lib/datadog/tracing/contrib/excon/ext.rb +16 -8
  151. data/lib/datadog/tracing/contrib/excon/middleware.rb +20 -5
  152. data/lib/datadog/tracing/contrib/ext.rb +23 -1
  153. data/lib/datadog/tracing/contrib/extensions.rb +32 -0
  154. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +20 -10
  155. data/lib/datadog/tracing/contrib/faraday/ext.rb +16 -8
  156. data/lib/datadog/tracing/contrib/faraday/middleware.rb +16 -5
  157. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +8 -6
  158. data/lib/datadog/tracing/contrib/grape/ext.rb +16 -14
  159. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +8 -6
  160. data/lib/datadog/tracing/contrib/graphql/ext.rb +7 -5
  161. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +19 -9
  162. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +29 -20
  163. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +21 -20
  164. data/lib/datadog/tracing/contrib/grpc/ext.rb +16 -13
  165. data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
  166. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +3 -2
  167. data/lib/datadog/tracing/contrib/hanami/ext.rb +10 -8
  168. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +4 -7
  169. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +33 -11
  170. data/lib/datadog/tracing/contrib/http/ext.rb +16 -9
  171. data/lib/datadog/tracing/contrib/http/instrumentation.rb +22 -7
  172. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +33 -11
  173. data/lib/datadog/tracing/contrib/httpclient/ext.rb +17 -9
  174. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +17 -5
  175. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +33 -11
  176. data/lib/datadog/tracing/contrib/httprb/ext.rb +16 -9
  177. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +17 -5
  178. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +9 -6
  179. data/lib/datadog/tracing/contrib/kafka/ext.rb +42 -39
  180. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +3 -2
  181. data/lib/datadog/tracing/contrib/lograge/ext.rb +3 -1
  182. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -0
  183. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +14 -7
  184. data/lib/datadog/tracing/contrib/mongodb/ext.rb +20 -16
  185. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +9 -5
  186. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +17 -14
  187. data/lib/datadog/tracing/contrib/mysql2/ext.rb +15 -10
  188. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +9 -5
  189. data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +52 -0
  190. data/lib/datadog/tracing/contrib/opensearch/ext.rb +37 -0
  191. data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
  192. data/lib/datadog/tracing/contrib/opensearch/patcher.rb +128 -0
  193. data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
  194. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +17 -14
  195. data/lib/datadog/tracing/contrib/pg/ext.rb +22 -19
  196. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +9 -5
  197. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +14 -7
  198. data/lib/datadog/tracing/contrib/presto/ext.rb +25 -20
  199. data/lib/datadog/tracing/contrib/presto/instrumentation.rb +9 -5
  200. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +12 -10
  201. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +12 -8
  202. data/lib/datadog/tracing/contrib/qless/ext.rb +14 -12
  203. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +21 -12
  204. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -7
  205. data/lib/datadog/tracing/contrib/racecar/event.rb +0 -5
  206. data/lib/datadog/tracing/contrib/racecar/ext.rb +20 -18
  207. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +16 -12
  208. data/lib/datadog/tracing/contrib/rack/ext.rb +18 -16
  209. data/lib/datadog/tracing/contrib/rack/header_collection.rb +3 -0
  210. data/lib/datadog/tracing/contrib/rack/header_tagging.rb +53 -0
  211. data/lib/datadog/tracing/contrib/rack/middlewares.rb +8 -49
  212. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +15 -11
  213. data/lib/datadog/tracing/contrib/rails/ext.rb +7 -5
  214. data/lib/datadog/tracing/contrib/rails/log_injection.rb +7 -10
  215. data/lib/datadog/tracing/contrib/rails/patcher.rb +10 -41
  216. data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
  217. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +12 -9
  218. data/lib/datadog/tracing/contrib/rake/ext.rb +14 -12
  219. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +17 -9
  220. data/lib/datadog/tracing/contrib/redis/ext.rb +22 -15
  221. data/lib/datadog/tracing/contrib/redis/tags.rb +9 -5
  222. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +13 -7
  223. data/lib/datadog/tracing/contrib/resque/ext.rb +9 -7
  224. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +16 -9
  225. data/lib/datadog/tracing/contrib/rest_client/ext.rb +15 -8
  226. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +20 -5
  227. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +9 -6
  228. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +3 -2
  229. data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +3 -1
  230. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +1 -0
  231. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +9 -6
  232. data/lib/datadog/tracing/contrib/sequel/ext.rb +10 -8
  233. data/lib/datadog/tracing/contrib/sequel/utils.rb +2 -7
  234. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +14 -8
  235. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +14 -12
  236. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +18 -11
  237. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +32 -30
  238. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +11 -9
  239. data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
  240. data/lib/datadog/tracing/contrib/sinatra/ext.rb +21 -19
  241. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
  242. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +14 -8
  243. data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
  244. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +1 -1
  245. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +74 -10
  246. data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +9 -6
  247. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +9 -6
  248. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +15 -13
  249. data/lib/datadog/tracing/contrib/utils/database.rb +5 -3
  250. data/lib/datadog/tracing/contrib.rb +1 -0
  251. data/lib/datadog/tracing/correlation.rb +9 -12
  252. data/lib/datadog/tracing/diagnostics/ext.rb +21 -19
  253. data/lib/datadog/tracing/distributed/b3_multi.rb +2 -2
  254. data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
  255. data/lib/datadog/tracing/distributed/trace_context.rb +52 -17
  256. data/lib/datadog/tracing/metadata/ext.rb +9 -6
  257. data/lib/datadog/tracing/remote.rb +78 -0
  258. data/lib/datadog/tracing/sampling/rule_sampler.rb +29 -0
  259. data/lib/datadog/tracing/span_operation.rb +3 -15
  260. data/lib/datadog/tracing/trace_operation.rb +16 -3
  261. data/lib/datadog/tracing/trace_segment.rb +5 -2
  262. data/lib/datadog/tracing/tracer.rb +10 -1
  263. data/lib/ddtrace/transport/ext.rb +15 -9
  264. data/lib/ddtrace/transport/trace_formatter.rb +9 -0
  265. data/lib/ddtrace/version.rb +8 -11
  266. metadata +36 -7
  267. data/lib/datadog/tracing/contrib/sinatra/headers.rb +0 -35
@@ -12,18 +12,21 @@ module Datadog
12
12
  # @public_api
13
13
  class Settings < Contrib::Configuration::Settings
14
14
  option :enabled do |o|
15
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
16
- o.lazy
15
+ o.type :bool
16
+ o.env Ext::ENV_ENABLED
17
+ o.default true
17
18
  end
18
19
 
19
20
  option :analytics_enabled do |o|
20
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
21
- o.lazy
21
+ o.type :bool
22
+ o.env Ext::ENV_ANALYTICS_ENABLED
23
+ o.default false
22
24
  end
23
25
 
24
26
  option :analytics_sample_rate do |o|
25
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
26
- o.lazy
27
+ o.type :float
28
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
29
+ o.default 1.0
27
30
  end
28
31
 
29
32
  option :service_name do |o|
@@ -33,7 +36,6 @@ module Datadog
33
36
  Ext::DEFAULT_PEER_SERVICE_NAME
34
37
  )
35
38
  end
36
- o.lazy
37
39
  end
38
40
  end
39
41
  end
@@ -40,11 +40,6 @@ module Datadog
40
40
  span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)
41
41
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
42
42
 
43
- # Tag as an external peer service
44
- if Contrib::SpanAttributeSchema.default_span_attribute_schema?
45
- span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
46
- end
47
-
48
43
  # Set analytics sample rate
49
44
  if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
50
45
  Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,24 +7,24 @@ module Datadog
5
7
  # Racecar integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- ENV_ENABLED = 'DD_TRACE_RACECAR_ENABLED'.freeze
9
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACECAR_ANALYTICS_ENABLED'.freeze
10
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'.freeze
11
- DEFAULT_PEER_SERVICE_NAME = 'racecar'.freeze
12
- SPAN_CONSUME = 'racecar.consume'.freeze
13
- SPAN_BATCH = 'racecar.batch'.freeze
14
- SPAN_MESSAGE = 'racecar.message'.freeze
15
- TAG_CONSUMER = 'kafka.consumer'.freeze
16
- TAG_FIRST_OFFSET = 'kafka.first_offset'.freeze
17
- TAG_MESSAGE_COUNT = 'kafka.message_count'.freeze
18
- TAG_OFFSET = 'kafka.offset'.freeze
19
- TAG_PARTITION = 'kafka.partition'.freeze
20
- TAG_TOPIC = 'kafka.topic'.freeze
21
- TAG_COMPONENT = 'racecar'.freeze
22
- TAG_OPERATION_CONSUME = 'consume'.freeze
23
- TAG_OPERATION_BATCH = 'batch'.freeze
24
- TAG_OPERATION_MESSAGE = 'message'.freeze
25
- TAG_MESSAGING_SYSTEM = 'kafka'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_RACECAR_ENABLED'
11
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACECAR_ANALYTICS_ENABLED'
12
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'
13
+ DEFAULT_PEER_SERVICE_NAME = 'racecar'
14
+ SPAN_CONSUME = 'racecar.consume'
15
+ SPAN_BATCH = 'racecar.batch'
16
+ SPAN_MESSAGE = 'racecar.message'
17
+ TAG_CONSUMER = 'kafka.consumer'
18
+ TAG_FIRST_OFFSET = 'kafka.first_offset'
19
+ TAG_MESSAGE_COUNT = 'kafka.message_count'
20
+ TAG_OFFSET = 'kafka.offset'
21
+ TAG_PARTITION = 'kafka.partition'
22
+ TAG_TOPIC = 'kafka.topic'
23
+ TAG_COMPONENT = 'racecar'
24
+ TAG_OPERATION_CONSUME = 'consume'
25
+ TAG_OPERATION_BATCH = 'batch'
26
+ TAG_OPERATION_MESSAGE = 'message'
27
+ TAG_MESSAGING_SYSTEM = 'kafka'
26
28
  end
27
29
  end
28
30
  end
@@ -17,30 +17,34 @@ module Datadog
17
17
  }.freeze
18
18
 
19
19
  option :enabled do |o|
20
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
21
- o.lazy
20
+ o.type :bool
21
+ o.env Ext::ENV_ENABLED
22
+ o.default true
22
23
  end
23
24
 
24
25
  option :analytics_enabled do |o|
25
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, nil) }
26
- o.lazy
26
+ o.type :bool, nilable: true
27
+ o.env Ext::ENV_ANALYTICS_ENABLED
27
28
  end
28
29
 
29
30
  option :analytics_sample_rate do |o|
30
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
31
- o.lazy
31
+ o.type :float
32
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
33
+ o.default 1.0
32
34
  end
33
35
 
34
36
  option :application
35
- option :distributed_tracing, default: true
36
- option :headers, default: DEFAULT_HEADERS
37
- option :middleware_names, default: false
38
- option :quantize, default: {}
39
- option :request_queuing, default: false
37
+ option :distributed_tracing, default: true, type: :bool
38
+ option :headers, default: DEFAULT_HEADERS, type: :hash
39
+ option :middleware_names, default: false, type: :bool
40
+ option :quantize, default: {}, type: :hash
41
+ option :request_queuing do |o|
42
+ o.default false
43
+ end
40
44
 
41
45
  option :service_name
42
46
 
43
- option :web_service_name, default: Ext::DEFAULT_PEER_WEBSERVER_SERVICE_NAME
47
+ option :web_service_name, default: Ext::DEFAULT_PEER_WEBSERVER_SERVICE_NAME, type: :string
44
48
  end
45
49
  end
46
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,22 +7,22 @@ module Datadog
5
7
  # Rack integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- ENV_ENABLED = 'DD_TRACE_RACK_ENABLED'.freeze
9
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACK_ANALYTICS_ENABLED'.freeze
10
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACK_ANALYTICS_SAMPLE_RATE'.freeze
11
- RACK_ENV_REQUEST_SPAN = 'datadog.rack_request_span'.freeze
12
- SPAN_HTTP_PROXY_REQUEST = 'http.proxy.request'.freeze
13
- SPAN_HTTP_PROXY_QUEUE = 'http.proxy.queue'.freeze
14
- SPAN_HTTP_SERVER_QUEUE = 'http_server.queue'.freeze
15
- SPAN_REQUEST = 'rack.request'.freeze
16
- TAG_COMPONENT = 'rack'.freeze
17
- TAG_COMPONENT_HTTP_PROXY = 'http_proxy'.freeze
18
- TAG_OPERATION_REQUEST = 'request'.freeze
19
- TAG_OPERATION_HTTP_PROXY_REQUEST = 'request'.freeze
20
- TAG_OPERATION_HTTP_PROXY_QUEUE = 'queue'.freeze
21
- TAG_OPERATION_HTTP_SERVER_QUEUE = 'queue'.freeze
22
- WEBSERVER_APP = 'webserver'.freeze
23
- DEFAULT_PEER_WEBSERVER_SERVICE_NAME = 'web-server'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_RACK_ENABLED'
11
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACK_ANALYTICS_ENABLED'
12
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACK_ANALYTICS_SAMPLE_RATE'
13
+ RACK_ENV_REQUEST_SPAN = 'datadog.rack_request_span'
14
+ SPAN_HTTP_PROXY_REQUEST = 'http.proxy.request'
15
+ SPAN_HTTP_PROXY_QUEUE = 'http.proxy.queue'
16
+ SPAN_HTTP_SERVER_QUEUE = 'http_server.queue'
17
+ SPAN_REQUEST = 'rack.request'
18
+ TAG_COMPONENT = 'rack'
19
+ TAG_COMPONENT_HTTP_PROXY = 'http_proxy'
20
+ TAG_OPERATION_REQUEST = 'request'
21
+ TAG_OPERATION_HTTP_PROXY_REQUEST = 'request'
22
+ TAG_OPERATION_HTTP_PROXY_QUEUE = 'queue'
23
+ TAG_OPERATION_HTTP_SERVER_QUEUE = 'queue'
24
+ WEBSERVER_APP = 'webserver'
25
+ DEFAULT_PEER_WEBSERVER_SERVICE_NAME = 'web-server'
24
26
  end
25
27
  end
26
28
  end
@@ -19,6 +19,9 @@ module Datadog
19
19
  @env[Header.to_rack_header(header_name)]
20
20
  end
21
21
 
22
+ # Allows this class to have a similar API to a {Hash}.
23
+ alias [] get
24
+
22
25
  # Tests whether a header with the given name exists in the environment.
23
26
  def key?(header_name)
24
27
  @env.key?(Header.to_rack_header(header_name))
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Tracing
5
+ module Contrib
6
+ module Rack
7
+ # Matches Rack-style headers with a matcher and sets matching headers into a span.
8
+ module HeaderTagging
9
+ def self.tag_request_headers(span, env, configuration)
10
+ # Wrap env in a case-insensitive Rack-style accessor.
11
+ headers = env.is_a?(Header::RequestHeaderCollection) ? env : Header::RequestHeaderCollection.new(env)
12
+
13
+ # Use global DD_TRACE_HEADER_TAGS if integration-level configuration is not provided
14
+ tags = if configuration.using_default?(:headers) && !Datadog.configuration.tracing.using_default?(:header_tags)
15
+ Datadog.configuration.tracing.header_tags.request_tags(headers)
16
+ else
17
+ whitelist = configuration[:headers][:request] || []
18
+ whitelist.each_with_object({}) do |header, result|
19
+ header_value = headers.get(header)
20
+ unless header_value.nil?
21
+ header_tag = Tracing::Metadata::Ext::HTTP::RequestHeaders.to_tag(header)
22
+ result[header_tag] = header_value
23
+ end
24
+ end
25
+ end
26
+
27
+ span.set_tags(tags)
28
+ end
29
+
30
+ def self.tag_response_headers(span, headers, configuration)
31
+ headers = Core::Utils::Hash::CaseInsensitiveWrapper.new(headers) # Make header access case-insensitive
32
+
33
+ # Use global DD_TRACE_HEADER_TAGS if integration-level configuration is not provided
34
+ tags = if configuration.using_default?(:headers) && !Datadog.configuration.tracing.using_default?(:header_tags)
35
+ Datadog.configuration.tracing.header_tags.response_tags(headers)
36
+ else
37
+ whitelist = configuration[:headers][:response] || []
38
+ whitelist.each_with_object({}) do |header, result|
39
+ header_value = headers[header]
40
+ unless header_value.nil?
41
+ header_tag = Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)
42
+ result[header_tag] = header_value
43
+ end
44
+ end
45
+ end
46
+
47
+ span.set_tags(tags)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,6 +1,7 @@
1
1
  require 'date'
2
2
 
3
3
  require_relative '../../../core/environment/variable_helpers'
4
+ require_relative '../../../core/backport'
4
5
  require_relative '../../client_ip'
5
6
  require_relative '../../metadata/ext'
6
7
  require_relative '../../propagation/http'
@@ -8,6 +9,7 @@ require_relative '../analytics'
8
9
  require_relative '../utils/quantization/http'
9
10
  require_relative 'ext'
10
11
  require_relative 'header_collection'
12
+ require_relative 'header_tagging'
11
13
  require_relative 'request_queue'
12
14
 
13
15
  module Datadog
@@ -69,6 +71,8 @@ module Datadog
69
71
 
70
72
  return @app.call(env) if previous_request_span
71
73
 
74
+ Datadog::Core::Remote.active_remote.barrier(:once) unless Datadog::Core::Remote.active_remote.nil?
75
+
72
76
  # Extract distributed tracing context before creating any spans,
73
77
  # so that all spans will be added to the distributed trace.
74
78
  if configuration[:distributed_tracing]
@@ -137,8 +141,6 @@ module Datadog
137
141
  # rubocop:disable Metrics/MethodLength
138
142
  def set_request_tags!(trace, request_span, env, status, headers, response, original_env)
139
143
  request_header_collection = Header::RequestHeaderCollection.new(env)
140
- request_headers_tags = parse_request_headers(request_header_collection)
141
- response_headers_tags = parse_response_headers(headers || {})
142
144
 
143
145
  # Since it could be mutated, it would be more accurate to fetch from the original env,
144
146
  # e.g. ActionDispatch::ShowExceptions middleware with Rails exceptions_app configuration
@@ -227,15 +229,8 @@ module Datadog
227
229
  request_span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_USER_AGENT, user_agent)
228
230
  end
229
231
 
230
- # Request headers
231
- request_headers_tags.each do |name, value|
232
- request_span.set_tag(name, value) if request_span.get_tag(name).nil?
233
- end
234
-
235
- # Response headers
236
- response_headers_tags.each do |name, value|
237
- request_span.set_tag(name, value) if request_span.get_tag(name).nil?
238
- end
232
+ HeaderTagging.tag_request_headers(request_span, request_header_collection, configuration)
233
+ HeaderTagging.tag_response_headers(request_span, headers, configuration) if headers
239
234
 
240
235
  # detect if the status code is a 5xx and flag the request span as an error
241
236
  # unless it has been already set by the underlying framework
@@ -253,19 +248,12 @@ module Datadog
253
248
  end
254
249
 
255
250
  def trace_http_server(span_name, start_time:)
256
- span = Tracing.trace(
251
+ Tracing.trace(
257
252
  span_name,
258
253
  span_type: Tracing::Metadata::Ext::HTTP::TYPE_PROXY,
259
254
  start_time: start_time,
260
255
  service: configuration[:web_service_name]
261
256
  )
262
-
263
- # Set peer service (so its not believed to belong to this app)
264
- if Contrib::SpanAttributeSchema.default_span_attribute_schema?
265
- span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, configuration[:web_service_name])
266
- end
267
-
268
- span
269
257
  end
270
258
 
271
259
  def parse_url(env, original_env)
@@ -304,7 +292,7 @@ module Datadog
304
292
  else
305
293
  # normally REQUEST_URI starts at the path, but it
306
294
  # might contain the full URL in some cases (e.g WEBrick)
307
- request_uri.sub(/^#{base_url}/, '')
295
+ Datadog::Core::BackportFrom25.string_delete_prefix(request_uri, base_url)
308
296
  end
309
297
 
310
298
  base_url + fullpath
@@ -313,35 +301,6 @@ module Datadog
313
301
  def parse_user_agent_header(headers)
314
302
  headers.get(Tracing::Metadata::Ext::HTTP::HEADER_USER_AGENT)
315
303
  end
316
-
317
- def parse_request_headers(headers)
318
- whitelist = configuration[:headers][:request] || []
319
- whitelist.each_with_object({}) do |header, result|
320
- header_value = headers.get(header)
321
- unless header_value.nil?
322
- header_tag = Tracing::Metadata::Ext::HTTP::RequestHeaders.to_tag(header)
323
- result[header_tag] = header_value
324
- end
325
- end
326
- end
327
-
328
- def parse_response_headers(headers)
329
- {}.tap do |result|
330
- whitelist = configuration[:headers][:response] || []
331
- whitelist.each do |header|
332
- if headers.key?(header)
333
- result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[header]
334
- else
335
- # Try a case-insensitive lookup
336
- uppercased_header = header.to_s.upcase
337
- matching_header = headers.keys.find { |h| h.upcase == uppercased_header }
338
- if matching_header
339
- result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header]
340
- end
341
- end
342
- end
343
- end
344
- end
345
304
  end
346
305
  end
347
306
  end
@@ -24,13 +24,14 @@ module Datadog
24
24
  end
25
25
 
26
26
  option :enabled do |o|
27
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
28
- o.lazy
27
+ o.type :bool
28
+ o.env Ext::ENV_ENABLED
29
+ o.default true
29
30
  end
30
31
 
31
32
  option :analytics_enabled do |o|
32
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, nil) }
33
- o.lazy
33
+ o.type :bool, nilable: true
34
+ o.env Ext::ENV_ANALYTICS_ENABLED
34
35
  o.on_set do |value|
35
36
  # Update ActionPack analytics too
36
37
  Datadog.configuration.tracing[:action_pack][:analytics_enabled] = value
@@ -38,18 +39,20 @@ module Datadog
38
39
  end
39
40
 
40
41
  option :analytics_sample_rate do |o|
41
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
42
- o.lazy
42
+ o.type :float
43
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
44
+ o.default 1.0
43
45
  o.on_set do |value|
44
46
  # Update ActionPack analytics too
45
47
  Datadog.configuration.tracing[:action_pack][:analytics_sample_rate] = value
46
48
  end
47
49
  end
48
50
 
49
- option :distributed_tracing, default: true
50
-
51
- option :request_queuing, default: false
51
+ option :distributed_tracing, default: true, type: :bool
52
52
 
53
+ option :request_queuing do |o|
54
+ o.default false
55
+ end
53
56
  # DEV-2.0: Breaking changes for removal.
54
57
  option :exception_controller do |o|
55
58
  o.on_set do |value|
@@ -62,9 +65,10 @@ module Datadog
62
65
  end
63
66
  end
64
67
 
65
- option :middleware, default: true
66
- option :middleware_names, default: false
68
+ option :middleware, default: true, type: :bool
69
+ option :middleware_names, default: false, type: :bool
67
70
  option :template_base_path do |o|
71
+ o.type :string
68
72
  o.default 'views/'
69
73
  o.on_set do |value|
70
74
  # Update ActionView template base path too
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,11 +7,11 @@ module Datadog
5
7
  # Rails integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- APP = 'rails'.freeze
9
- ENV_ENABLED = 'DD_TRACE_RAILS_ENABLED'.freeze
10
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAILS_ANALYTICS_ENABLED'.freeze
11
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAILS_ANALYTICS_SAMPLE_RATE'.freeze
12
- ENV_DISABLE = 'DISABLE_DATADOG_RAILS'.freeze
10
+ APP = 'rails'
11
+ ENV_ENABLED = 'DD_TRACE_RAILS_ENABLED'
12
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAILS_ANALYTICS_ENABLED'
13
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAILS_ANALYTICS_SAMPLE_RATE'
14
+ ENV_DISABLE = 'DISABLE_DATADOG_RAILS'
13
15
  end
14
16
  end
15
17
  end
@@ -7,17 +7,14 @@ module Datadog
7
7
  module LogInjection
8
8
  module_function
9
9
 
10
- def add_as_tagged_logging_logger(app)
11
- # we want to check if the current logger is a tagger logger instance
12
- # log_tags defaults to nil so we have to set as an array if nothing exists yet
13
- if (log_tags = app.config.log_tags).nil?
14
- app.config.log_tags = [proc { Tracing.log_correlation }]
15
- # if existing log_tags configuration exists, append to the end of the array
16
- elsif log_tags.is_a?(Array)
17
- app.config.log_tags << proc { Tracing.log_correlation }
18
- end
10
+ # Use `app.config.log_tags` to inject propagation tags into the default Rails logger.
11
+ def configure_log_tags(app_config)
12
+ # When using SemanticLogger, app_config.log_tags could be a Hash and should not be modified here
13
+ return unless app_config.log_tags.nil? || app_config.log_tags.respond_to?(:<<)
14
+
15
+ app_config.log_tags ||= [] # Can be nil, we initialized it if so
16
+ app_config.log_tags << proc { Tracing.log_correlation if Datadog.configuration.tracing.log_injection }
19
17
  rescue StandardError => e
20
- # TODO: can we use Datadog.logger at this point?
21
18
  Datadog.logger.warn(
22
19
  "Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class.name} #{e.message}"
23
20
  )
@@ -24,23 +24,24 @@ module Datadog
24
24
  end
25
25
 
26
26
  def patch
27
- patch_before_intialize
28
- patch_after_intialize
27
+ patch_before_initialize
28
+ patch_after_initialize
29
29
  end
30
30
 
31
- def patch_before_intialize
31
+ def patch_before_initialize
32
32
  ::ActiveSupport.on_load(:before_initialize) do
33
- Contrib::Rails::Patcher.before_intialize(self)
33
+ Contrib::Rails::Patcher.before_initialize(self)
34
34
  end
35
35
  end
36
36
 
37
- def before_intialize(app)
37
+ def before_initialize(app)
38
38
  BEFORE_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
39
39
  # Middleware must be added before the application is initialized.
40
40
  # Otherwise the middleware stack will be frozen.
41
41
  # Sometimes we don't want to activate middleware e.g. OpenTracing, etc.
42
42
  add_middleware(app) if Datadog.configuration.tracing[:rails][:middleware]
43
- add_logger(app) if Datadog.configuration.tracing.log_injection
43
+
44
+ Rails::LogInjection.configure_log_tags(app.config)
44
45
  end
45
46
  end
46
47
 
@@ -61,45 +62,13 @@ module Datadog
61
62
  app.middleware.insert_after(::ActionDispatch::DebugExceptions, Contrib::Rails::ExceptionMiddleware)
62
63
  end
63
64
 
64
- def add_logger(app)
65
- should_warn = true
66
- # check if lograge key exists
67
- # Note: Rails executes initializers sequentially based on alphabetical order,
68
- # and lograge config could occur after datadog config.
69
- # So checking for `app.config.lograge.enabled` may yield a false negative,
70
- # and adding custom options naively if `config.lograge` exists from the lograge Railtie,
71
- # is inconsistent since a lograge initializer would override it.
72
- # Instead, we patch Lograge `custom_options` internals directly
73
- # as part of Rails framework patching
74
- # and just flag off the warning log here.
75
- # SemanticLogger we similarly patch in the after_initiaize block, and should flag
76
- # off the warning log here if we know we'll patch this gem later.
77
- should_warn = false if app.config.respond_to?(:lograge) || defined?(::SemanticLogger)
78
-
79
- # if lograge isn't set, check if tagged logged is enabled.
80
- # if so, add proc that injects trace identifiers for tagged logging.
81
- logger = app.config.logger || ::Rails.logger
82
-
83
- if logger \
84
- && defined?(::ActiveSupport::TaggedLogging) \
85
- && logger.is_a?(::ActiveSupport::TaggedLogging)
86
-
87
- Contrib::Rails::LogInjection.add_as_tagged_logging_logger(app)
88
- should_warn = false
89
- end
90
-
91
- if should_warn
92
- Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger.class} is not supported")
93
- end
94
- end
95
-
96
- def patch_after_intialize
65
+ def patch_after_initialize
97
66
  ::ActiveSupport.on_load(:after_initialize) do
98
- Contrib::Rails::Patcher.after_intialize(self)
67
+ Contrib::Rails::Patcher.after_initialize(self)
99
68
  end
100
69
  end
101
70
 
102
- def after_intialize(app)
71
+ def after_initialize(app)
103
72
  AFTER_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
104
73
  # Finish configuring the tracer after the application is initialized.
105
74
  # We need to wait for some things, like application name, middleware stack, etc.
@@ -6,12 +6,12 @@ module Datadog
6
6
  # Railtie class initializes
7
7
  class Railtie < Rails::Railtie
8
8
  # Add the trace middleware to the application stack
9
- initializer 'datadog.before_intialize' do |app|
10
- Tracing::Contrib::Rails::Patcher.before_intialize(app)
9
+ initializer 'datadog.before_initialize' do |app|
10
+ Tracing::Contrib::Rails::Patcher.before_initialize(app)
11
11
  end
12
12
 
13
13
  config.after_initialize do
14
- Tracing::Contrib::Rails::Patcher.after_intialize(self)
14
+ Tracing::Contrib::Rails::Patcher.after_initialize(self)
15
15
  end
16
16
  end
17
17
  end
@@ -14,21 +14,24 @@ module Datadog
14
14
  # @public_api
15
15
  class Settings < Contrib::Configuration::Settings
16
16
  option :enabled do |o|
17
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
18
- o.lazy
17
+ o.type :bool
18
+ o.env Ext::ENV_ENABLED
19
+ o.default true
19
20
  end
20
21
 
21
22
  option :analytics_enabled do |o|
22
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
23
- o.lazy
23
+ o.type :bool
24
+ o.env Ext::ENV_ANALYTICS_ENABLED
25
+ o.default false
24
26
  end
25
27
 
26
28
  option :analytics_sample_rate do |o|
27
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
28
- o.lazy
29
+ o.type :float
30
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
31
+ o.default 1.0
29
32
  end
30
33
 
31
- option :quantize, default: {}
34
+ option :quantize, default: {}, type: :hash
32
35
  option :service_name
33
36
 
34
37
  # A list of rake tasks, using their string names, to be instrumented.
@@ -36,8 +39,8 @@ module Datadog
36
39
  # Automatically instrumenting all Rake tasks can lead to long-running tasks
37
40
  # causing undue memory accumulation, as the trace for such tasks is never flushed.
38
41
  option :tasks do |o|
39
- o.default { [] }
40
- o.lazy
42
+ o.type :array
43
+ o.default []
41
44
  o.on_set do |value|
42
45
  # DEV: It should be possible to modify the value after it's set. E.g. for normalization.
43
46
  options[:tasks].instance_variable_set(:@value, value.map(&:to_s).to_set)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,18 +7,18 @@ module Datadog
5
7
  # Rake integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- ENV_ENABLED = 'DD_TRACE_RAKE_ENABLED'.freeze
9
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAKE_ANALYTICS_ENABLED'.freeze
10
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAKE_ANALYTICS_SAMPLE_RATE'.freeze
11
- SERVICE_NAME = 'rake'.freeze
12
- SPAN_INVOKE = 'rake.invoke'.freeze
13
- SPAN_EXECUTE = 'rake.execute'.freeze
14
- TAG_EXECUTE_ARGS = 'rake.execute.args'.freeze
15
- TAG_INVOKE_ARGS = 'rake.invoke.args'.freeze
16
- TAG_TASK_ARG_NAMES = 'rake.task.arg_names'.freeze
17
- TAG_COMPONENT = 'rake'.freeze
18
- TAG_OPERATION_EXECUTE = 'execute'.freeze
19
- TAG_OPERATION_INVOKE = 'invoke'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_RAKE_ENABLED'
11
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAKE_ANALYTICS_ENABLED'
12
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAKE_ANALYTICS_SAMPLE_RATE'
13
+ SERVICE_NAME = 'rake'
14
+ SPAN_INVOKE = 'rake.invoke'
15
+ SPAN_EXECUTE = 'rake.execute'
16
+ TAG_EXECUTE_ARGS = 'rake.execute.args'
17
+ TAG_INVOKE_ARGS = 'rake.invoke.args'
18
+ TAG_TASK_ARG_NAMES = 'rake.task.arg_names'
19
+ TAG_COMPONENT = 'rake'
20
+ TAG_OPERATION_EXECUTE = 'execute'
21
+ TAG_OPERATION_INVOKE = 'invoke'
20
22
  end
21
23
  end
22
24
  end