ddtrace 1.18.0 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +82 -1
  3. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +96 -66
  4. data/ext/ddtrace_profiling_native_extension/collectors_discrete_dynamic_sampler.c +349 -0
  5. data/ext/ddtrace_profiling_native_extension/collectors_discrete_dynamic_sampler.h +89 -0
  6. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +22 -14
  7. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +4 -0
  8. data/ext/ddtrace_profiling_native_extension/collectors_gc_profiling_helper.c +156 -0
  9. data/ext/ddtrace_profiling_native_extension/collectors_gc_profiling_helper.h +5 -0
  10. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +43 -102
  11. data/ext/ddtrace_profiling_native_extension/collectors_stack.h +10 -3
  12. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +159 -124
  13. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.h +2 -1
  14. data/ext/ddtrace_profiling_native_extension/extconf.rb +19 -0
  15. data/ext/ddtrace_profiling_native_extension/heap_recorder.c +970 -0
  16. data/ext/ddtrace_profiling_native_extension/heap_recorder.h +155 -0
  17. data/ext/ddtrace_profiling_native_extension/helpers.h +6 -0
  18. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.c +20 -0
  19. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +11 -0
  20. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +5 -0
  21. data/ext/ddtrace_profiling_native_extension/profiling.c +17 -0
  22. data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +147 -0
  23. data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +28 -0
  24. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +329 -10
  25. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +3 -0
  26. data/ext/ddtrace_profiling_native_extension/time_helpers.h +2 -0
  27. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -1
  28. data/lib/datadog/core/configuration/settings.rb +153 -21
  29. data/lib/datadog/core/environment/class_count.rb +6 -6
  30. data/lib/datadog/core/remote/component.rb +25 -12
  31. data/lib/datadog/core/remote/ext.rb +1 -0
  32. data/lib/datadog/core/remote/tie/tracing.rb +39 -0
  33. data/lib/datadog/core/remote/tie.rb +27 -0
  34. data/lib/datadog/core/telemetry/collector.rb +10 -0
  35. data/lib/datadog/core/telemetry/event.rb +2 -1
  36. data/lib/datadog/core/telemetry/ext.rb +3 -0
  37. data/lib/datadog/core/telemetry/v1/app_event.rb +8 -1
  38. data/lib/datadog/core/telemetry/v1/install_signature.rb +38 -0
  39. data/lib/datadog/opentelemetry/sdk/propagator.rb +3 -2
  40. data/lib/datadog/opentelemetry.rb +3 -0
  41. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +5 -12
  42. data/lib/datadog/profiling/component.rb +183 -13
  43. data/lib/datadog/profiling/scheduler.rb +4 -6
  44. data/lib/datadog/profiling/stack_recorder.rb +13 -2
  45. data/lib/datadog/tracing/configuration/ext.rb +0 -1
  46. data/lib/datadog/tracing/configuration/settings.rb +2 -1
  47. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +1 -0
  48. data/lib/datadog/tracing/contrib/action_cable/ext.rb +1 -0
  49. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +1 -0
  50. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +1 -0
  51. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +1 -0
  52. data/lib/datadog/tracing/contrib/action_pack/ext.rb +1 -0
  53. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +1 -0
  54. data/lib/datadog/tracing/contrib/action_view/ext.rb +1 -0
  55. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +1 -0
  56. data/lib/datadog/tracing/contrib/active_job/ext.rb +1 -0
  57. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +1 -0
  58. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +1 -0
  59. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +1 -0
  60. data/lib/datadog/tracing/contrib/active_record/ext.rb +1 -0
  61. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +1 -0
  62. data/lib/datadog/tracing/contrib/active_support/ext.rb +1 -0
  63. data/lib/datadog/tracing/contrib/analytics.rb +0 -1
  64. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +1 -0
  65. data/lib/datadog/tracing/contrib/aws/ext.rb +1 -0
  66. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +1 -0
  67. data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
  68. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +1 -0
  69. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +1 -0
  70. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +1 -0
  71. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +1 -0
  72. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +1 -0
  73. data/lib/datadog/tracing/contrib/ethon/ext.rb +1 -0
  74. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +1 -0
  75. data/lib/datadog/tracing/contrib/excon/ext.rb +1 -0
  76. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +7 -0
  77. data/lib/datadog/tracing/contrib/faraday/ext.rb +1 -0
  78. data/lib/datadog/tracing/contrib/faraday/middleware.rb +1 -1
  79. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +1 -0
  80. data/lib/datadog/tracing/contrib/grape/ext.rb +1 -0
  81. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +1 -0
  82. data/lib/datadog/tracing/contrib/graphql/ext.rb +1 -0
  83. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -0
  84. data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
  85. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +1 -0
  86. data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +2 -2
  87. data/lib/datadog/tracing/contrib/http/ext.rb +1 -0
  88. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +1 -0
  89. data/lib/datadog/tracing/contrib/httpclient/ext.rb +1 -0
  90. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +1 -0
  91. data/lib/datadog/tracing/contrib/httprb/ext.rb +1 -0
  92. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +1 -0
  93. data/lib/datadog/tracing/contrib/kafka/ext.rb +1 -0
  94. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +1 -0
  95. data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
  96. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +5 -0
  97. data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
  98. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -1
  99. data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +1 -0
  100. data/lib/datadog/tracing/contrib/opensearch/ext.rb +1 -0
  101. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +1 -0
  102. data/lib/datadog/tracing/contrib/pg/ext.rb +1 -0
  103. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +1 -0
  104. data/lib/datadog/tracing/contrib/presto/ext.rb +1 -0
  105. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +1 -0
  106. data/lib/datadog/tracing/contrib/qless/ext.rb +1 -0
  107. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +1 -0
  108. data/lib/datadog/tracing/contrib/que/ext.rb +1 -0
  109. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +1 -0
  110. data/lib/datadog/tracing/contrib/racecar/ext.rb +1 -0
  111. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +1 -0
  112. data/lib/datadog/tracing/contrib/rack/ext.rb +1 -0
  113. data/lib/datadog/tracing/contrib/rack/middlewares.rb +9 -2
  114. data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +0 -2
  115. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +1 -0
  116. data/lib/datadog/tracing/contrib/rails/ext.rb +1 -0
  117. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +1 -0
  118. data/lib/datadog/tracing/contrib/rake/ext.rb +1 -0
  119. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +1 -0
  120. data/lib/datadog/tracing/contrib/redis/ext.rb +1 -0
  121. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +2 -2
  122. data/lib/datadog/tracing/contrib/redis/patcher.rb +34 -21
  123. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +1 -0
  124. data/lib/datadog/tracing/contrib/resque/ext.rb +1 -0
  125. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -0
  126. data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
  127. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +1 -0
  128. data/lib/datadog/tracing/contrib/roda/ext.rb +1 -0
  129. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +1 -0
  130. data/lib/datadog/tracing/contrib/sequel/ext.rb +1 -0
  131. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +1 -0
  132. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +1 -0
  133. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +1 -0
  134. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +1 -0
  135. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +1 -0
  136. data/lib/datadog/tracing/contrib/sinatra/ext.rb +1 -0
  137. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +1 -0
  138. data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
  139. data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +1 -0
  140. data/lib/datadog/tracing/contrib/stripe/ext.rb +1 -0
  141. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +1 -0
  142. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +1 -0
  143. data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +58 -0
  144. data/lib/datadog/tracing/contrib/trilogy/ext.rb +27 -0
  145. data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +94 -0
  146. data/lib/datadog/tracing/contrib/trilogy/integration.rb +43 -0
  147. data/lib/datadog/tracing/contrib/trilogy/patcher.rb +31 -0
  148. data/lib/datadog/tracing/contrib.rb +1 -0
  149. data/lib/datadog/tracing.rb +8 -2
  150. data/lib/ddtrace/version.rb +1 -1
  151. metadata +20 -6
@@ -24,7 +24,7 @@ module Datadog
24
24
  # Do this once to reduce expensive regex calls.
25
25
  request_options = build_request_options!(env)
26
26
 
27
- Tracing.trace(Ext::SPAN_REQUEST) do |span, trace|
27
+ Tracing.trace(Ext::SPAN_REQUEST, on_error: request_options[:on_error]) do |span, trace|
28
28
  annotate!(span, env, request_options)
29
29
  propagate!(trace, span, env) if request_options[:distributed_tracing] && Tracing.enabled?
30
30
  app.call(env).on_complete { |resp| handle_response(span, resp, request_options) }
@@ -18,6 +18,7 @@ module Datadog
18
18
  o.default true
19
19
  end
20
20
 
21
+ # @!visibility private
21
22
  option :analytics_enabled do |o|
22
23
  o.type :bool, nilable: true
23
24
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_GRAPE_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_GRAPE_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_GRAPE_ANALYTICS_SAMPLE_RATE'
13
14
  SPAN_ENDPOINT_RENDER = 'grape.endpoint_render'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool, nilable: true
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_GRAPHQL_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_GRAPHQL_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_GRAPHQL_ANALYTICS_SAMPLE_RATE'
13
14
  SERVICE_NAME = 'graphql'
@@ -18,6 +18,7 @@ module Datadog
18
18
  o.default true
19
19
  end
20
20
 
21
+ # @!visibility private
21
22
  option :analytics_enabled do |o|
22
23
  o.type :bool
23
24
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_GRPC_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_GRPC_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_GRPC_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_GRPC_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_GRPC_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'grpc'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -13,8 +13,8 @@ module Datadog
13
13
  #
14
14
  # In case both variants are present, the verbatim match will be used.
15
15
  class Fetcher < Tracing::Distributed::Fetcher
16
- # DEV: Should we try to parse both verbatim an Rack-formatted headers,
17
- # DEV: given Rack-formatted is the most common format in Ruby?
16
+ # @param [String] name the header name
17
+ # @return [String, nil] the header value or nil if not found
18
18
  def [](name)
19
19
  # Try to fetch with the plain key
20
20
  value = super(name)
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_HTTP_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_NET_HTTP_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_NET_HTTP_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTP_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTP_ANALYTICS_SAMPLE_RATE'
15
16
  ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTP_ERROR_STATUS_CODES'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -11,6 +11,7 @@ module Datadog
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_HTTPCLIENT_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_HTTPCLIENT_PEER_SERVICE'
13
13
 
14
+ # @!visibility private
14
15
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPCLIENT_ANALYTICS_ENABLED'
15
16
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTPCLIENT_ANALYTICS_SAMPLE_RATE'
16
17
  ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_HTTPRB_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_HTTPRB_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_HTTPRB_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPRB_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_EHTTPRB_ANALYTICS_SAMPLE_RATE'
15
16
  ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_KAFKA_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_KAFKA_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_KAFKA_ANALYTICS_SAMPLE_RATE'
13
14
  SPAN_CONNECTION_REQUEST = 'kafka.connection.request'
@@ -19,6 +19,7 @@ module Datadog
19
19
  o.default true
20
20
  end
21
21
 
22
+ # @!visibility private
22
23
  option :analytics_enabled do |o|
23
24
  o.type :bool
24
25
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_MONGO_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_MONGO_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_MONGO_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_MONGO_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_MONGO_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'mongodb'
@@ -19,6 +19,7 @@ module Datadog
19
19
  o.default true
20
20
  end
21
21
 
22
+ # @!visibility private
22
23
  option :analytics_enabled do |o|
23
24
  o.type :bool
24
25
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -50,6 +51,10 @@ module Datadog
50
51
  o.type :string, nilable: true
51
52
  o.env Ext::ENV_PEER_SERVICE
52
53
  end
54
+
55
+ option :on_error do |o|
56
+ o.type :proc, nilable: true
57
+ end
53
58
  end
54
59
  end
55
60
  end
@@ -11,6 +11,7 @@ module Datadog
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_MYSQL2_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_MYSQL2_PEER_SERVICE'
13
13
 
14
+ # @!visibility private
14
15
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_MYSQL2_ANALYTICS_ENABLED'
15
16
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_MYSQL2_ANALYTICS_SAMPLE_RATE'
16
17
  DEFAULT_PEER_SERVICE_NAME = 'mysql2'
@@ -21,8 +21,9 @@ module Datadog
21
21
  module InstanceMethods
22
22
  def query(sql, options = {})
23
23
  service = Datadog.configuration_for(self, :service_name) || datadog_configuration[:service_name]
24
+ on_error = Datadog.configuration_for(self, :on_error) || datadog_configuration[:on_error]
24
25
 
25
- Tracing.trace(Ext::SPAN_QUERY, service: service) do |span, trace_op|
26
+ Tracing.trace(Ext::SPAN_QUERY, service: service, on_error: on_error) do |span, trace_op|
26
27
  span.resource = sql
27
28
  span.span_type = Tracing::Metadata::Ext::SQL::TYPE
28
29
 
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_OPENSEARCH_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_OPENSEARCH_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_OPENSEARCH_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_OPENSEARCH_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_OPENSEARCH_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'opensearch'
@@ -19,6 +19,7 @@ module Datadog
19
19
  o.default true
20
20
  end
21
21
 
22
+ # @!visibility private
22
23
  option :analytics_enabled do |o|
23
24
  o.type :bool
24
25
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_PG_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_PG_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_PG_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_PG_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_PG_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'pg'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_PRESTO_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_PRESTO_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_PRESTO_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_PRESTO_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_PRESTO_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'presto'
@@ -11,6 +11,7 @@ module Datadog
11
11
  # Custom settings for the Qless integration
12
12
  # @public_api
13
13
  class Settings < Contrib::Configuration::Settings
14
+ # @!visibility private
14
15
  option :analytics_enabled do |o|
15
16
  o.type :bool
16
17
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -7,6 +7,7 @@ module Datadog
7
7
  # Qless integration constants
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
+ # @!visibility private
10
11
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_QLESS_ANALYTICS_ENABLED'
11
12
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_QLESS_ANALYTICS_SAMPLE_RATE'
12
13
  ENV_TAG_JOB_DATA = 'DD_QLESS_TAG_JOB_DATA'
@@ -20,6 +20,7 @@ module Datadog
20
20
  o.default true
21
21
  end
22
22
 
23
+ # @!visibility private
23
24
  option :analytics_enabled do |o|
24
25
  o.type :bool
25
26
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -7,6 +7,7 @@ module Datadog
7
7
  # Que integration constants
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
+ # @!visibility private
10
11
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_QUE_ANALYTICS_ENABLED'
11
12
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_QUE_ANALYTICS_SAMPLE_RATE'
12
13
  ENV_ENABLED = 'DD_TRACE_QUE_ENABLED'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_RACECAR_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACECAR_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'
13
14
  DEFAULT_PEER_SERVICE_NAME = 'racecar'
@@ -22,6 +22,7 @@ module Datadog
22
22
  o.default true
23
23
  end
24
24
 
25
+ # @!visibility private
25
26
  option :analytics_enabled do |o|
26
27
  o.type :bool, nilable: true
27
28
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_RACK_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACK_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACK_ANALYTICS_SAMPLE_RATE'
13
14
  RACK_ENV_REQUEST_SPAN = 'datadog.rack_request_span'
@@ -2,6 +2,7 @@ require 'date'
2
2
 
3
3
  require_relative '../../../core/environment/variable_helpers'
4
4
  require_relative '../../../core/backport'
5
+ require_relative '../../../core/remote/tie/tracing'
5
6
  require_relative '../../client_ip'
6
7
  require_relative '../../metadata/ext'
7
8
  require_relative '../../propagation/http'
@@ -71,7 +72,7 @@ module Datadog
71
72
 
72
73
  return @app.call(env) if previous_request_span
73
74
 
74
- Datadog::Core::Remote.active_remote.barrier(:once) unless Datadog::Core::Remote.active_remote.nil?
75
+ boot = Datadog::Core::Remote::Tie.boot
75
76
 
76
77
  # Extract distributed tracing context before creating any spans,
77
78
  # so that all spans will be added to the distributed trace.
@@ -91,9 +92,15 @@ module Datadog
91
92
  # we must ensure that the span `resource` is set later
92
93
  request_span = Tracing.trace(Ext::SPAN_REQUEST, **trace_options)
93
94
  request_span.resource = nil
94
- request_trace = Tracing.active_trace
95
+
96
+ # When tracing and distributed tracing are both disabled, `.active_trace` will be `nil`,
97
+ # Return a null object to continue operation
98
+ request_trace = Tracing.active_trace || TraceOperation.new
99
+
95
100
  env[Ext::RACK_ENV_REQUEST_SPAN] = request_span
96
101
 
102
+ Datadog::Core::Remote::Tie::Tracing.tag(boot, request_span)
103
+
97
104
  # Copy the original env, before the rest of the stack executes.
98
105
  # Values may change; we want values before that happens.
99
106
  original_env = env.dup
@@ -1,5 +1,3 @@
1
- require_relative '../auto_instrument'
2
-
3
1
  # Railtie to include AutoInstrumentation in rails loading
4
2
  class DatadogAutoInstrumentRailtie < Rails::Railtie
5
3
  # we want to load before config initializers so that any user supplied config
@@ -29,6 +29,7 @@ module Datadog
29
29
  o.default true
30
30
  end
31
31
 
32
+ # @!visibility private
32
33
  option :analytics_enabled do |o|
33
34
  o.type :bool, nilable: true
34
35
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -9,6 +9,7 @@ module Datadog
9
9
  module Ext
10
10
  APP = 'rails'
11
11
  ENV_ENABLED = 'DD_TRACE_RAILS_ENABLED'
12
+ # @!visibility private
12
13
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAILS_ANALYTICS_ENABLED'
13
14
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAILS_ANALYTICS_SAMPLE_RATE'
14
15
  ENV_DISABLE = 'DISABLE_DATADOG_RAILS'
@@ -19,6 +19,7 @@ module Datadog
19
19
  o.default true
20
20
  end
21
21
 
22
+ # @!visibility private
22
23
  option :analytics_enabled do |o|
23
24
  o.type :bool
24
25
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_RAKE_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAKE_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAKE_ANALYTICS_SAMPLE_RATE'
13
14
  SERVICE_NAME = 'rake'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_REDIS_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_REDIS_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_REDIS_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_REDIS_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_REDIS_ANALYTICS_SAMPLE_RATE'
15
16
  ENV_COMMAND_ARGS = 'DD_REDIS_COMMAND_ARGS'
@@ -28,7 +28,7 @@ module Datadog
28
28
  private
29
29
 
30
30
  def command_args?
31
- pinned = Datadog.configuration_for(redis_instance, :command_args)
31
+ pinned = Datadog.configuration_for(self, :command_args)
32
32
 
33
33
  return pinned unless pinned.nil?
34
34
 
@@ -36,7 +36,7 @@ module Datadog
36
36
  end
37
37
 
38
38
  def service_name
39
- Datadog.configuration_for(redis_instance, :service_name) ||
39
+ Datadog.configuration_for(self, :service_name) ||
40
40
  datadog_configuration[:service_name]
41
41
  end
42
42
 
@@ -10,38 +10,48 @@ module Datadog
10
10
  module Patcher
11
11
  include Contrib::Patcher
12
12
 
13
- # Patch for redis instance
14
- module InstancePatch
13
+ # Patch for redis instance (with redis < 5)
14
+ module DatadogPinPatch
15
15
  def self.included(base)
16
16
  base.prepend(InstanceMethods)
17
17
  end
18
18
 
19
19
  # Instance method patch for redis instance
20
20
  module InstanceMethods
21
- # `options` could be frozen
22
- def initialize(options = {})
23
- super(options.merge(redis_instance: self))
21
+ def datadog_pin=(pin)
22
+ pin.onto(datadog_target)
23
+ end
24
+
25
+ def datadog_target
26
+ # For `redis-rb` 4.x
27
+ return _client if respond_to?(:_client)
28
+ # For `redis-rb` 3.x
29
+ return client if respond_to?(:client)
30
+
31
+ Datadog.logger.warn 'Fail to apply configuration on redis client instance with ' \
32
+ '`Datadog.configure_onto(redis)`.'
33
+
34
+ # Null object instead of raising error
35
+ self
24
36
  end
25
37
  end
26
38
  end
27
39
 
28
- # Patch for redis client
29
- module ClientPatch
40
+ # Patch for redis instance (with redis >= 5)
41
+ module NotSupportedNoticePatch
30
42
  def self.included(base)
31
43
  base.prepend(InstanceMethods)
32
44
  end
33
45
 
34
- # Instance method patch for redis client
46
+ # Instance method patch for redis instance
35
47
  module InstanceMethods
36
- def initialize(options = {})
37
- @redis_instance = options.delete(:redis_instance)
38
-
39
- super(options)
48
+ def datadog_pin=(_pin)
49
+ Datadog.logger.warn \
50
+ '`Datadog.configure_onto(redis)` is not supported on Redis 5+. To instrument '\
51
+ "a redis instance with custom configuration, please initialize it with:\n"\
52
+ " `Redis.new(..., custom: { datadog: { service_name: 'my-service' } })`.\n\n" \
53
+ 'See: https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md#redis'
40
54
  end
41
-
42
- private
43
-
44
- attr_reader :redis_instance
45
55
  end
46
56
  end
47
57
 
@@ -62,12 +72,15 @@ module Datadog
62
72
  ::RedisClient.register(TraceMiddleware)
63
73
  end
64
74
 
65
- if Integration.redis_compatible? && Integration.redis_version < Gem::Version.new('5.0.0')
66
- require_relative 'instrumentation'
75
+ if Integration.redis_compatible?
76
+ if Integration.redis_version < Gem::Version.new('5.0.0')
77
+ require_relative 'instrumentation'
67
78
 
68
- ::Redis.include(InstancePatch)
69
- ::Redis::Client.include(ClientPatch)
70
- ::Redis::Client.include(Instrumentation)
79
+ ::Redis.include(DatadogPinPatch)
80
+ ::Redis::Client.include(Instrumentation)
81
+ else # warn about non-supported configure_onto usage
82
+ ::Redis.include(NotSupportedNoticePatch)
83
+ end
71
84
  end
72
85
  end
73
86
  end
@@ -18,6 +18,7 @@ module Datadog
18
18
  o.default true
19
19
  end
20
20
 
21
+ # @!visibility private
21
22
  option :analytics_enabled do |o|
22
23
  o.type :bool
23
24
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_RESQUE_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_RESQUE_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RESQUE_ANALYTICS_SAMPLE_RATE'
13
14
  SERVICE_NAME = 'resque'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -10,6 +10,7 @@ module Datadog
10
10
  ENV_ENABLED = 'DD_TRACE_REST_CLIENT_ENABLED'
11
11
  ENV_SERVICE_NAME = 'DD_TRACE_REST_CLIENT_SERVICE_NAME'
12
12
  ENV_PEER_SERVICE = 'DD_TRACE_REST_CLIENT_PEER_SERVICE'
13
+ # @!visibility private
13
14
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_REST_CLIENT_ANALYTICS_ENABLED'
14
15
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_REST_CLIENT_ANALYTICS_SAMPLE_RATE'
15
16
  DEFAULT_PEER_SERVICE_NAME = 'rest_client'
@@ -16,6 +16,7 @@ module Datadog
16
16
  o.default true
17
17
  end
18
18
 
19
+ # @!visibility private
19
20
  option :analytics_enabled do |o|
20
21
  o.type :bool
21
22
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  module Ext
9
9
  APP = 'roda'
10
10
  ENV_ENABLED = 'DD_TRACE_RODA_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_RODA_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_RODA_ANALYTICS_SAMPLE_RATE'
13
14
  SPAN_REQUEST = 'roda.request'
@@ -17,6 +17,7 @@ module Datadog
17
17
  o.default true
18
18
  end
19
19
 
20
+ # @!visibility private
20
21
  option :analytics_enabled do |o|
21
22
  o.type :bool
22
23
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_SEQUEL_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_SEQUEL_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SEQUEL_ANALYTICS_SAMPLE_RATE'
13
14
  SPAN_QUERY = 'sequel.query'
@@ -18,6 +18,7 @@ module Datadog
18
18
  o.default true
19
19
  end
20
20
 
21
+ # @!visibility private
21
22
  option :analytics_enabled do |o|
22
23
  o.type :bool
23
24
  o.env Ext::ENV_ANALYTICS_ENABLED
@@ -8,6 +8,7 @@ module Datadog
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
10
  ENV_ENABLED = 'DD_TRACE_SHORYUKEN_ENABLED'
11
+ # @!visibility private
11
12
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_SHORYUKEN_ANALYTICS_ENABLED'
12
13
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SHORYUKEN_ANALYTICS_SAMPLE_RATE'
13
14
  SERVICE_NAME = 'shoryuken'