ddtrace 1.6.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -2
  3. data/README.md +2 -2
  4. data/ext/ddtrace_profiling_loader/extconf.rb +5 -2
  5. data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +1 -1
  6. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +3 -2
  7. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +81 -47
  8. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +1 -1
  9. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +332 -125
  10. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +142 -0
  11. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +14 -0
  12. data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +241 -0
  13. data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.h +3 -0
  14. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +11 -13
  15. data/ext/ddtrace_profiling_native_extension/extconf.rb +22 -8
  16. data/ext/ddtrace_profiling_native_extension/helpers.h +5 -0
  17. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +8 -0
  18. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +111 -26
  19. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +9 -0
  20. data/ext/ddtrace_profiling_native_extension/profiling.c +205 -0
  21. data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +86 -0
  22. data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +28 -6
  23. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.c +115 -0
  24. data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +11 -0
  25. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +84 -35
  26. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +1 -0
  27. data/ext/ddtrace_profiling_native_extension/time_helpers.c +17 -0
  28. data/ext/ddtrace_profiling_native_extension/time_helpers.h +10 -0
  29. data/lib/datadog/appsec/assets/blocked.html +98 -3
  30. data/lib/datadog/appsec/assets/blocked.json +1 -0
  31. data/lib/datadog/appsec/assets/blocked.text +5 -0
  32. data/lib/datadog/appsec/assets/waf_rules/recommended.json +35 -46
  33. data/lib/datadog/appsec/assets/waf_rules/risky.json +1 -1
  34. data/lib/datadog/appsec/assets/waf_rules/strict.json +46 -1
  35. data/lib/datadog/appsec/assets.rb +2 -2
  36. data/lib/datadog/appsec/configuration/settings.rb +6 -0
  37. data/lib/datadog/appsec/configuration.rb +4 -0
  38. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +4 -8
  39. data/lib/datadog/appsec/contrib/rack/request.rb +17 -0
  40. data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +2 -2
  41. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -2
  42. data/lib/datadog/appsec/contrib/rails/patcher.rb +3 -6
  43. data/lib/datadog/appsec/contrib/sinatra/ext.rb +1 -0
  44. data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +1 -1
  45. data/lib/datadog/appsec/contrib/sinatra/patcher.rb +11 -8
  46. data/lib/datadog/appsec/extensions.rb +10 -0
  47. data/lib/datadog/appsec/processor.rb +18 -0
  48. data/lib/datadog/appsec/response.rb +54 -0
  49. data/lib/datadog/core/configuration/components.rb +27 -6
  50. data/lib/datadog/core/configuration/ext.rb +18 -0
  51. data/lib/datadog/core/configuration/settings.rb +14 -341
  52. data/lib/datadog/core/diagnostics/health.rb +4 -22
  53. data/lib/datadog/core/environment/variable_helpers.rb +58 -10
  54. data/lib/datadog/core/runtime/ext.rb +1 -1
  55. data/lib/datadog/core/utils.rb +0 -21
  56. data/lib/datadog/core.rb +21 -1
  57. data/lib/datadog/opentracer/distributed_headers.rb +7 -9
  58. data/lib/datadog/opentracer/rack_propagator.rb +0 -3
  59. data/lib/datadog/opentracer/text_map_propagator.rb +5 -7
  60. data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +10 -4
  61. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +20 -5
  62. data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +14 -0
  63. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +68 -0
  64. data/lib/datadog/profiling/collectors/old_stack.rb +7 -0
  65. data/lib/datadog/profiling/exporter.rb +5 -0
  66. data/lib/datadog/profiling/old_recorder.rb +8 -0
  67. data/lib/datadog/profiling/profiler.rb +7 -0
  68. data/lib/datadog/profiling/scheduler.rb +4 -7
  69. data/lib/datadog/profiling/stack_recorder.rb +36 -0
  70. data/lib/datadog/profiling/tasks/setup.rb +0 -7
  71. data/lib/datadog/profiling.rb +2 -0
  72. data/lib/datadog/tracing/configuration/ext.rb +33 -3
  73. data/lib/datadog/tracing/configuration/settings.rb +433 -0
  74. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +4 -1
  75. data/lib/datadog/tracing/contrib/aws/ext.rb +1 -0
  76. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +4 -1
  77. data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
  78. data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +4 -0
  79. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +5 -1
  80. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +1 -0
  81. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +6 -1
  82. data/lib/datadog/tracing/contrib/ethon/ext.rb +1 -0
  83. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +5 -1
  84. data/lib/datadog/tracing/contrib/excon/ext.rb +1 -0
  85. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +5 -1
  86. data/lib/datadog/tracing/contrib/faraday/ext.rb +1 -0
  87. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +6 -1
  88. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +2 -1
  89. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +6 -12
  90. data/lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb +27 -0
  91. data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +43 -0
  92. data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
  93. data/lib/datadog/tracing/contrib/grpc/patcher.rb +0 -2
  94. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +6 -1
  95. data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +32 -0
  96. data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +38 -0
  97. data/lib/datadog/tracing/contrib/http/ext.rb +1 -0
  98. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +6 -1
  99. data/lib/datadog/tracing/contrib/httpclient/ext.rb +1 -0
  100. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +6 -1
  101. data/lib/datadog/tracing/contrib/httprb/ext.rb +1 -0
  102. data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +1 -0
  103. data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +1 -0
  104. data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +1 -0
  105. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +5 -1
  106. data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
  107. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +2 -0
  108. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +4 -1
  109. data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
  110. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -2
  111. data/lib/datadog/tracing/contrib/patcher.rb +3 -2
  112. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +4 -1
  113. data/lib/datadog/tracing/contrib/pg/ext.rb +1 -0
  114. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +12 -2
  115. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +4 -1
  116. data/lib/datadog/tracing/contrib/presto/ext.rb +1 -0
  117. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +1 -0
  118. data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +10 -12
  119. data/lib/datadog/tracing/contrib/que/tracer.rb +2 -0
  120. data/lib/datadog/tracing/contrib/racecar/events/batch.rb +4 -1
  121. data/lib/datadog/tracing/contrib/racecar/events/message.rb +4 -1
  122. data/lib/datadog/tracing/contrib/rack/middlewares.rb +2 -0
  123. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +4 -1
  124. data/lib/datadog/tracing/contrib/redis/ext.rb +1 -0
  125. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +30 -21
  126. data/lib/datadog/tracing/contrib/redis/integration.rb +34 -2
  127. data/lib/datadog/tracing/contrib/redis/patcher.rb +18 -14
  128. data/lib/datadog/tracing/contrib/redis/quantize.rb +12 -9
  129. data/lib/datadog/tracing/contrib/redis/tags.rb +4 -6
  130. data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +72 -0
  131. data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
  132. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +6 -1
  133. data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
  134. data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
  135. data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +5 -0
  136. data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -0
  137. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +2 -0
  138. data/lib/datadog/{core → tracing}/diagnostics/ext.rb +1 -6
  139. data/lib/datadog/tracing/diagnostics/health.rb +40 -0
  140. data/lib/datadog/tracing/distributed/b3_multi.rb +66 -0
  141. data/lib/datadog/tracing/distributed/b3_single.rb +66 -0
  142. data/lib/datadog/tracing/distributed/datadog.rb +153 -0
  143. data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +1 -0
  144. data/lib/datadog/tracing/distributed/fetcher.rb +30 -0
  145. data/lib/datadog/tracing/distributed/headers/ext.rb +18 -16
  146. data/lib/datadog/tracing/distributed/helpers.rb +9 -7
  147. data/lib/datadog/tracing/distributed/none.rb +19 -0
  148. data/lib/datadog/tracing/distributed/propagation.rb +127 -0
  149. data/lib/datadog/tracing/distributed/trace_context.rb +369 -0
  150. data/lib/datadog/tracing/metadata/ext.rb +1 -1
  151. data/lib/datadog/tracing/propagation/http.rb +3 -106
  152. data/lib/datadog/tracing/sampling/priority_sampler.rb +11 -0
  153. data/lib/datadog/tracing/sampling/rate_sampler.rb +3 -3
  154. data/lib/datadog/tracing/span.rb +3 -19
  155. data/lib/datadog/tracing/span_operation.rb +5 -4
  156. data/lib/datadog/tracing/trace_digest.rb +75 -2
  157. data/lib/datadog/tracing/trace_operation.rb +5 -4
  158. data/lib/datadog/tracing/trace_segment.rb +1 -1
  159. data/lib/datadog/tracing/utils.rb +50 -0
  160. data/lib/ddtrace/transport/trace_formatter.rb +2 -5
  161. data/lib/ddtrace/version.rb +2 -2
  162. metadata +35 -15
  163. data/lib/datadog/tracing/distributed/headers/b3.rb +0 -55
  164. data/lib/datadog/tracing/distributed/headers/b3_single.rb +0 -67
  165. data/lib/datadog/tracing/distributed/headers/datadog.rb +0 -144
  166. data/lib/datadog/tracing/distributed/headers/parser.rb +0 -37
  167. data/lib/datadog/tracing/distributed/metadata/b3.rb +0 -55
  168. data/lib/datadog/tracing/distributed/metadata/b3_single.rb +0 -66
  169. data/lib/datadog/tracing/distributed/metadata/datadog.rb +0 -73
  170. data/lib/datadog/tracing/distributed/metadata/parser.rb +0 -34
  171. data/lib/datadog/tracing/propagation/grpc.rb +0 -98
@@ -6,6 +6,70 @@ module Datadog
6
6
  # Used to propagate context and continue traces across execution boundaries.
7
7
  # @public_api
8
8
  class TraceDigest
9
+ # @!attribute [r] span_id
10
+ # Datadog id for the currently active span.
11
+ # @return [Integer]
12
+ # @!attribute [r] span_name
13
+ # The operation name of the currently active span.
14
+ # @return [String]
15
+ # @!attribute [r] span_resource
16
+ # The resource name of the currently active span.
17
+ # @return [String]
18
+ # @!attribute [r] span_service
19
+ # The service of the currently active span.
20
+ # @return [String]
21
+ # @!attribute [r] span_type
22
+ # The type of the currently active span.
23
+ # @return [String]
24
+ # @!attribute [r] trace_distributed_tags
25
+ # Datadog-specific tags that support richer distributed tracing association.
26
+ # @return [Hash<String,String>]
27
+ # @!attribute [r] trace_hostname
28
+ # The hostname of the currently active trace. Use to attribute traces to hosts.
29
+ # @return [String]
30
+ # @!attribute [r] trace_id
31
+ # Datadog id for the currently active trace.
32
+ # @return [Integer]
33
+ # @!attribute [r] trace_name
34
+ # Operation name for the currently active trace.
35
+ # @return [Integer]
36
+ # @!attribute [r] trace_origin
37
+ # Datadog-specific attribution of this trace's creation.
38
+ # @return [String]
39
+ # @!attribute [r] trace_process_id
40
+ # The OS-specific process id.
41
+ # @return [Integer]
42
+ # @!attribute [r] trace_resource
43
+ # The resource name of the currently active trace.
44
+ # @return [String]
45
+ # @!attribute [r] trace_runtime_id
46
+ # Unique id to this Ruby process. Used to differentiate traces coming from
47
+ # child processes forked from same parent process.
48
+ # @return [String]
49
+ # @!attribute [r] trace_sampling_priority
50
+ # Datadog-specific sampling decision for the currently active trace.
51
+ # @return [Integer]
52
+ # @!attribute [r] trace_service
53
+ # The service of the currently active trace.
54
+ # @return [String]
55
+ # @!attribute [r] trace_distributed_id
56
+ # The trace id extracted from a distributed context, if different from `trace_id`.
57
+ #
58
+ # The current use case is when the distributed context has a trace id integer larger than 64-bit:
59
+ # This attribute will preserve the original id, while `trace_id` will only contain the lower 64 bits.
60
+ # @return [Integer]
61
+ # @see https://www.w3.org/TR/trace-context/#trace-id
62
+ # @!attribute [r] trace_tracestate
63
+ # The W3C "tracestate" extracted from a distributed context.
64
+ # This field is a string representing vendor-specific distribution data.
65
+ # @return [String]
66
+ # @see https://www.w3.org/TR/trace-context/#tracestate-header
67
+ # @!attribute [r] trace_flags
68
+ # The W3C "trace-flags" extracted from a distributed context. This field is an 8-bit unsigned integer.
69
+ # @return [Integer]
70
+ # @see https://www.w3.org/TR/trace-context/#trace-flags
71
+ # TODO: The documentation for the last attribute above won't be rendered.
72
+ # TODO: This might be a YARD bug as adding an attribute, making it now second-last attribute, renders correctly.
9
73
  attr_reader \
10
74
  :span_id,
11
75
  :span_name,
@@ -21,7 +85,10 @@ module Datadog
21
85
  :trace_resource,
22
86
  :trace_runtime_id,
23
87
  :trace_sampling_priority,
24
- :trace_service
88
+ :trace_service,
89
+ :trace_distributed_id,
90
+ :trace_flags,
91
+ :trace_state
25
92
 
26
93
  def initialize(
27
94
  span_id: nil,
@@ -38,7 +105,10 @@ module Datadog
38
105
  trace_resource: nil,
39
106
  trace_runtime_id: nil,
40
107
  trace_sampling_priority: nil,
41
- trace_service: nil
108
+ trace_service: nil,
109
+ trace_distributed_id: nil,
110
+ trace_flags: nil,
111
+ trace_state: nil
42
112
  )
43
113
  @span_id = span_id
44
114
  @span_name = span_name && span_name.dup.freeze
@@ -55,6 +125,9 @@ module Datadog
55
125
  @trace_runtime_id = trace_runtime_id && trace_runtime_id.dup.freeze
56
126
  @trace_sampling_priority = trace_sampling_priority
57
127
  @trace_service = trace_service && trace_service.dup.freeze
128
+ @trace_distributed_id = trace_distributed_id
129
+ @trace_flags = trace_flags
130
+ @trace_state = trace_state && trace_state.dup.freeze
58
131
 
59
132
  freeze
60
133
  end
@@ -4,12 +4,13 @@ require_relative '../core'
4
4
  require_relative '../core/environment/identity'
5
5
  require_relative '../core/utils'
6
6
 
7
- require_relative 'sampling/ext'
8
7
  require_relative 'event'
8
+ require_relative 'metadata/tagging'
9
+ require_relative 'sampling/ext'
9
10
  require_relative 'span_operation'
10
- require_relative 'trace_segment'
11
11
  require_relative 'trace_digest'
12
- require_relative 'metadata/tagging'
12
+ require_relative 'trace_segment'
13
+ require_relative 'utils'
13
14
 
14
15
  module Datadog
15
16
  module Tracing
@@ -70,7 +71,7 @@ module Datadog
70
71
  metrics: nil
71
72
  )
72
73
  # Attributes
73
- @id = id || Core::Utils.next_id
74
+ @id = id || Tracing::Utils.next_id
74
75
  @max_length = max_length || DEFAULT_MAX_LENGTH
75
76
  @parent_span_id = parent_span_id
76
77
  @sampled = sampled.nil? ? true : sampled
@@ -173,7 +173,7 @@ module Datadog
173
173
  end
174
174
 
175
175
  def process_id_tag
176
- meta[Core::Runtime::Ext::TAG_PID]
176
+ meta[Core::Runtime::Ext::TAG_PROCESS_ID]
177
177
  end
178
178
 
179
179
  def rate_limiter_rate_tag
@@ -0,0 +1,50 @@
1
+ # typed: true
2
+
3
+ require_relative '../core/utils/forking'
4
+
5
+ module Datadog
6
+ module Tracing
7
+ # Utils contains low-level tracing utility functions.
8
+ # @public_api
9
+ module Utils
10
+ extend Datadog::Core::Utils::Forking
11
+
12
+ # The max value for a {Datadog::Tracing::Span} identifier.
13
+ # Span and trace identifiers should be strictly positive and strictly inferior to this limit.
14
+ #
15
+ # Limited to +2<<62-1+ positive integers, as Ruby is able to represent such numbers "inline",
16
+ # inside a +VALUE+ scalar, thus not requiring memory allocation.
17
+ #
18
+ # The range of IDs also has to consider portability across different languages and platforms.
19
+ RUBY_MAX_ID = (1 << 62) - 1
20
+
21
+ # Excludes zero from possible values
22
+ RUBY_ID_RANGE = (1..RUBY_MAX_ID).freeze
23
+
24
+ # While we only generate 63-bit integers due to limitations in other languages, we support
25
+ # parsing 64-bit integers for distributed tracing since an upstream system may generate one
26
+ EXTERNAL_MAX_ID = 1 << 64
27
+
28
+ # We use a custom random number generator because we want no interference
29
+ # with the default one. Using the default prng, we could break code that
30
+ # would rely on srand/rand sequences.
31
+
32
+ # Return a randomly generated integer, valid as a Span ID or Trace ID.
33
+ # This method is thread-safe and fork-safe.
34
+ def self.next_id
35
+ after_fork! { reset! }
36
+ id_rng.rand(RUBY_ID_RANGE)
37
+ end
38
+
39
+ def self.id_rng
40
+ @id_rng ||= Random.new
41
+ end
42
+
43
+ def self.reset!
44
+ @id_rng = Random.new
45
+ end
46
+
47
+ private_class_method :id_rng, :reset!
48
+ end
49
+ end
50
+ end
@@ -94,7 +94,7 @@ module Datadog
94
94
  end
95
95
 
96
96
  def tag_lang!
97
- return if trace.lang.nil? || root_span.get_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE)
97
+ return if trace.lang.nil?
98
98
 
99
99
  root_span.set_tag(
100
100
  Core::Runtime::Ext::TAG_LANG,
@@ -114,10 +114,7 @@ module Datadog
114
114
  def tag_process_id!
115
115
  return unless trace.process_id
116
116
 
117
- root_span.set_tag(
118
- Core::Runtime::Ext::TAG_PID,
119
- trace.process_id
120
- )
117
+ root_span.set_tag(Core::Runtime::Ext::TAG_PROCESS_ID, trace.process_id)
121
118
  end
122
119
 
123
120
  def tag_rate_limiter_rate!
@@ -3,8 +3,8 @@
3
3
  module DDTrace
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 6
7
- PATCH = 1
6
+ MINOR = 8
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2022-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.10.16
34
34
  - - "<="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.10.17
36
+ version: 0.10.18
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.10.16
44
44
  - - "<="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.10.17
46
+ version: 0.10.18
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: libddwaf
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,10 @@ files:
102
102
  - ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c
103
103
  - ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h
104
104
  - ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c
105
+ - ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c
106
+ - ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h
107
+ - ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c
108
+ - ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.h
105
109
  - ext/ddtrace_profiling_native_extension/collectors_stack.c
106
110
  - ext/ddtrace_profiling_native_extension/collectors_stack.h
107
111
  - ext/ddtrace_profiling_native_extension/extconf.rb
@@ -114,11 +118,17 @@ files:
114
118
  - ext/ddtrace_profiling_native_extension/profiling.c
115
119
  - ext/ddtrace_profiling_native_extension/ruby_helpers.c
116
120
  - ext/ddtrace_profiling_native_extension/ruby_helpers.h
121
+ - ext/ddtrace_profiling_native_extension/setup_signal_handler.c
122
+ - ext/ddtrace_profiling_native_extension/setup_signal_handler.h
117
123
  - ext/ddtrace_profiling_native_extension/stack_recorder.c
118
124
  - ext/ddtrace_profiling_native_extension/stack_recorder.h
125
+ - ext/ddtrace_profiling_native_extension/time_helpers.c
126
+ - ext/ddtrace_profiling_native_extension/time_helpers.h
119
127
  - lib/datadog/appsec.rb
120
128
  - lib/datadog/appsec/assets.rb
121
129
  - lib/datadog/appsec/assets/blocked.html
130
+ - lib/datadog/appsec/assets/blocked.json
131
+ - lib/datadog/appsec/assets/blocked.text
122
132
  - lib/datadog/appsec/assets/waf_rules/README.md
123
133
  - lib/datadog/appsec/assets/waf_rules/recommended.json
124
134
  - lib/datadog/appsec/assets/waf_rules/risky.json
@@ -168,6 +178,7 @@ files:
168
178
  - lib/datadog/appsec/reactive/engine.rb
169
179
  - lib/datadog/appsec/reactive/operation.rb
170
180
  - lib/datadog/appsec/reactive/subscriber.rb
181
+ - lib/datadog/appsec/response.rb
171
182
  - lib/datadog/ci.rb
172
183
  - lib/datadog/ci/configuration/components.rb
173
184
  - lib/datadog/ci/configuration/settings.rb
@@ -199,6 +210,7 @@ files:
199
210
  - lib/datadog/core/configuration/base.rb
200
211
  - lib/datadog/core/configuration/components.rb
201
212
  - lib/datadog/core/configuration/dependency_resolver.rb
213
+ - lib/datadog/core/configuration/ext.rb
202
214
  - lib/datadog/core/configuration/option.rb
203
215
  - lib/datadog/core/configuration/option_definition.rb
204
216
  - lib/datadog/core/configuration/option_definition_set.rb
@@ -206,7 +218,6 @@ files:
206
218
  - lib/datadog/core/configuration/options.rb
207
219
  - lib/datadog/core/configuration/settings.rb
208
220
  - lib/datadog/core/diagnostics/environment_logger.rb
209
- - lib/datadog/core/diagnostics/ext.rb
210
221
  - lib/datadog/core/diagnostics/health.rb
211
222
  - lib/datadog/core/encoding.rb
212
223
  - lib/datadog/core/environment/cgroup.rb
@@ -302,6 +313,8 @@ files:
302
313
  - lib/datadog/profiling/collectors/code_provenance.rb
303
314
  - lib/datadog/profiling/collectors/cpu_and_wall_time.rb
304
315
  - lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb
316
+ - lib/datadog/profiling/collectors/dynamic_sampling_rate.rb
317
+ - lib/datadog/profiling/collectors/idle_sampling_helper.rb
305
318
  - lib/datadog/profiling/collectors/old_stack.rb
306
319
  - lib/datadog/profiling/collectors/stack.rb
307
320
  - lib/datadog/profiling/encoding/profile.rb
@@ -339,6 +352,7 @@ files:
339
352
  - lib/datadog/tracing/buffer.rb
340
353
  - lib/datadog/tracing/client_ip.rb
341
354
  - lib/datadog/tracing/configuration/ext.rb
355
+ - lib/datadog/tracing/configuration/settings.rb
342
356
  - lib/datadog/tracing/context.rb
343
357
  - lib/datadog/tracing/context_provider.rb
344
358
  - lib/datadog/tracing/contrib.rb
@@ -492,6 +506,8 @@ files:
492
506
  - lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb
493
507
  - lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb
494
508
  - lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb
509
+ - lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb
510
+ - lib/datadog/tracing/contrib/grpc/distributed/propagation.rb
495
511
  - lib/datadog/tracing/contrib/grpc/ext.rb
496
512
  - lib/datadog/tracing/contrib/grpc/integration.rb
497
513
  - lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb
@@ -506,6 +522,8 @@ files:
506
522
  - lib/datadog/tracing/contrib/hanami/router_tracing.rb
507
523
  - lib/datadog/tracing/contrib/http/circuit_breaker.rb
508
524
  - lib/datadog/tracing/contrib/http/configuration/settings.rb
525
+ - lib/datadog/tracing/contrib/http/distributed/fetcher.rb
526
+ - lib/datadog/tracing/contrib/http/distributed/propagation.rb
509
527
  - lib/datadog/tracing/contrib/http/ext.rb
510
528
  - lib/datadog/tracing/contrib/http/instrumentation.rb
511
529
  - lib/datadog/tracing/contrib/http/integration.rb
@@ -622,6 +640,7 @@ files:
622
640
  - lib/datadog/tracing/contrib/redis/patcher.rb
623
641
  - lib/datadog/tracing/contrib/redis/quantize.rb
624
642
  - lib/datadog/tracing/contrib/redis/tags.rb
643
+ - lib/datadog/tracing/contrib/redis/trace_middleware.rb
625
644
  - lib/datadog/tracing/contrib/redis/vendor/LICENSE
626
645
  - lib/datadog/tracing/contrib/redis/vendor/resolver.rb
627
646
  - lib/datadog/tracing/contrib/registerable.rb
@@ -689,17 +708,18 @@ files:
689
708
  - lib/datadog/tracing/contrib/utils/quantization/hash.rb
690
709
  - lib/datadog/tracing/contrib/utils/quantization/http.rb
691
710
  - lib/datadog/tracing/correlation.rb
711
+ - lib/datadog/tracing/diagnostics/ext.rb
712
+ - lib/datadog/tracing/diagnostics/health.rb
713
+ - lib/datadog/tracing/distributed/b3_multi.rb
714
+ - lib/datadog/tracing/distributed/b3_single.rb
715
+ - lib/datadog/tracing/distributed/datadog.rb
692
716
  - lib/datadog/tracing/distributed/datadog_tags_codec.rb
693
- - lib/datadog/tracing/distributed/headers/b3.rb
694
- - lib/datadog/tracing/distributed/headers/b3_single.rb
695
- - lib/datadog/tracing/distributed/headers/datadog.rb
717
+ - lib/datadog/tracing/distributed/fetcher.rb
696
718
  - lib/datadog/tracing/distributed/headers/ext.rb
697
- - lib/datadog/tracing/distributed/headers/parser.rb
698
719
  - lib/datadog/tracing/distributed/helpers.rb
699
- - lib/datadog/tracing/distributed/metadata/b3.rb
700
- - lib/datadog/tracing/distributed/metadata/b3_single.rb
701
- - lib/datadog/tracing/distributed/metadata/datadog.rb
702
- - lib/datadog/tracing/distributed/metadata/parser.rb
720
+ - lib/datadog/tracing/distributed/none.rb
721
+ - lib/datadog/tracing/distributed/propagation.rb
722
+ - lib/datadog/tracing/distributed/trace_context.rb
703
723
  - lib/datadog/tracing/event.rb
704
724
  - lib/datadog/tracing/flush.rb
705
725
  - lib/datadog/tracing/metadata.rb
@@ -710,7 +730,6 @@ files:
710
730
  - lib/datadog/tracing/pipeline.rb
711
731
  - lib/datadog/tracing/pipeline/span_filter.rb
712
732
  - lib/datadog/tracing/pipeline/span_processor.rb
713
- - lib/datadog/tracing/propagation/grpc.rb
714
733
  - lib/datadog/tracing/propagation/http.rb
715
734
  - lib/datadog/tracing/runtime/metrics.rb
716
735
  - lib/datadog/tracing/sampling/all_sampler.rb
@@ -736,6 +755,7 @@ files:
736
755
  - lib/datadog/tracing/trace_operation.rb
737
756
  - lib/datadog/tracing/trace_segment.rb
738
757
  - lib/datadog/tracing/tracer.rb
758
+ - lib/datadog/tracing/utils.rb
739
759
  - lib/datadog/tracing/workers.rb
740
760
  - lib/datadog/tracing/workers/trace_writer.rb
741
761
  - lib/datadog/tracing/writer.rb
@@ -796,7 +816,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
796
816
  - !ruby/object:Gem::Version
797
817
  version: 2.0.0
798
818
  requirements: []
799
- rubygems_version: 3.3.7
819
+ rubygems_version: 3.3.26
800
820
  signing_key:
801
821
  specification_version: 4
802
822
  summary: Datadog tracing code for your Ruby applications
@@ -1,55 +0,0 @@
1
- # typed: true
2
-
3
- require_relative 'parser'
4
- require_relative '../helpers'
5
- require_relative 'ext'
6
- require_relative '../../trace_digest'
7
-
8
- module Datadog
9
- module Tracing
10
- module Distributed
11
- module Headers
12
- # B3 provides helpers to inject or extract headers for B3 style headers
13
- module B3
14
- include Ext
15
-
16
- def self.inject!(digest, env)
17
- return if digest.nil?
18
-
19
- # DEV: We need these to be hex encoded
20
- env[B3_HEADER_TRACE_ID] = digest.trace_id.to_s(16)
21
- env[B3_HEADER_SPAN_ID] = digest.span_id.to_s(16)
22
-
23
- if digest.trace_sampling_priority
24
- sampling_priority = Helpers.clamp_sampling_priority(
25
- digest.trace_sampling_priority
26
- )
27
- env[B3_HEADER_SAMPLED] = sampling_priority.to_s
28
- end
29
-
30
- env
31
- end
32
-
33
- def self.extract(env)
34
- # Extract values from headers
35
- # DEV: B3 doesn't have "origin"
36
- headers = Parser.new(env)
37
- trace_id = headers.id(B3_HEADER_TRACE_ID, 16)
38
- span_id = headers.id(B3_HEADER_SPAN_ID, 16)
39
- # We don't need to try and convert sampled since B3 supports 0/1 (AUTO_REJECT/AUTO_KEEP)
40
- sampling_priority = headers.number(B3_HEADER_SAMPLED)
41
-
42
- # Return early if this propagation is not valid
43
- return unless trace_id && span_id
44
-
45
- TraceDigest.new(
46
- trace_id: trace_id,
47
- span_id: span_id,
48
- trace_sampling_priority: sampling_priority
49
- )
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,67 +0,0 @@
1
- # typed: true
2
-
3
- require_relative 'parser'
4
- require_relative '../helpers'
5
- require_relative 'ext'
6
- require_relative '../../trace_digest'
7
-
8
- module Datadog
9
- module Tracing
10
- module Distributed
11
- module Headers
12
- # B3Single provides helpers to inject or extract headers for B3 single header style headers
13
- module B3Single
14
- include Ext
15
-
16
- def self.inject!(digest, env)
17
- return if digest.nil?
18
-
19
- # Header format:
20
- # b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
21
- # https://github.com/apache/incubator-zipkin-b3-propagation/tree/7c6e9f14d6627832bd80baa87ac7dabee7be23cf#single-header
22
- # DEV: `{SamplingState}` and `{ParentSpanId`}` are optional
23
-
24
- # DEV: We need these to be hex encoded
25
- header = "#{digest.trace_id.to_s(16)}-#{digest.span_id.to_s(16)}"
26
-
27
- if digest.trace_sampling_priority
28
- sampling_priority = Helpers.clamp_sampling_priority(
29
- digest.trace_sampling_priority
30
- )
31
- header += "-#{sampling_priority}"
32
- end
33
-
34
- env[B3_HEADER_SINGLE] = header
35
-
36
- env
37
- end
38
-
39
- def self.extract(env)
40
- # Header format:
41
- # b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
42
- # https://github.com/apache/incubator-zipkin-b3-propagation/tree/7c6e9f14d6627832bd80baa87ac7dabee7be23cf#single-header
43
- # DEV: `{SamplingState}` and `{ParentSpanId`}` are optional
44
-
45
- headers = Parser.new(env)
46
- value = headers.header(B3_HEADER_SINGLE)
47
- return if value.nil?
48
-
49
- parts = value.split('-')
50
- trace_id = Helpers.value_to_id(parts[0], 16) unless parts.empty?
51
- span_id = Helpers.value_to_id(parts[1], 16) if parts.length > 1
52
- sampling_priority = Helpers.value_to_number(parts[2]) if parts.length > 2
53
-
54
- # Return early if this propagation is not valid
55
- return unless trace_id && span_id
56
-
57
- TraceDigest.new(
58
- span_id: span_id,
59
- trace_id: trace_id,
60
- trace_sampling_priority: sampling_priority
61
- )
62
- end
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,144 +0,0 @@
1
- # frozen_string_literal: true
2
- # typed: true
3
-
4
- require_relative 'parser'
5
- require_relative 'ext'
6
- require_relative '../../metadata/ext'
7
- require_relative '../../trace_digest'
8
- require_relative '../datadog_tags_codec'
9
-
10
- module Datadog
11
- module Tracing
12
- module Distributed
13
- module Headers
14
- # Datadog provides helpers to inject or extract headers for Datadog style headers
15
- module Datadog
16
- class << self
17
- include Ext
18
-
19
- def inject!(digest, env)
20
- return if digest.nil?
21
-
22
- env[HTTP_HEADER_TRACE_ID] = digest.trace_id.to_s
23
- env[HTTP_HEADER_PARENT_ID] = digest.span_id.to_s
24
- env[HTTP_HEADER_SAMPLING_PRIORITY] = digest.trace_sampling_priority.to_s if digest.trace_sampling_priority
25
- env[HTTP_HEADER_ORIGIN] = digest.trace_origin.to_s unless digest.trace_origin.nil?
26
-
27
- inject_tags(digest, env)
28
-
29
- env
30
- end
31
-
32
- def extract(env)
33
- # Extract values from headers
34
- headers = Parser.new(env)
35
- trace_id = headers.id(HTTP_HEADER_TRACE_ID)
36
- parent_id = headers.id(HTTP_HEADER_PARENT_ID)
37
- origin = headers.header(HTTP_HEADER_ORIGIN)
38
- sampling_priority = headers.number(HTTP_HEADER_SAMPLING_PRIORITY)
39
-
40
- # Return early if this propagation is not valid
41
- # DEV: To be valid we need to have a trace id and a parent id
42
- # or when it is a synthetics trace, just the trace id.
43
- # DEV: `Parser#id` will not return 0
44
- return unless (trace_id && parent_id) || (origin && trace_id)
45
-
46
- trace_distributed_tags = extract_tags(headers)
47
-
48
- # Return new trace headers
49
- TraceDigest.new(
50
- span_id: parent_id,
51
- trace_id: trace_id,
52
- trace_origin: origin,
53
- trace_sampling_priority: sampling_priority,
54
- trace_distributed_tags: trace_distributed_tags,
55
- )
56
- end
57
-
58
- private
59
-
60
- # Export trace distributed tags through the `x-datadog-tags` header.
61
- #
62
- # DEV: This method accesses global state (the active trace) to record its error state as a trace tag.
63
- # DEV: This means errors cannot be reported if there's not active span.
64
- # DEV: Ideally, we'd have a dedicated error reporting stream for all of ddtrace.
65
- # DEV: The same comment applies to the {.extract_tags}.
66
- def inject_tags(digest, env)
67
- return if digest.trace_distributed_tags.nil? || digest.trace_distributed_tags.empty?
68
-
69
- if ::Datadog.configuration.tracing.x_datadog_tags_max_length <= 0
70
- active_trace = Tracing.active_trace
71
- active_trace.set_tag('_dd.propagation_error', 'disabled') if active_trace
72
- return
73
- end
74
-
75
- encoded_tags = DatadogTagsCodec.encode(digest.trace_distributed_tags)
76
-
77
- if encoded_tags.size > ::Datadog.configuration.tracing.x_datadog_tags_max_length
78
- active_trace = Tracing.active_trace
79
- active_trace.set_tag('_dd.propagation_error', 'inject_max_size') if active_trace
80
-
81
- ::Datadog.logger.warn(
82
- "Failed to inject x-datadog-tags: tags are too large (size:#{encoded_tags.size} " \
83
- "limit:#{::Datadog.configuration.tracing.x_datadog_tags_max_length}). This limit can be configured " \
84
- 'through the DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH environment variable.'
85
- )
86
- return
87
- end
88
-
89
- env[HTTP_HEADER_TAGS] = encoded_tags
90
- rescue => e
91
- active_trace = Tracing.active_trace
92
- active_trace.set_tag('_dd.propagation_error', 'encoding_error') if active_trace
93
- ::Datadog.logger.warn(
94
- "Failed to inject x-datadog-tags: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
95
- )
96
- end
97
-
98
- # Import `x-datadog-tags` header tags as trace distributed tags.
99
- # Only tags that have the `_dd.p.` prefix are processed.
100
- def extract_tags(headers)
101
- tags_header = headers.header(HTTP_HEADER_TAGS)
102
- return unless tags_header
103
-
104
- if ::Datadog.configuration.tracing.x_datadog_tags_max_length <= 0
105
- active_trace = Tracing.active_trace
106
- active_trace.set_tag('_dd.propagation_error', 'disabled') if active_trace
107
- return
108
- end
109
-
110
- if tags_header.size > ::Datadog.configuration.tracing.x_datadog_tags_max_length
111
- active_trace = Tracing.active_trace
112
- active_trace.set_tag('_dd.propagation_error', 'extract_max_size') if active_trace
113
-
114
- ::Datadog.logger.warn(
115
- "Failed to extract x-datadog-tags: tags are too large (size:#{tags_header.size} " \
116
- "limit:#{::Datadog.configuration.tracing.x_datadog_tags_max_length}). This limit can be configured " \
117
- 'through the DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH environment variable.'
118
- )
119
- return
120
- end
121
-
122
- tags = DatadogTagsCodec.decode(tags_header)
123
- # Only extract keys with the expected Datadog prefix
124
- tags.select! do |key, _|
125
- key.start_with?(Tracing::Metadata::Ext::Distributed::TAGS_PREFIX) && key != EXCLUDED_TAG
126
- end
127
- tags
128
- rescue => e
129
- active_trace = Tracing.active_trace
130
- active_trace.set_tag('_dd.propagation_error', 'decoding_error') if active_trace
131
- ::Datadog.logger.warn(
132
- "Failed to extract x-datadog-tags: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
133
- )
134
- end
135
-
136
- # We want to exclude tags that we don't want to propagate downstream.
137
- EXCLUDED_TAG = '_dd.p.upstream_services'
138
- private_constant :EXCLUDED_TAG
139
- end
140
- end
141
- end
142
- end
143
- end
144
- end