ddtrace 0.34.1 → 0.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +58 -9
  3. data/.circleci/images/primary/Dockerfile-jruby-9.2 +77 -0
  4. data/.rubocop.yml +4 -0
  5. data/Appraisals +9 -7
  6. data/CHANGELOG.md +89 -3
  7. data/Rakefile +11 -2
  8. data/ddtrace.gemspec +5 -3
  9. data/docker-compose.yml +35 -0
  10. data/docs/DevelopmentGuide.md +1 -1
  11. data/docs/GettingStarted.md +89 -36
  12. data/lib/ddtrace.rb +1 -1
  13. data/lib/ddtrace/buffer.rb +9 -9
  14. data/lib/ddtrace/chunker.rb +34 -0
  15. data/lib/ddtrace/configuration.rb +28 -5
  16. data/lib/ddtrace/configuration/base.rb +1 -1
  17. data/lib/ddtrace/configuration/components.rb +154 -0
  18. data/lib/ddtrace/configuration/options.rb +1 -1
  19. data/lib/ddtrace/configuration/settings.rb +131 -63
  20. data/lib/ddtrace/context.rb +6 -6
  21. data/lib/ddtrace/context_flush.rb +1 -1
  22. data/lib/ddtrace/contrib/action_cable/instrumentation.rb +1 -1
  23. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +2 -2
  24. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -1
  25. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -1
  26. data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +1 -1
  27. data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +2 -2
  28. data/lib/ddtrace/contrib/action_view/patcher.rb +1 -1
  29. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +1 -1
  30. data/lib/ddtrace/contrib/active_record/events/sql.rb +1 -1
  31. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +2 -2
  32. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -2
  33. data/lib/ddtrace/contrib/analytics.rb +1 -1
  34. data/lib/ddtrace/contrib/configuration/settings.rb +1 -1
  35. data/lib/ddtrace/contrib/dalli/patcher.rb +1 -1
  36. data/lib/ddtrace/contrib/dalli/quantize.rb +1 -1
  37. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -1
  38. data/lib/ddtrace/contrib/excon/middleware.rb +2 -2
  39. data/lib/ddtrace/contrib/extensions.rb +29 -5
  40. data/lib/ddtrace/contrib/faraday/patcher.rb +1 -1
  41. data/lib/ddtrace/contrib/grape/endpoint.rb +5 -5
  42. data/lib/ddtrace/contrib/grape/patcher.rb +1 -1
  43. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +1 -1
  44. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +2 -2
  45. data/lib/ddtrace/contrib/grpc/patcher.rb +1 -1
  46. data/lib/ddtrace/contrib/http/circuit_breaker.rb +8 -32
  47. data/lib/ddtrace/contrib/http/instrumentation.rb +2 -2
  48. data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -2
  49. data/lib/ddtrace/contrib/patchable.rb +1 -1
  50. data/lib/ddtrace/contrib/patcher.rb +3 -3
  51. data/lib/ddtrace/contrib/presto/instrumentation.rb +3 -3
  52. data/lib/ddtrace/contrib/presto/patcher.rb +1 -1
  53. data/lib/ddtrace/contrib/rack/middlewares.rb +2 -2
  54. data/lib/ddtrace/contrib/rack/patcher.rb +2 -2
  55. data/lib/ddtrace/contrib/rack/request_queue.rb +1 -1
  56. data/lib/ddtrace/contrib/rails/configuration/settings.rb +14 -0
  57. data/lib/ddtrace/contrib/rails/framework.rb +54 -48
  58. data/lib/ddtrace/contrib/rails/integration.rb +1 -1
  59. data/lib/ddtrace/contrib/rake/instrumentation.rb +2 -2
  60. data/lib/ddtrace/contrib/redis/quantize.rb +1 -1
  61. data/lib/ddtrace/contrib/resque/resque_job.rb +2 -2
  62. data/lib/ddtrace/contrib/sidekiq/tracing.rb +1 -1
  63. data/lib/ddtrace/contrib/sinatra/env.rb +20 -0
  64. data/lib/ddtrace/contrib/sinatra/ext.rb +6 -0
  65. data/lib/ddtrace/contrib/sinatra/patcher.rb +1 -0
  66. data/lib/ddtrace/contrib/sinatra/tracer.rb +98 -35
  67. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +16 -13
  68. data/lib/ddtrace/correlation.rb +9 -6
  69. data/lib/ddtrace/diagnostics/health.rb +2 -6
  70. data/lib/ddtrace/encoding.rb +13 -39
  71. data/lib/ddtrace/event.rb +1 -1
  72. data/lib/ddtrace/ext/correlation.rb +1 -0
  73. data/lib/ddtrace/ext/diagnostics.rb +2 -0
  74. data/lib/ddtrace/ext/environment.rb +1 -0
  75. data/lib/ddtrace/ext/forced_tracing.rb +1 -1
  76. data/lib/ddtrace/logger.rb +3 -44
  77. data/lib/ddtrace/metrics.rb +5 -5
  78. data/lib/ddtrace/monkey.rb +1 -1
  79. data/lib/ddtrace/opentracer/global_tracer.rb +1 -1
  80. data/lib/ddtrace/pin.rb +18 -17
  81. data/lib/ddtrace/pipeline.rb +1 -1
  82. data/lib/ddtrace/propagation/http_propagator.rb +2 -2
  83. data/lib/ddtrace/runtime/cgroup.rb +1 -1
  84. data/lib/ddtrace/runtime/container.rb +1 -1
  85. data/lib/ddtrace/runtime/metrics.rb +5 -2
  86. data/lib/ddtrace/sampler.rb +2 -2
  87. data/lib/ddtrace/sampling/rule.rb +1 -1
  88. data/lib/ddtrace/sampling/rule_sampler.rb +1 -1
  89. data/lib/ddtrace/span.rb +4 -4
  90. data/lib/ddtrace/sync_writer.rb +3 -8
  91. data/lib/ddtrace/tracer.rb +26 -31
  92. data/lib/ddtrace/transport/http.rb +1 -1
  93. data/lib/ddtrace/transport/http/api/instance.rb +4 -0
  94. data/lib/ddtrace/transport/http/builder.rb +3 -5
  95. data/lib/ddtrace/transport/http/client.rb +7 -64
  96. data/lib/ddtrace/transport/http/response.rb +1 -1
  97. data/lib/ddtrace/transport/http/statistics.rb +1 -1
  98. data/lib/ddtrace/transport/http/traces.rb +10 -7
  99. data/lib/ddtrace/transport/io.rb +1 -1
  100. data/lib/ddtrace/transport/io/client.rb +2 -2
  101. data/lib/ddtrace/transport/io/response.rb +3 -1
  102. data/lib/ddtrace/transport/io/traces.rb +50 -3
  103. data/lib/ddtrace/transport/parcel.rb +0 -4
  104. data/lib/ddtrace/transport/statistics.rb +2 -2
  105. data/lib/ddtrace/transport/traces.rb +160 -10
  106. data/lib/ddtrace/utils.rb +1 -1
  107. data/lib/ddtrace/version.rb +2 -2
  108. data/lib/ddtrace/workers.rb +5 -13
  109. data/lib/ddtrace/workers/async.rb +2 -2
  110. data/lib/ddtrace/workers/runtime_metrics.rb +47 -0
  111. data/lib/ddtrace/workers/trace_writer.rb +199 -0
  112. data/lib/ddtrace/writer.rb +20 -27
  113. metadata +22 -32
@@ -95,12 +95,12 @@ module Datadog
95
95
  if @max_length > 0 && @trace.length >= @max_length
96
96
  # Detach the span from any context, it's being dropped and ignored.
97
97
  span.context = nil
98
- Datadog::Logger.log.debug("context full, ignoring span #{span.name}")
98
+ Datadog.logger.debug("context full, ignoring span #{span.name}")
99
99
 
100
100
  # If overflow has already occurred, don't send this metric.
101
101
  # Prevents metrics spam if buffer repeatedly overflows for the same trace.
102
102
  unless @overflow
103
- Diagnostics::Health.metrics.error_context_overflow(1, tags: ["max_length:#{@max_length}"])
103
+ Datadog.health_metrics.error_context_overflow(1, tags: ["max_length:#{@max_length}"])
104
104
  @overflow = true
105
105
  end
106
106
 
@@ -124,14 +124,14 @@ module Datadog
124
124
  set_current_span(span.parent)
125
125
  return if span.tracer.nil?
126
126
  if span.parent.nil? && !all_spans_finished?
127
- if Datadog::Logger.debug_logging
127
+ if Datadog.configuration.diagnostics.debug
128
128
  opened_spans = @trace.length - @finished_spans
129
- Datadog::Logger.log.debug("root span #{span.name} closed but has #{opened_spans} unfinished spans:")
129
+ Datadog.logger.debug("root span #{span.name} closed but has #{opened_spans} unfinished spans:")
130
130
  end
131
131
 
132
132
  @trace.reject(&:finished?).group_by(&:name).each do |unfinished_span_name, unfinished_spans|
133
- Datadog::Logger.log.debug("unfinished span: #{unfinished_spans.first}") if Datadog::Logger.debug_logging
134
- Diagnostics::Health.metrics.error_unfinished_spans(
133
+ Datadog.logger.debug("unfinished span: #{unfinished_spans.first}") if Datadog.configuration.diagnostics.debug
134
+ Datadog.health_metrics.error_unfinished_spans(
135
135
  unfinished_spans.length,
136
136
  tags: ["name:#{unfinished_span_name}"]
137
137
  )
@@ -58,7 +58,7 @@ module Datadog
58
58
  if trace[0]
59
59
  context.annotate_for_flush!(trace[0])
60
60
  else
61
- Datadog::Logger.log.debug('Tried to retrieve trace from context, but got nothing. ' \
61
+ Datadog.logger.debug('Tried to retrieve trace from context, but got nothing. ' \
62
62
  "Is there another consumer for this context? #{context.trace_id}")
63
63
  end
64
64
 
@@ -18,7 +18,7 @@ module Datadog
18
18
  rack_request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
19
19
  rack_request_span.resource = span.resource if rack_request_span
20
20
  rescue StandardError => e
21
- Datadog::Logger.log.error("Error preparing span for ActionCable::Connection: #{e}")
21
+ Datadog.logger.error("Error preparing span for ActionCable::Connection: #{e}")
22
22
  end
23
23
 
24
24
  super
@@ -24,7 +24,7 @@ module Datadog
24
24
  tracing_context = payload.fetch(:tracing_context)
25
25
  tracing_context[:dd_request_span] = span
26
26
  rescue StandardError => e
27
- Datadog::Logger.log.error(e.message)
27
+ Datadog.logger.error(e.message)
28
28
  end
29
29
 
30
30
  def finish_processing(payload)
@@ -71,7 +71,7 @@ module Datadog
71
71
  span.finish
72
72
  end
73
73
  rescue StandardError => e
74
- Datadog::Logger.log.error(e.message)
74
+ Datadog.logger.error(e.message)
75
75
  end
76
76
 
77
77
  def exception_controller?(payload)
@@ -36,7 +36,7 @@ module Datadog
36
36
 
37
37
  record_exception(span, payload)
38
38
  rescue StandardError => e
39
- Datadog::Logger.log.debug(e.message)
39
+ Datadog.logger.debug(e.message)
40
40
  end
41
41
  end
42
42
  end
@@ -39,7 +39,7 @@ module Datadog
39
39
 
40
40
  record_exception(span, payload)
41
41
  rescue StandardError => e
42
- Datadog::Logger.log.debug(e.message)
42
+ Datadog.logger.debug(e.message)
43
43
  end
44
44
  end
45
45
  end
@@ -21,7 +21,7 @@ module Datadog
21
21
 
22
22
  datadog_render_partial(template)
23
23
  rescue StandardError => e
24
- Datadog::Logger.log.debug(e.message)
24
+ Datadog.logger.debug(e.message)
25
25
  end
26
26
 
27
27
  # execute the original function anyway
@@ -54,7 +54,7 @@ module Datadog
54
54
  # Measure service stats
55
55
  Contrib::Analytics.set_measured(active_datadog_span)
56
56
  rescue StandardError => e
57
- Datadog::Logger.log.debug(e.message)
57
+ Datadog.logger.debug(e.message)
58
58
  end
59
59
 
60
60
  # execute the original function anyway
@@ -103,7 +103,7 @@ module Datadog
103
103
 
104
104
  datadog_render_template(template, layout_name)
105
105
  rescue StandardError => e
106
- Datadog::Logger.log.debug(e.message)
106
+ Datadog.logger.debug(e.message)
107
107
  end
108
108
 
109
109
  # execute the original function anyway
@@ -38,7 +38,7 @@ module Datadog
38
38
  ::ActionView::Rendering.send(:prepend, Instrumentation::TemplateRenderer::Rails30)
39
39
  ::ActionView::Partials::PartialRenderer.send(:prepend, Instrumentation::PartialRenderer::RailsLessThan4)
40
40
  else
41
- Datadog::Logger.log.debug('Expected Template/Partial classes not found; template rendering disabled')
41
+ Datadog.logger.debug('Expected Template/Partial classes not found; template rendering disabled')
42
42
  end
43
43
  end
44
44
  end
@@ -51,7 +51,7 @@ module Datadog
51
51
  span.set_tag(Ext::TAG_INSTANTIATION_CLASS_NAME, payload.fetch(:class_name))
52
52
  span.set_tag(Ext::TAG_INSTANTIATION_RECORD_COUNT, payload.fetch(:record_count))
53
53
  rescue StandardError => e
54
- Datadog::Logger.log.debug(e.message)
54
+ Datadog.logger.debug(e.message)
55
55
  end
56
56
  end
57
57
  end
@@ -55,7 +55,7 @@ module Datadog
55
55
  span.set_tag(Datadog::Ext::NET::TARGET_HOST, config[:host]) if config[:host]
56
56
  span.set_tag(Datadog::Ext::NET::TARGET_PORT, config[:port]) if config[:port]
57
57
  rescue StandardError => e
58
- Datadog::Logger.log.debug(e.message)
58
+ Datadog.logger.debug(e.message)
59
59
  end
60
60
  end
61
61
  end
@@ -31,7 +31,7 @@ module Datadog
31
31
  span.resource = payload.fetch(:action)
32
32
  tracing_context[:dd_cache_span] = span
33
33
  rescue StandardError => e
34
- Datadog::Logger.log.debug(e.message)
34
+ Datadog.logger.debug(e.message)
35
35
  end
36
36
 
37
37
  def finish_trace_cache(payload)
@@ -56,7 +56,7 @@ module Datadog
56
56
  span.finish
57
57
  end
58
58
  rescue StandardError => e
59
- Datadog::Logger.log.debug(e.message)
59
+ Datadog.logger.debug(e.message)
60
60
  end
61
61
 
62
62
  # Defines instrumentation for ActiveSupport cache reading
@@ -114,7 +114,7 @@ module Datadog
114
114
  def run(span, name, id, payload)
115
115
  run!(span, name, id, payload)
116
116
  rescue StandardError => e
117
- Datadog::Logger.log.debug("ActiveSupport::Notifications handler for '#{name}' failed: #{e.message}")
117
+ Datadog.logger.debug("ActiveSupport::Notifications handler for '#{name}' failed: #{e.message}")
118
118
  end
119
119
 
120
120
  def run!(*args)
@@ -139,7 +139,7 @@ module Datadog
139
139
  begin
140
140
  callback.call(event, key, *args)
141
141
  rescue StandardError => e
142
- Datadog::Logger.log.debug(
142
+ Datadog.logger.debug(
143
143
  "ActiveSupport::Notifications '#{key}' callback for '#{event}' failed: #{e.message}"
144
144
  )
145
145
  end
@@ -9,7 +9,7 @@ module Datadog
9
9
  # Checks whether analytics should be enabled.
10
10
  # `flag` is a truthy/falsey value that represents a setting on the integration.
11
11
  def enabled?(flag = nil)
12
- (Datadog.configuration.analytics_enabled && flag != false) || flag == true
12
+ (Datadog.configuration.analytics.enabled && flag != false) || flag == true
13
13
  end
14
14
 
15
15
  def set_sample_rate(span, sample_rate)
@@ -16,7 +16,7 @@ module Datadog
16
16
 
17
17
  def configure(options = {})
18
18
  self.class.options.dependency_order.each do |name|
19
- self[name] = options.fetch(name, self[name])
19
+ self[name] = options[name] if options.key?(name)
20
20
  end
21
21
 
22
22
  yield(self) if block_given?
@@ -57,7 +57,7 @@ module Datadog
57
57
 
58
58
  def log_deprecation_warning(method_name)
59
59
  do_once(method_name) do
60
- Datadog::Logger.log.warn("#{method_name}:#{DEPRECATION_WARNING}")
60
+ Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
61
61
  end
62
62
  end
63
63
  end
@@ -13,7 +13,7 @@ module Datadog
13
13
  command = Utils.utf8_encode(command, binary: true, placeholder: placeholder)
14
14
  Utils.truncate(command, Ext::QUANTIZE_MAX_CMD_LENGTH)
15
15
  rescue => e
16
- Logger.log.debug("Error sanitizing Dalli operation: #{e}")
16
+ Datadog.logger.debug("Error sanitizing Dalli operation: #{e}")
17
17
  placeholder
18
18
  end
19
19
  end
@@ -97,7 +97,7 @@ module Datadog
97
97
  quantized_url = Datadog::Contrib::Elasticsearch::Quantize.format_url(url)
98
98
  span.resource = "#{method} #{quantized_url}"
99
99
  rescue StandardError => e
100
- Datadog::Logger.log.error(e.message)
100
+ Datadog.logger.error(e.message)
101
101
  ensure
102
102
  # the call is still executed
103
103
  response = perform_request_without_datadog(*args)
@@ -34,7 +34,7 @@ module Datadog
34
34
  end
35
35
  end
36
36
  rescue StandardError => e
37
- Datadog::Logger.log.debug(e.message)
37
+ Datadog.logger.debug(e.message)
38
38
  end
39
39
 
40
40
  @stack.request_call(datum)
@@ -137,7 +137,7 @@ module Datadog
137
137
  end
138
138
  end
139
139
  rescue StandardError => e
140
- Datadog::Logger.log.debug(e.message)
140
+ Datadog.logger.debug(e.message)
141
141
  end
142
142
 
143
143
  def propagate!(span, datum)
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  require 'ddtrace/contrib/registry'
2
3
 
3
4
  module Datadog
@@ -7,6 +8,7 @@ module Datadog
7
8
  module Extensions
8
9
  def self.extended(base)
9
10
  Datadog.send(:extend, Helpers)
11
+ Datadog.send(:extend, Configuration)
10
12
  Datadog::Configuration::Settings.send(:include, Configuration::Settings)
11
13
  end
12
14
 
@@ -17,7 +19,24 @@ module Datadog
17
19
  end
18
20
  end
19
21
 
22
+ # Configuration methods for Datadog module.
20
23
  module Configuration
24
+ def configure(target = configuration, opts = {})
25
+ # Reconfigure core settings
26
+ super
27
+
28
+ # Activate integrations
29
+ if target.respond_to?(:integrations_pending_activation)
30
+ target.integrations_pending_activation.each do |integration|
31
+ integration.patch if integration.respond_to?(:patch)
32
+ end
33
+
34
+ target.integrations_pending_activation.clear
35
+ end
36
+
37
+ target
38
+ end
39
+
21
40
  # Extensions for Datadog::Configuration::Settings
22
41
  module Settings
23
42
  InvalidIntegrationError = Class.new(StandardError)
@@ -34,22 +53,27 @@ module Datadog
34
53
  integration.configuration(configuration_name) unless integration.nil?
35
54
  end
36
55
 
37
- def use(integration_name, options = {}, &block)
56
+ def instrument(integration_name, options = {}, &block)
38
57
  integration = fetch_integration(integration_name)
39
58
 
40
59
  unless integration.nil?
41
60
  configuration_name = options[:describes] || :default
42
61
  filtered_options = options.reject { |k, _v| k == :describes }
43
62
  integration.configure(configuration_name, filtered_options, &block)
44
- end
45
63
 
46
- integration.patch if integration.respond_to?(:patch)
64
+ # Add to activation list
65
+ integrations_pending_activation << integration
66
+ end
47
67
  end
48
68
 
49
- private
69
+ alias_method :use, :instrument
70
+
71
+ def integrations_pending_activation
72
+ @integrations_pending_activation ||= Set.new
73
+ end
50
74
 
51
75
  def fetch_integration(name)
52
- get_option(:registry)[name] ||
76
+ registry[name] ||
53
77
  raise(InvalidIntegrationError, "'#{name}' is not a valid integration.")
54
78
  end
55
79
  end
@@ -71,7 +71,7 @@ module Datadog
71
71
 
72
72
  def log_deprecation_warning(method_name)
73
73
  do_once(method_name) do
74
- Datadog::Logger.log.warn("#{method_name}:#{DEPRECATION_WARNING}")
74
+ Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
75
75
  end
76
76
  end
77
77
  end
@@ -46,7 +46,7 @@ module Datadog
46
46
 
47
47
  Thread.current[KEY_RUN] = true
48
48
  rescue StandardError => e
49
- Datadog::Logger.log.error(e.message)
49
+ Datadog.logger.error(e.message)
50
50
  end
51
51
 
52
52
  def endpoint_run(name, start, finish, id, payload)
@@ -99,7 +99,7 @@ module Datadog
99
99
  span.finish(finish)
100
100
  end
101
101
  rescue StandardError => e
102
- Datadog::Logger.log.error(e.message)
102
+ Datadog.logger.error(e.message)
103
103
  end
104
104
 
105
105
  def endpoint_start_render(*)
@@ -115,7 +115,7 @@ module Datadog
115
115
 
116
116
  Thread.current[KEY_RENDER] = true
117
117
  rescue StandardError => e
118
- Datadog::Logger.log.error(e.message)
118
+ Datadog.logger.error(e.message)
119
119
  end
120
120
 
121
121
  def endpoint_render(name, start, finish, id, payload)
@@ -138,7 +138,7 @@ module Datadog
138
138
  span.finish(finish)
139
139
  end
140
140
  rescue StandardError => e
141
- Datadog::Logger.log.error(e.message)
141
+ Datadog.logger.error(e.message)
142
142
  end
143
143
 
144
144
  def endpoint_run_filters(name, start, finish, id, payload)
@@ -173,7 +173,7 @@ module Datadog
173
173
  span.finish(finish)
174
174
  end
175
175
  rescue StandardError => e
176
- Datadog::Logger.log.error(e.message)
176
+ Datadog.logger.error(e.message)
177
177
  end
178
178
 
179
179
  private
@@ -63,7 +63,7 @@ module Datadog
63
63
 
64
64
  def log_deprecation_warning(method_name)
65
65
  do_once(method_name) do
66
- Datadog::Logger.log.warn("#{method_name}:#{DEPRECATION_WARNING}")
66
+ Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
67
67
  end
68
68
  end
69
69
  end
@@ -40,7 +40,7 @@ module Datadog
40
40
  Datadog::GRPCPropagator
41
41
  .inject!(span.context, metadata)
42
42
  rescue StandardError => e
43
- Datadog::Logger.log.debug("GRPC client trace failed: #{e}")
43
+ Datadog.logger.debug("GRPC client trace failed: #{e}")
44
44
  end
45
45
 
46
46
  def format_resource(proto_method)
@@ -35,7 +35,7 @@ module Datadog
35
35
  tracer.provider.context = Datadog::GRPCPropagator
36
36
  .extract(metadata)
37
37
  rescue StandardError => e
38
- Datadog::Logger.log.debug(
38
+ Datadog.logger.debug(
39
39
  "unable to propagate GRPC metadata to context: #{e}"
40
40
  )
41
41
  end
@@ -52,7 +52,7 @@ module Datadog
52
52
  # Measure service stats
53
53
  Contrib::Analytics.set_measured(span)
54
54
  rescue StandardError => e
55
- Datadog::Logger.log.debug("GRPC client trace failed: #{e}")
55
+ Datadog.logger.debug("GRPC client trace failed: #{e}")
56
56
  end
57
57
 
58
58
  def reserved_headers
@@ -62,7 +62,7 @@ module Datadog
62
62
 
63
63
  def log_deprecation_warning(method_name)
64
64
  do_once(method_name) do
65
- Datadog::Logger.log.warn("#{method_name}:#{DEPRECATION_WARNING}")
65
+ Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
66
66
  end
67
67
  end
68
68
  end
@@ -4,8 +4,8 @@ module Datadog
4
4
  # HTTP integration circuit breaker behavior
5
5
  # For avoiding recursive traces.
6
6
  module CircuitBreaker
7
- def should_skip_tracing?(req, address, port, tracer)
8
- return true if datadog_http_request?(req, address, port, tracer)
7
+ def should_skip_tracing?(request, tracer)
8
+ return true if datadog_http_request?(request)
9
9
 
10
10
  # we don't want a "shotgun" effect with two nested traces for one
11
11
  # logical get, and request is likely to call itself recursively
@@ -16,38 +16,14 @@ module Datadog
16
16
  end
17
17
 
18
18
  # We don't want to trace our own call to the API (they use net/http)
19
- # TODO: We don't want this kind of coupling with the transport.
19
+ # TODO: We don't want this kind of soft-check on HTTP requests.
20
20
  # Remove this when transport implements its own "skip tracing" mechanism.
21
- def datadog_http_request?(req, address, port, tracer)
22
- transport = tracer.writer.transport
23
-
24
- transport_hostname = nil
25
- transport_port = nil
26
-
27
- # Get settings from transport, if available.
28
- case transport
29
- when Datadog::Transport::HTTP::Client
30
- adapter = transport.current_api.adapter
31
- if adapter.is_a?(Datadog::Transport::HTTP::Adapters::Net)
32
- transport_hostname = adapter.hostname.to_s
33
- transport_port = adapter.port.to_i
34
- end
35
- end
36
-
37
- # When we know the host & port (from the URI) we use it, else (most-likely
38
- # called with a block) rely on the URL at the end.
39
- if req.respond_to?(:uri) && req.uri
40
- if req.uri.host.to_s == transport_hostname &&
41
- req.uri.port.to_i == transport_port
42
- return true
43
- end
44
- elsif address && port &&
45
- address.to_s == transport_hostname &&
46
- port.to_i == transport_port
47
- return true
21
+ def datadog_http_request?(request)
22
+ if request[Datadog::Ext::Transport::HTTP::HEADER_META_TRACER_VERSION]
23
+ true
24
+ else
25
+ false
48
26
  end
49
-
50
- false
51
27
  end
52
28
 
53
29
  def should_skip_distributed_tracing?(pin)