ddtrace 0.40.0 → 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +148 -130
  3. data/.circleci/images/primary/Dockerfile-3.0.0 +73 -0
  4. data/.github/workflows/add-milestone-to-pull-requests.yml +42 -0
  5. data/.github/workflows/create-next-milestone.yml +20 -0
  6. data/.simplecov +3 -0
  7. data/Appraisals +414 -135
  8. data/CHANGELOG.md +1112 -342
  9. data/CONTRIBUTING.md +2 -2
  10. data/Gemfile +4 -2
  11. data/README.md +1 -0
  12. data/Rakefile +231 -29
  13. data/ddtrace.gemspec +8 -8
  14. data/docker-compose.yml +30 -0
  15. data/docs/DevelopmentGuide.md +12 -2
  16. data/docs/GettingStarted.md +187 -16
  17. data/lib/ddtrace.rb +10 -0
  18. data/lib/ddtrace/auto_instrument.rb +3 -0
  19. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  20. data/lib/ddtrace/buffer.rb +259 -52
  21. data/lib/ddtrace/configuration.rb +19 -0
  22. data/lib/ddtrace/configuration/options.rb +3 -1
  23. data/lib/ddtrace/configuration/settings.rb +9 -3
  24. data/lib/ddtrace/context.rb +18 -0
  25. data/lib/ddtrace/context_provider.rb +17 -5
  26. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  27. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  28. data/lib/ddtrace/contrib/action_view/event.rb +0 -4
  29. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  30. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  31. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  32. data/lib/ddtrace/contrib/active_record/events/sql.rb +4 -0
  33. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  34. data/lib/ddtrace/contrib/active_record/utils.rb +67 -21
  35. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +104 -3
  36. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +21 -0
  37. data/lib/ddtrace/contrib/active_support/ext.rb +3 -0
  38. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  39. data/lib/ddtrace/contrib/active_support/notifications/event.rb +10 -0
  40. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -2
  41. data/lib/ddtrace/contrib/auto_instrument.rb +48 -0
  42. data/lib/ddtrace/contrib/aws/instrumentation.rb +6 -1
  43. data/lib/ddtrace/contrib/aws/patcher.rb +0 -1
  44. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  45. data/lib/ddtrace/contrib/configurable.rb +2 -0
  46. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +6 -5
  47. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +38 -0
  48. data/lib/ddtrace/contrib/cucumber/ext.rb +19 -0
  49. data/lib/ddtrace/contrib/cucumber/formatter.rb +104 -0
  50. data/lib/ddtrace/contrib/cucumber/instrumentation.rb +24 -0
  51. data/lib/ddtrace/contrib/cucumber/integration.rb +45 -0
  52. data/lib/ddtrace/contrib/cucumber/patcher.rb +23 -0
  53. data/lib/ddtrace/contrib/dalli/instrumentation.rb +4 -0
  54. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
  55. data/lib/ddtrace/contrib/delayed_job/ext.rb +2 -0
  56. data/lib/ddtrace/contrib/delayed_job/plugin.rb +39 -15
  57. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +4 -0
  58. data/lib/ddtrace/contrib/ethon/easy_patch.rb +10 -7
  59. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  60. data/lib/ddtrace/contrib/ethon/multi_patch.rb +4 -0
  61. data/lib/ddtrace/contrib/excon/middleware.rb +11 -1
  62. data/lib/ddtrace/contrib/extensions.rb +27 -1
  63. data/lib/ddtrace/contrib/faraday/middleware.rb +4 -0
  64. data/lib/ddtrace/contrib/faraday/patcher.rb +1 -1
  65. data/lib/ddtrace/contrib/grape/configuration/settings.rb +7 -0
  66. data/lib/ddtrace/contrib/grape/endpoint.rb +53 -18
  67. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  68. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +5 -1
  69. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -0
  70. data/lib/ddtrace/contrib/http/instrumentation.rb +6 -2
  71. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  72. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  73. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +152 -0
  74. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  75. data/lib/ddtrace/contrib/httpclient/patcher.rb +35 -0
  76. data/lib/ddtrace/contrib/httprb/instrumentation.rb +6 -3
  77. data/lib/ddtrace/contrib/kafka/event.rb +1 -1
  78. data/lib/ddtrace/contrib/mongodb/subscribers.rb +4 -0
  79. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +4 -0
  80. data/lib/ddtrace/contrib/patchable.rb +18 -7
  81. data/lib/ddtrace/contrib/presto/instrumentation.rb +3 -0
  82. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  83. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  84. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  85. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  86. data/lib/ddtrace/contrib/qless/qless_job.rb +72 -0
  87. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +32 -0
  88. data/lib/ddtrace/contrib/que/configuration/settings.rb +1 -0
  89. data/lib/ddtrace/contrib/que/tracer.rb +2 -1
  90. data/lib/ddtrace/contrib/racecar/event.rb +4 -0
  91. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  92. data/lib/ddtrace/contrib/rack/middlewares.rb +1 -1
  93. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  94. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  95. data/lib/ddtrace/contrib/rails/patcher.rb +19 -5
  96. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  97. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  98. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
  99. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  100. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  101. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  102. data/lib/ddtrace/contrib/redis/quantize.rb +27 -0
  103. data/lib/ddtrace/contrib/redis/tags.rb +9 -1
  104. data/lib/ddtrace/contrib/resque/configuration/settings.rb +1 -0
  105. data/lib/ddtrace/contrib/resque/integration.rb +1 -1
  106. data/lib/ddtrace/contrib/resque/resque_job.rb +1 -1
  107. data/lib/ddtrace/contrib/rest_client/request_patch.rb +4 -0
  108. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +38 -0
  109. data/lib/ddtrace/contrib/rspec/example.rb +61 -0
  110. data/lib/ddtrace/contrib/rspec/example_group.rb +61 -0
  111. data/lib/ddtrace/contrib/rspec/ext.rb +19 -0
  112. data/lib/ddtrace/contrib/rspec/integration.rb +46 -0
  113. data/lib/ddtrace/contrib/rspec/patcher.rb +25 -0
  114. data/lib/ddtrace/contrib/sequel/database.rb +3 -1
  115. data/lib/ddtrace/contrib/sequel/dataset.rb +3 -2
  116. data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
  117. data/lib/ddtrace/contrib/sequel/utils.rb +16 -5
  118. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
  119. data/lib/ddtrace/contrib/shoryuken/tracer.rb +4 -1
  120. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +1 -0
  121. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +4 -1
  122. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +2 -2
  123. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +1 -0
  124. data/lib/ddtrace/contrib/sneakers/tracer.rb +17 -20
  125. data/lib/ddtrace/contrib/status_code_matcher.rb +67 -0
  126. data/lib/ddtrace/ext/app_types.rb +1 -0
  127. data/lib/ddtrace/ext/ci.rb +297 -0
  128. data/lib/ddtrace/ext/distributed.rb +8 -2
  129. data/lib/ddtrace/ext/git.rb +11 -0
  130. data/lib/ddtrace/ext/integration.rb +8 -0
  131. data/lib/ddtrace/ext/runtime.rb +2 -0
  132. data/lib/ddtrace/ext/test.rb +24 -0
  133. data/lib/ddtrace/opentracer/distributed_headers.rb +1 -1
  134. data/lib/ddtrace/propagation/grpc_propagator.rb +18 -6
  135. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  136. data/lib/ddtrace/runtime/identity.rb +4 -5
  137. data/lib/ddtrace/runtime/metrics.rb +6 -2
  138. data/lib/ddtrace/sampler.rb +2 -2
  139. data/lib/ddtrace/sampling/rate_limiter.rb +65 -16
  140. data/lib/ddtrace/span.rb +152 -27
  141. data/lib/ddtrace/tracer.rb +25 -13
  142. data/lib/ddtrace/transport/http/adapters/net.rb +8 -2
  143. data/lib/ddtrace/transport/http/statistics.rb +14 -1
  144. data/lib/ddtrace/transport/traces.rb +7 -2
  145. data/lib/ddtrace/utils.rb +16 -13
  146. data/lib/ddtrace/utils/forking.rb +52 -0
  147. data/lib/ddtrace/version.rb +1 -1
  148. data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
  149. data/lib/ddtrace/writer.rb +19 -1
  150. metadata +111 -19
@@ -1,4 +1,3 @@
1
- require 'pp'
2
1
  require 'thread'
3
2
  require 'logger'
4
3
  require 'pathname'
@@ -8,6 +7,7 @@ require 'ddtrace/span'
8
7
  require 'ddtrace/context'
9
8
  require 'ddtrace/logger'
10
9
  require 'ddtrace/writer'
10
+ require 'ddtrace/runtime/identity'
11
11
  require 'ddtrace/sampler'
12
12
  require 'ddtrace/sampling'
13
13
  require 'ddtrace/correlation'
@@ -60,8 +60,8 @@ module Datadog
60
60
  #
61
61
  # This method makes use of a \ContextProvider that is automatically set during the tracer
62
62
  # initialization, or while using a library instrumentation.
63
- def call_context
64
- @provider.context
63
+ def call_context(key = nil)
64
+ @provider.context(key)
65
65
  end
66
66
 
67
67
  # Initialize a new \Tracer used to create, sample and submit spans that measure the
@@ -186,8 +186,7 @@ module Datadog
186
186
  # * +start_time+: when the span actually starts (defaults to \now)
187
187
  # * +tags+: extra tags which should be added to the span.
188
188
  def start_span(name, options = {})
189
- start_time = options.fetch(:start_time, Time.now.utc)
190
-
189
+ start_time = options[:start_time]
191
190
  tags = options.fetch(:tags, {})
192
191
 
193
192
  span_options = options.select do |k, _v|
@@ -203,6 +202,7 @@ module Datadog
203
202
  # root span
204
203
  @sampler.sample!(span)
205
204
  span.set_tag('system.pid', Process.pid)
205
+ span.set_tag(Datadog::Ext::Runtime::TAG_ID, Datadog::Runtime::Identity.id)
206
206
 
207
207
  if ctx && ctx.trace_id
208
208
  span.trace_id = ctx.trace_id
@@ -212,9 +212,10 @@ module Datadog
212
212
  # child span
213
213
  span.parent = parent # sets service, trace_id, parent_id, sampled
214
214
  end
215
+
215
216
  span.set_tags(@tags) unless @tags.empty?
216
217
  span.set_tags(tags) unless tags.empty?
217
- span.start_time = start_time
218
+ span.start(start_time)
218
219
 
219
220
  # this could at some point be optional (start_active_span vs start_manual_span)
220
221
  ctx.add_span(span) unless ctx.nil?
@@ -288,8 +289,19 @@ module Datadog
288
289
  # and it is user code which should be executed no matter what.
289
290
  # It's not a problem since we re-raise it afterwards so for example a
290
291
  # SignalException::Interrupt would still bubble up.
292
+ # rubocop:disable Metrics/BlockNesting
291
293
  rescue Exception => e
292
- (options[:on_error] || DEFAULT_ON_ERROR).call(span, e)
294
+ if (on_error_handler = options[:on_error]) && on_error_handler.respond_to?(:call)
295
+ begin
296
+ on_error_handler.call(span, e)
297
+ rescue
298
+ Datadog.logger.debug('Custom on_error handler failed, falling back to default')
299
+ DEFAULT_ON_ERROR.call(span, e)
300
+ end
301
+ else
302
+ Datadog.logger.debug('Custom on_error handler must be a callable, falling back to default') if on_error_handler
303
+ DEFAULT_ON_ERROR.call(span, e)
304
+ end
293
305
  raise e
294
306
  ensure
295
307
  span.finish unless span.nil?
@@ -325,18 +337,18 @@ module Datadog
325
337
  end
326
338
 
327
339
  # Return the current active span or +nil+.
328
- def active_span
329
- call_context.current_span
340
+ def active_span(key = nil)
341
+ call_context(key).current_span
330
342
  end
331
343
 
332
344
  # Return the current active root span or +nil+.
333
- def active_root_span
334
- call_context.current_root_span
345
+ def active_root_span(key = nil)
346
+ call_context(key).current_root_span
335
347
  end
336
348
 
337
349
  # Return a CorrelationIdentifier for active span
338
- def active_correlation
339
- Datadog::Correlation.identifier_from_context(call_context)
350
+ def active_correlation(key = nil)
351
+ Datadog::Correlation.identifier_from_context(call_context(key))
340
352
  end
341
353
 
342
354
  # Send the trace to the writer to enqueue the spans list in the agent
@@ -20,8 +20,14 @@ module Datadog
20
20
  end
21
21
 
22
22
  def open
23
- # Open connection
24
- ::Net::HTTP.start(hostname, port, open_timeout: timeout, read_timeout: timeout) do |http|
23
+ # DEV Initializing +Net::HTTP+ directly help us avoid expensive
24
+ # options processing done in +Net::HTTP.start+:
25
+ # https://github.com/ruby/ruby/blob/b2d96abb42abbe2e01f010ffc9ac51f0f9a50002/lib/net/http.rb#L614-L618
26
+ req = ::Net::HTTP.new(hostname, port, nil)
27
+
28
+ req.open_timeout = req.read_timeout = timeout
29
+
30
+ req.start do |http|
25
31
  yield(http)
26
32
  end
27
33
  end
@@ -18,11 +18,24 @@ module Datadog
18
18
  # Add status code tag to api.responses metric
19
19
  if metrics.key?(:api_responses)
20
20
  (metrics[:api_responses].options[:tags] ||= []).tap do |tags|
21
- tags << "status_code:#{response.code}"
21
+ tags << metrics_tag_value(response.code)
22
22
  end
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ private
28
+
29
+ # The most common status code on a healthy tracer
30
+ STATUS_CODE_200 = 'status_code:200'.freeze
31
+
32
+ def metrics_tag_value(status_code)
33
+ if status_code == 200
34
+ STATUS_CODE_200 # DEV Saves string concatenation/creation for common case
35
+ else
36
+ "status_code:#{status_code}"
37
+ end
38
+ end
26
39
  end
27
40
  end
28
41
  end
@@ -57,7 +57,12 @@ module Datadog
57
57
  # @return [Enumerable[Array[Bytes,Integer]]] list of encoded chunks: each containing a byte array and
58
58
  # number of traces
59
59
  def encode_in_chunks(traces)
60
- encoded_traces = traces.map { |t| encode_one(t) }.reject(&:nil?)
60
+ encoded_traces = if traces.respond_to?(:filter_map)
61
+ # DEV Supported since Ruby 2.7, saves an intermediate object creation
62
+ traces.filter_map { |t| encode_one(t) }
63
+ else
64
+ traces.map { |t| encode_one(t) }.reject(&:nil?)
65
+ end
61
66
 
62
67
  Datadog::Chunker.chunk_by_size(encoded_traces, max_size).map do |chunk|
63
68
  [encoder.join(chunk), chunk.size]
@@ -86,7 +91,7 @@ module Datadog
86
91
  module_function
87
92
 
88
93
  def encode_trace(encoder, trace)
89
- encoder.encode(trace.map(&:to_hash))
94
+ encoder.encode(trace)
90
95
  end
91
96
  end
92
97
 
@@ -1,32 +1,31 @@
1
1
  require 'ddtrace/utils/database'
2
+ require 'ddtrace/utils/forking'
2
3
 
3
4
  module Datadog
4
5
  # Utils contains low-level utilities, typically to provide pseudo-random trace IDs.
5
6
  module Utils
6
- STRING_PLACEHOLDER = ''.encode(::Encoding::UTF_8).freeze
7
+ extend Utils::Forking
8
+
9
+ EMPTY_STRING = ''.encode(::Encoding::UTF_8).freeze
7
10
  # We use a custom random number generator because we want no interference
8
11
  # with the default one. Using the default prng, we could break code that
9
12
  # would rely on srand/rand sequences.
10
13
 
11
14
  # Return a span id
12
15
  def self.next_id
13
- reset! if was_forked?
14
-
15
- @rnd.rand(Datadog::Span::MAX_ID)
16
+ after_fork! { reset! }
17
+ id_rng.rand(Datadog::Span::RUBY_MAX_ID)
16
18
  end
17
19
 
18
- def self.reset!
19
- @pid = Process.pid
20
- @rnd = Random.new
20
+ def self.id_rng
21
+ @id_rng ||= Random.new
21
22
  end
22
23
 
23
- def self.was_forked?
24
- Process.pid != @pid
24
+ def self.reset!
25
+ @id_rng = Random.new
25
26
  end
26
27
 
27
- private_class_method :reset!, :was_forked?
28
-
29
- reset!
28
+ private_class_method :id_rng, :reset!
30
29
 
31
30
  def self.truncate(value, size, omission = '...'.freeze)
32
31
  string = value.to_s
@@ -53,13 +52,17 @@ module Datadog
53
52
  str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
54
53
  elsif str.encoding == ::Encoding::UTF_8
55
54
  str
55
+ elsif str.empty?
56
+ # DEV Optimization as `nil.to_s` is a very common source for an empty string,
57
+ # DEV but it comes encoded as US_ASCII.
58
+ EMPTY_STRING
56
59
  else
57
60
  str.encode(::Encoding::UTF_8)
58
61
  end
59
62
  rescue => e
60
63
  Datadog.logger.debug("Error encoding string in UTF-8: #{e}")
61
64
 
62
- options.fetch(:placeholder, STRING_PLACEHOLDER)
65
+ options.fetch(:placeholder, EMPTY_STRING)
63
66
  end
64
67
  end
65
68
  end
@@ -0,0 +1,52 @@
1
+ module Datadog
2
+ module Utils
3
+ # Helper methods for managing forking behavior
4
+ module Forking
5
+ def self.included(base)
6
+ base.send(:prepend, ClassExtensions) if base.is_a?(Class)
7
+ end
8
+
9
+ def self.extended(base)
10
+ # Explicitly update PID here because there's a case where
11
+ # the code path that lazily updates the PID may not be exercised
12
+ # until after a fork occurs, thus causing the event to be missed.
13
+ # By eagerly setting this, we avoid this scenario.
14
+ base.update_fork_pid!
15
+ end
16
+
17
+ def after_fork!
18
+ if forked?
19
+ yield
20
+ update_fork_pid!
21
+ true
22
+ else
23
+ false
24
+ end
25
+ end
26
+
27
+ def forked?
28
+ Process.pid != fork_pid
29
+ end
30
+
31
+ def update_fork_pid!
32
+ @fork_pid = Process.pid
33
+ end
34
+
35
+ def fork_pid
36
+ @fork_pid ||= Process.pid
37
+ end
38
+
39
+ # Adds additional functionality for Classes that implement Forking
40
+ module ClassExtensions
41
+ # Addresses an edge case where forking before invoking #update_fork_pid! on the
42
+ # object will cause forking to not be detected in the fork when it should have.
43
+ #
44
+ # This wrapper prevents this by initializing the fork PID when the object is created.
45
+ def initialize(*args, &block)
46
+ super
47
+ update_fork_pid!
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,7 +1,7 @@
1
1
  module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 40
4
+ MINOR = 45
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
@@ -12,6 +12,10 @@ module Datadog
12
12
  extend Forwardable
13
13
  include Workers::Polling
14
14
 
15
+ # In seconds
16
+ DEFAULT_FLUSH_INTERVAL = 10
17
+ DEFAULT_BACK_OFF_MAX = 30
18
+
15
19
  attr_reader \
16
20
  :metrics
17
21
 
@@ -22,9 +26,9 @@ module Datadog
22
26
  self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)
23
27
 
24
28
  # Workers::IntervalLoop settings
25
- self.interval = options[:interval] if options.key?(:interval)
26
- self.back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio)
27
- self.back_off_max = options[:back_off_max] if options.key?(:back_off_max)
29
+ self.loop_base_interval = options.fetch(:interval, DEFAULT_FLUSH_INTERVAL)
30
+ self.loop_back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio)
31
+ self.loop_back_off_max = options.fetch(:back_off_max, DEFAULT_BACK_OFF_MAX)
28
32
 
29
33
  self.enabled = options.fetch(:enabled, false)
30
34
  end
@@ -42,13 +42,22 @@ module Datadog
42
42
 
43
43
  # one worker for traces
44
44
  @worker = nil
45
+
46
+ # Once stopped, this writer instance cannot be restarted.
47
+ # This allow for graceful shutdown, while preventing
48
+ # the host application from inadvertently start new
49
+ # threads during shutdown.
50
+ @stopped = false
45
51
  end
46
52
 
47
53
  def start
48
54
  @mutex_after_fork.synchronize do
55
+ return false if @stopped
56
+
49
57
  pid = Process.pid
50
58
  return if @worker && pid == @pid
51
59
  @pid = pid
60
+
52
61
  start_worker
53
62
  true
54
63
  end
@@ -67,14 +76,23 @@ module Datadog
67
76
  @worker.start
68
77
  end
69
78
 
79
+ # Gracefully shuts down this writer.
80
+ #
81
+ # Once stopped methods calls won't fail, but
82
+ # no internal work will be performed.
83
+ #
84
+ # It is not possible to restart a stopped writer instance.
70
85
  def stop
71
86
  @mutex_after_fork.synchronize { stop_worker }
72
87
  end
73
88
 
74
89
  def stop_worker
90
+ @stopped = true
91
+
75
92
  return if @worker.nil?
76
93
  @worker.stop
77
94
  @worker = nil
95
+
78
96
  true
79
97
  end
80
98
 
@@ -136,7 +154,7 @@ module Datadog
136
154
 
137
155
  if worker_local
138
156
  worker_local.enqueue_trace(trace)
139
- else
157
+ elsif !@stopped
140
158
  Datadog.logger.debug('Writer either failed to start or was stopped before #write could complete')
141
159
  end
142
160
  end
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: 0.40.0
4
+ version: 0.45.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-08 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.4.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: concurrent-ruby
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '1.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ruby-prof
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.4'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: minitest
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +178,20 @@ dependencies:
150
178
  - - '='
151
179
  - !ruby/object:Gem::Version
152
180
  version: 1.0.2
181
+ - !ruby/object:Gem::Dependency
182
+ name: pimpmychangelog
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.1.2
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.1.2
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: appraisal
155
197
  requirement: !ruby/object:Gem::Requirement
@@ -182,16 +224,16 @@ dependencies:
182
224
  name: webmock
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
- - - "~>"
227
+ - - ">="
186
228
  - !ruby/object:Gem::Version
187
- version: '2.0'
229
+ version: 3.10.0
188
230
  type: :development
189
231
  prerelease: false
190
232
  version_requirements: !ruby/object:Gem::Requirement
191
233
  requirements:
192
- - - "~>"
234
+ - - ">="
193
235
  - !ruby/object:Gem::Version
194
- version: '2.0'
236
+ version: 3.10.0
195
237
  - !ruby/object:Gem::Dependency
196
238
  name: builder
197
239
  requirement: !ruby/object:Gem::Requirement
@@ -207,33 +249,33 @@ dependencies:
207
249
  - !ruby/object:Gem::Version
208
250
  version: '0'
209
251
  - !ruby/object:Gem::Dependency
210
- name: sqlite3
252
+ name: climate_control
211
253
  requirement: !ruby/object:Gem::Requirement
212
254
  requirements:
213
255
  - - "~>"
214
256
  - !ruby/object:Gem::Version
215
- version: 1.3.6
257
+ version: 0.2.0
216
258
  type: :development
217
259
  prerelease: false
218
260
  version_requirements: !ruby/object:Gem::Requirement
219
261
  requirements:
220
262
  - - "~>"
221
263
  - !ruby/object:Gem::Version
222
- version: 1.3.6
264
+ version: 0.2.0
223
265
  - !ruby/object:Gem::Dependency
224
- name: climate_control
266
+ name: rspec_junit_formatter
225
267
  requirement: !ruby/object:Gem::Requirement
226
268
  requirements:
227
- - - "~>"
269
+ - - ">="
228
270
  - !ruby/object:Gem::Version
229
- version: 0.2.0
271
+ version: 0.4.1
230
272
  type: :development
231
273
  prerelease: false
232
274
  version_requirements: !ruby/object:Gem::Requirement
233
275
  requirements:
234
- - - "~>"
276
+ - - ">="
235
277
  - !ruby/object:Gem::Version
236
- version: 0.2.0
278
+ version: 0.4.1
237
279
  - !ruby/object:Gem::Dependency
238
280
  name: addressable
239
281
  requirement: !ruby/object:Gem::Requirement
@@ -310,28 +352,42 @@ dependencies:
310
352
  requirements:
311
353
  - - "~>"
312
354
  - !ruby/object:Gem::Version
313
- version: 0.10.4
355
+ version: 0.12.2
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: 0.12.2
363
+ - !ruby/object:Gem::Dependency
364
+ name: pry-nav
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - "~>"
368
+ - !ruby/object:Gem::Version
369
+ version: 0.3.0
314
370
  type: :development
315
371
  prerelease: false
316
372
  version_requirements: !ruby/object:Gem::Requirement
317
373
  requirements:
318
374
  - - "~>"
319
375
  - !ruby/object:Gem::Version
320
- version: 0.10.4
376
+ version: 0.3.0
321
377
  - !ruby/object:Gem::Dependency
322
378
  name: pry-stack_explorer
323
379
  requirement: !ruby/object:Gem::Requirement
324
380
  requirements:
325
381
  - - "~>"
326
382
  - !ruby/object:Gem::Version
327
- version: 0.4.9.2
383
+ version: 0.4.9
328
384
  type: :development
329
385
  prerelease: false
330
386
  version_requirements: !ruby/object:Gem::Requirement
331
387
  requirements:
332
388
  - - "~>"
333
389
  - !ruby/object:Gem::Version
334
- version: 0.4.9.2
390
+ version: 0.4.9
335
391
  - !ruby/object:Gem::Dependency
336
392
  name: simplecov
337
393
  requirement: !ruby/object:Gem::Requirement
@@ -379,10 +435,13 @@ files:
379
435
  - ".circleci/images/primary/Dockerfile-2.5.6"
380
436
  - ".circleci/images/primary/Dockerfile-2.6.4"
381
437
  - ".circleci/images/primary/Dockerfile-2.7.0"
438
+ - ".circleci/images/primary/Dockerfile-3.0.0"
382
439
  - ".circleci/images/primary/Dockerfile-jruby-9.2"
383
440
  - ".dockerignore"
384
441
  - ".env"
385
442
  - ".github/CODEOWNERS"
443
+ - ".github/workflows/add-milestone-to-pull-requests.yml"
444
+ - ".github/workflows/create-next-milestone.yml"
386
445
  - ".gitignore"
387
446
  - ".gitlab-ci.yml"
388
447
  - ".rspec"
@@ -411,6 +470,8 @@ files:
411
470
  - lib/ddtrace/augmentation/method_wrapper.rb
412
471
  - lib/ddtrace/augmentation/method_wrapping.rb
413
472
  - lib/ddtrace/augmentation/shim.rb
473
+ - lib/ddtrace/auto_instrument.rb
474
+ - lib/ddtrace/auto_instrument_base.rb
414
475
  - lib/ddtrace/buffer.rb
415
476
  - lib/ddtrace/chunker.rb
416
477
  - lib/ddtrace/configuration.rb
@@ -484,6 +545,7 @@ files:
484
545
  - lib/ddtrace/contrib/active_support/notifications/subscription.rb
485
546
  - lib/ddtrace/contrib/active_support/patcher.rb
486
547
  - lib/ddtrace/contrib/analytics.rb
548
+ - lib/ddtrace/contrib/auto_instrument.rb
487
549
  - lib/ddtrace/contrib/aws/configuration/settings.rb
488
550
  - lib/ddtrace/contrib/aws/ext.rb
489
551
  - lib/ddtrace/contrib/aws/instrumentation.rb
@@ -501,6 +563,12 @@ files:
501
563
  - lib/ddtrace/contrib/configuration/resolver.rb
502
564
  - lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb
503
565
  - lib/ddtrace/contrib/configuration/settings.rb
566
+ - lib/ddtrace/contrib/cucumber/configuration/settings.rb
567
+ - lib/ddtrace/contrib/cucumber/ext.rb
568
+ - lib/ddtrace/contrib/cucumber/formatter.rb
569
+ - lib/ddtrace/contrib/cucumber/instrumentation.rb
570
+ - lib/ddtrace/contrib/cucumber/integration.rb
571
+ - lib/ddtrace/contrib/cucumber/patcher.rb
504
572
  - lib/ddtrace/contrib/dalli/configuration/settings.rb
505
573
  - lib/ddtrace/contrib/dalli/ext.rb
506
574
  - lib/ddtrace/contrib/dalli/instrumentation.rb
@@ -561,6 +629,11 @@ files:
561
629
  - lib/ddtrace/contrib/http/integration.rb
562
630
  - lib/ddtrace/contrib/http/patcher.rb
563
631
  - lib/ddtrace/contrib/http_annotation_helper.rb
632
+ - lib/ddtrace/contrib/httpclient/configuration/settings.rb
633
+ - lib/ddtrace/contrib/httpclient/ext.rb
634
+ - lib/ddtrace/contrib/httpclient/instrumentation.rb
635
+ - lib/ddtrace/contrib/httpclient/integration.rb
636
+ - lib/ddtrace/contrib/httpclient/patcher.rb
564
637
  - lib/ddtrace/contrib/httprb/configuration/settings.rb
565
638
  - lib/ddtrace/contrib/httprb/ext.rb
566
639
  - lib/ddtrace/contrib/httprb/instrumentation.rb
@@ -603,6 +676,12 @@ files:
603
676
  - lib/ddtrace/contrib/presto/instrumentation.rb
604
677
  - lib/ddtrace/contrib/presto/integration.rb
605
678
  - lib/ddtrace/contrib/presto/patcher.rb
679
+ - lib/ddtrace/contrib/qless/configuration/settings.rb
680
+ - lib/ddtrace/contrib/qless/ext.rb
681
+ - lib/ddtrace/contrib/qless/integration.rb
682
+ - lib/ddtrace/contrib/qless/patcher.rb
683
+ - lib/ddtrace/contrib/qless/qless_job.rb
684
+ - lib/ddtrace/contrib/qless/tracer_cleaner.rb
606
685
  - lib/ddtrace/contrib/que/configuration/settings.rb
607
686
  - lib/ddtrace/contrib/que/ext.rb
608
687
  - lib/ddtrace/contrib/que/integration.rb
@@ -623,6 +702,7 @@ files:
623
702
  - lib/ddtrace/contrib/rack/middlewares.rb
624
703
  - lib/ddtrace/contrib/rack/patcher.rb
625
704
  - lib/ddtrace/contrib/rack/request_queue.rb
705
+ - lib/ddtrace/contrib/rails/auto_instrument_railtie.rb
626
706
  - lib/ddtrace/contrib/rails/configuration/settings.rb
627
707
  - lib/ddtrace/contrib/rails/ext.rb
628
708
  - lib/ddtrace/contrib/rails/framework.rb
@@ -657,6 +737,12 @@ files:
657
737
  - lib/ddtrace/contrib/rest_client/integration.rb
658
738
  - lib/ddtrace/contrib/rest_client/patcher.rb
659
739
  - lib/ddtrace/contrib/rest_client/request_patch.rb
740
+ - lib/ddtrace/contrib/rspec/configuration/settings.rb
741
+ - lib/ddtrace/contrib/rspec/example.rb
742
+ - lib/ddtrace/contrib/rspec/example_group.rb
743
+ - lib/ddtrace/contrib/rspec/ext.rb
744
+ - lib/ddtrace/contrib/rspec/integration.rb
745
+ - lib/ddtrace/contrib/rspec/patcher.rb
660
746
  - lib/ddtrace/contrib/sequel/configuration/settings.rb
661
747
  - lib/ddtrace/contrib/sequel/database.rb
662
748
  - lib/ddtrace/contrib/sequel/dataset.rb
@@ -689,6 +775,7 @@ files:
689
775
  - lib/ddtrace/contrib/sneakers/integration.rb
690
776
  - lib/ddtrace/contrib/sneakers/patcher.rb
691
777
  - lib/ddtrace/contrib/sneakers/tracer.rb
778
+ - lib/ddtrace/contrib/status_code_matcher.rb
692
779
  - lib/ddtrace/contrib/sucker_punch/configuration/settings.rb
693
780
  - lib/ddtrace/contrib/sucker_punch/exception_handler.rb
694
781
  - lib/ddtrace/contrib/sucker_punch/ext.rb
@@ -709,13 +796,16 @@ files:
709
796
  - lib/ddtrace/event.rb
710
797
  - lib/ddtrace/ext/analytics.rb
711
798
  - lib/ddtrace/ext/app_types.rb
799
+ - lib/ddtrace/ext/ci.rb
712
800
  - lib/ddtrace/ext/correlation.rb
713
801
  - lib/ddtrace/ext/diagnostics.rb
714
802
  - lib/ddtrace/ext/distributed.rb
715
803
  - lib/ddtrace/ext/environment.rb
716
804
  - lib/ddtrace/ext/errors.rb
717
805
  - lib/ddtrace/ext/forced_tracing.rb
806
+ - lib/ddtrace/ext/git.rb
718
807
  - lib/ddtrace/ext/http.rb
808
+ - lib/ddtrace/ext/integration.rb
719
809
  - lib/ddtrace/ext/manual_tracing.rb
720
810
  - lib/ddtrace/ext/metrics.rb
721
811
  - lib/ddtrace/ext/net.rb
@@ -723,6 +813,7 @@ files:
723
813
  - lib/ddtrace/ext/runtime.rb
724
814
  - lib/ddtrace/ext/sampling.rb
725
815
  - lib/ddtrace/ext/sql.rb
816
+ - lib/ddtrace/ext/test.rb
726
817
  - lib/ddtrace/ext/transport.rb
727
818
  - lib/ddtrace/forced_tracing.rb
728
819
  - lib/ddtrace/logger.rb
@@ -801,6 +892,7 @@ files:
801
892
  - lib/ddtrace/transport/traces.rb
802
893
  - lib/ddtrace/utils.rb
803
894
  - lib/ddtrace/utils/database.rb
895
+ - lib/ddtrace/utils/forking.rb
804
896
  - lib/ddtrace/utils/time.rb
805
897
  - lib/ddtrace/vendor/active_record/connection_specification.rb
806
898
  - lib/ddtrace/version.rb
@@ -834,7 +926,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
834
926
  - !ruby/object:Gem::Version
835
927
  version: 2.0.0
836
928
  requirements: []
837
- rubygems_version: 3.0.3
929
+ rubygems_version: 3.1.2
838
930
  signing_key:
839
931
  specification_version: 4
840
932
  summary: Datadog tracing code for your Ruby applications