ddtrace 0.34.1 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,9 +1,14 @@
1
+ require 'forwardable'
2
+
1
3
  require 'ddtrace/configuration/pin_setup'
2
4
  require 'ddtrace/configuration/settings'
5
+ require 'ddtrace/configuration/components'
3
6
 
4
7
  module Datadog
5
8
  # Configuration provides a unique access point for configurations
6
9
  module Configuration
10
+ extend Forwardable
11
+
7
12
  attr_writer :configuration
8
13
 
9
14
  def configuration
@@ -13,18 +18,36 @@ module Datadog
13
18
  def configure(target = configuration, opts = {})
14
19
  if target.is_a?(Settings)
15
20
  yield(target) if block_given?
21
+
22
+ # Build immutable components from settings
23
+ @components ||= nil
24
+ @components = if @components
25
+ Components.replace!(@components, target)
26
+ else
27
+ Components.new(target)
28
+ end
29
+
30
+ target
16
31
  else
17
32
  PinSetup.new(target, opts).call
18
33
  end
19
34
  end
20
35
 
21
- # Helper methods
22
- def tracer
23
- configuration.tracer
36
+ def_delegators \
37
+ :components,
38
+ :health_metrics,
39
+ :logger,
40
+ :runtime_metrics,
41
+ :tracer
42
+
43
+ def shutdown!
44
+ components.teardown! if @components
24
45
  end
25
46
 
26
- def runtime_metrics
27
- tracer.writer.runtime_metrics
47
+ protected
48
+
49
+ def components
50
+ @components ||= Components.new(configuration)
28
51
  end
29
52
  end
30
53
  end
@@ -45,7 +45,7 @@ module Datadog
45
45
  # Instance methods for configuration
46
46
  module InstanceMethods
47
47
  def initialize(options = {})
48
- configure(options)
48
+ configure(options) unless options.empty?
49
49
  end
50
50
 
51
51
  def configure(opts = {})
@@ -0,0 +1,154 @@
1
+ require 'ddtrace/diagnostics/health'
2
+ require 'ddtrace/logger'
3
+ require 'ddtrace/runtime/metrics'
4
+ require 'ddtrace/tracer'
5
+ require 'ddtrace/workers/runtime_metrics'
6
+
7
+ module Datadog
8
+ module Configuration
9
+ # Global components for the trace library.
10
+ # rubocop:disable Metrics/LineLength
11
+ class Components
12
+ class << self
13
+ def replace!(old, settings)
14
+ replacement = new(settings)
15
+ old.teardown!(replacement)
16
+ replacement
17
+ end
18
+
19
+ def build_health_metrics(settings)
20
+ settings = settings.diagnostics.health_metrics
21
+ options = { enabled: settings.enabled }
22
+ options[:statsd] = settings.statsd unless settings.statsd.nil?
23
+
24
+ Datadog::Diagnostics::Health::Metrics.new(options)
25
+ end
26
+
27
+ def build_logger(settings)
28
+ logger = settings.logger.instance || Datadog::Logger.new(STDOUT)
29
+ logger.level = settings.diagnostics.debug ? ::Logger::DEBUG : settings.logger.level
30
+
31
+ logger
32
+ end
33
+
34
+ def build_runtime_metrics(settings)
35
+ options = { enabled: settings.runtime_metrics.enabled }
36
+ options[:statsd] = settings.runtime_metrics.statsd unless settings.runtime_metrics.statsd.nil?
37
+ options[:services] = [settings.service] unless settings.service.nil?
38
+
39
+ Datadog::Runtime::Metrics.new(options)
40
+ end
41
+
42
+ def build_runtime_metrics_worker(settings)
43
+ # NOTE: Should we just ignore building the worker if its not enabled?
44
+ options = settings.runtime_metrics.opts.merge(
45
+ enabled: settings.runtime_metrics.enabled,
46
+ metrics: build_runtime_metrics(settings)
47
+ )
48
+
49
+ Datadog::Workers::RuntimeMetrics.new(options)
50
+ end
51
+
52
+ def build_tracer(settings)
53
+ # If a custom tracer has been provided, use it instead.
54
+ # Ignore all other options (they should already be configured.)
55
+ tracer = settings.tracer.instance
56
+ return tracer unless tracer.nil?
57
+
58
+ tracer = Tracer.new(
59
+ default_service: settings.service,
60
+ enabled: settings.tracer.enabled,
61
+ partial_flush: settings.tracer.partial_flush.enabled,
62
+ tags: build_tracer_tags(settings)
63
+ )
64
+
65
+ # TODO: We reconfigure the tracer here because it has way too many
66
+ # options it allows to mutate, and it's overwhelming to rewrite
67
+ # tracer initialization for now. Just reconfigure using the
68
+ # existing mutable #configure function. Remove when these components
69
+ # are extracted.
70
+ tracer.configure(build_tracer_options(settings))
71
+
72
+ tracer
73
+ end
74
+
75
+ private
76
+
77
+ def build_tracer_tags(settings)
78
+ settings.tags.dup.tap do |tags|
79
+ tags['env'] = settings.env unless settings.env.nil?
80
+ tags['version'] = settings.version unless settings.version.nil?
81
+ end
82
+ end
83
+
84
+ def build_tracer_options(settings)
85
+ settings = settings.tracer
86
+
87
+ {}.tap do |opts|
88
+ opts[:hostname] = settings.hostname unless settings.hostname.nil?
89
+ opts[:min_spans_before_partial_flush] = settings.partial_flush.min_spans_threshold unless settings.partial_flush.min_spans_threshold.nil?
90
+ opts[:partial_flush] = settings.partial_flush.enabled unless settings.partial_flush.enabled.nil?
91
+ opts[:port] = settings.port unless settings.port.nil?
92
+ opts[:priority_sampling] = settings.priority_sampling unless settings.priority_sampling.nil?
93
+ opts[:sampler] = settings.sampler unless settings.sampler.nil?
94
+ opts[:transport_options] = settings.transport_options
95
+ opts[:writer] = settings.writer unless settings.writer.nil?
96
+ opts[:writer_options] = settings.writer_options if settings.writer.nil?
97
+ end
98
+ end
99
+ end
100
+
101
+ attr_reader \
102
+ :health_metrics,
103
+ :logger,
104
+ :runtime_metrics,
105
+ :tracer
106
+
107
+ def initialize(settings)
108
+ # Logger
109
+ @logger = self.class.build_logger(settings)
110
+
111
+ # Tracer
112
+ @tracer = self.class.build_tracer(settings)
113
+
114
+ # Runtime metrics
115
+ @runtime_metrics = self.class.build_runtime_metrics_worker(settings)
116
+
117
+ # Health metrics
118
+ @health_metrics = self.class.build_health_metrics(settings)
119
+ end
120
+
121
+ # Shuts down all the components in use.
122
+ # If it has another instance to compare to, it will compare
123
+ # and avoid tearing down parts still in use.
124
+ def teardown!(replacement = nil)
125
+ # Shutdown the old tracer, unless it's still being used.
126
+ # (e.g. a custom tracer instance passed in.)
127
+ tracer.shutdown! unless replacement && tracer == replacement.tracer
128
+
129
+ # Shutdown workers
130
+ runtime_metrics.enabled = false
131
+ runtime_metrics.stop(true)
132
+
133
+ # Shutdown the old metrics, unless they are still being used.
134
+ # (e.g. custom Statsd instances.)
135
+ old_statsd = [
136
+ runtime_metrics.metrics.statsd,
137
+ health_metrics.statsd
138
+ ].compact.uniq
139
+
140
+ new_statsd = if replacement
141
+ [
142
+ replacement.runtime_metrics.metrics.statsd,
143
+ replacement.health_metrics.statsd
144
+ ].compact.uniq
145
+ else
146
+ []
147
+ end
148
+
149
+ unused_statsd = (old_statsd - (old_statsd & new_statsd))
150
+ unused_statsd.each(&:close)
151
+ end
152
+ end
153
+ end
154
+ end
@@ -80,7 +80,7 @@ module Datadog
80
80
  end
81
81
 
82
82
  def options_hash
83
- options.each_with_object({}) do |(key, _), hash|
83
+ self.class.options.merge(options).each_with_object({}) do |(key, _), hash|
84
84
  hash[key] = get_option(key)
85
85
  end
86
86
  end
@@ -1,3 +1,4 @@
1
+ require 'logger'
1
2
  require 'ddtrace/configuration/base'
2
3
 
3
4
  require 'ddtrace/ext/analytics'
@@ -5,34 +6,41 @@ require 'ddtrace/ext/distributed'
5
6
  require 'ddtrace/ext/runtime'
6
7
  require 'ddtrace/ext/sampling'
7
8
 
8
- require 'ddtrace/tracer'
9
- require 'ddtrace/metrics'
10
- require 'ddtrace/diagnostics/health'
11
-
12
9
  module Datadog
13
10
  module Configuration
14
11
  # Global configuration settings for the trace library.
12
+ # rubocop:disable Metrics/ClassLength
15
13
  class Settings
16
14
  include Base
17
15
 
18
16
  #
19
17
  # Configuration options
20
18
  #
19
+ settings :analytics do
20
+ option :enabled do |o|
21
+ o.default { env_to_bool(Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED, nil) }
22
+ o.lazy
23
+ end
24
+ end
25
+
21
26
  option :analytics_enabled do |o|
22
- # TODO: Raise deprecation warning
23
- o.default { env_to_bool(Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED, nil) }
24
- o.lazy
27
+ o.delegate_to { get_option(:analytics).enabled }
28
+ o.on_set do |value|
29
+ # TODO: Raise deprecation warning
30
+ get_option(:analytics).enabled = value
31
+ end
25
32
  end
26
33
 
27
34
  settings :diagnostics do
28
- option :health_metrics do |o|
29
- o.default do
30
- Datadog::Diagnostics::Health::Metrics.new(
31
- enabled: env_to_bool(Datadog::Ext::Diagnostics::Health::Metrics::ENV_ENABLED, false)
32
- )
35
+ option :debug, default: false
36
+
37
+ settings :health_metrics do
38
+ option :enabled do |o|
39
+ o.default { env_to_bool(Datadog::Ext::Diagnostics::Health::Metrics::ENV_ENABLED, false) }
40
+ o.lazy
33
41
  end
34
42
 
35
- o.lazy
43
+ option :statsd
36
44
  end
37
45
  end
38
46
 
@@ -63,7 +71,19 @@ module Datadog
63
71
  option :env do |o|
64
72
  o.default { ENV.fetch(Ext::Environment::ENV_ENVIRONMENT, nil) }
65
73
  o.lazy
66
- o.on_set { |value| get_option(:tracer).set_tags('env' => value) }
74
+ end
75
+
76
+ settings :logger do
77
+ option :instance do |o|
78
+ o.setter { |value, old_value| value.is_a?(::Logger) ? value : old_value }
79
+ o.on_set { |value| set_option(:level, value.level) unless value.nil? }
80
+ end
81
+
82
+ option :level, default: ::Logger::WARN
83
+ end
84
+
85
+ def logger=(logger)
86
+ get_option(:logger).instance = logger
67
87
  end
68
88
 
69
89
  option :report_hostname do |o|
@@ -71,19 +91,34 @@ module Datadog
71
91
  o.lazy
72
92
  end
73
93
 
94
+ settings :runtime_metrics do
95
+ option :enabled do |o|
96
+ o.default { env_to_bool(Ext::Runtime::Metrics::ENV_ENABLED, false) }
97
+ o.lazy
98
+ end
99
+
100
+ option :opts, default: ->(_i) { {} }, lazy: true
101
+ option :statsd
102
+ end
103
+
74
104
  # Backwards compatibility for configuring runtime metrics e.g. `c.runtime_metrics enabled: true`
75
105
  def runtime_metrics(options = nil)
76
- runtime_metrics = get_option(:tracer).writer.runtime_metrics
77
- return runtime_metrics if options.nil?
106
+ settings = get_option(:runtime_metrics)
107
+ return settings if options.nil?
78
108
 
109
+ # If options were provided (old style) then raise warnings and apply them:
79
110
  # TODO: Raise deprecation warning
80
- runtime_metrics.configure(options)
111
+ settings.enabled = options[:enabled] if options.key?(:enabled)
112
+ settings.statsd = options[:statsd] if options.key?(:statsd)
113
+ settings
81
114
  end
82
115
 
83
116
  option :runtime_metrics_enabled do |o|
84
- # TODO: Raise deprecation warning
85
- o.default { env_to_bool(Ext::Runtime::Metrics::ENV_ENABLED, false) }
86
- o.lazy
117
+ o.delegate_to { get_option(:runtime_metrics).enabled }
118
+ o.on_set do |value|
119
+ # TODO: Raise deprecation warning
120
+ get_option(:runtime_metrics).enabled = value
121
+ end
87
122
  end
88
123
 
89
124
  settings :sampling do
@@ -101,7 +136,6 @@ module Datadog
101
136
  option :service do |o|
102
137
  o.default { ENV.fetch(Ext::Environment::ENV_SERVICE, nil) }
103
138
  o.lazy
104
- o.on_set { |value| get_option(:tracer).default_service = value }
105
139
  end
106
140
 
107
141
  option :tags do |o|
@@ -125,62 +159,96 @@ module Datadog
125
159
  # Coerce keys to strings
126
160
  string_tags = Hash[new_value.collect { |k, v| [k.to_s, v] }]
127
161
 
162
+ # Cross-populate tag values with other settings
163
+ if env.nil? && string_tags.key?(Ext::Environment::TAG_ENV)
164
+ self.env = string_tags[Ext::Environment::TAG_ENV]
165
+ end
166
+
167
+ if version.nil? && string_tags.key?(Ext::Environment::TAG_VERSION)
168
+ self.version = string_tags[Ext::Environment::TAG_VERSION]
169
+ end
170
+
171
+ if service.nil? && string_tags.key?(Ext::Environment::TAG_SERVICE)
172
+ self.service = string_tags[Ext::Environment::TAG_SERVICE]
173
+ end
174
+
128
175
  # Merge with previous tags
129
176
  (old_value || {}).merge(string_tags)
130
177
  end
131
178
 
132
- o.on_set { |value| get_option(:tracer).set_tags(value) }
133
-
134
179
  o.lazy
135
180
  end
136
181
 
137
- option :tracer do |o|
138
- o.default { Tracer.new }
139
- o.lazy
182
+ settings :tracer do
183
+ option :enabled, default: true
184
+ option :hostname # TODO: Deprecate
185
+ option :instance
140
186
 
141
- # On reset, shut down the old tracer,
142
- # then instantiate a new one.
143
- o.resetter do |tracer|
144
- tracer.shutdown!
145
- Tracer.new
146
- end
147
-
148
- # Backwards compatibility for configuring tracer e.g. `c.tracer debug: true`
149
- o.helper :tracer do |options = nil|
150
- tracer = options && options.key?(:instance) ? set_option(:tracer, options[:instance]) : get_option(:tracer)
151
-
152
- tracer.tap do |t|
153
- unless options.nil?
154
- t.configure(options)
155
-
156
- if options[:log]
157
- # TODO: Raise deprecation warning
158
- Datadog::Logger.log = options[:log]
159
- end
160
-
161
- if options[:tags]
162
- # TODO: Raise deprecation warning
163
- t.set_tags(options[:tags])
164
- end
165
-
166
- if options[:env]
167
- # TODO: Raise deprecation warning
168
- t.set_tags(env: options[:env])
169
- end
170
-
171
- if options.key?(:debug)
172
- # TODO: Raise deprecation warning
173
- Datadog::Logger.debug_logging = options[:debug]
174
- end
175
- end
176
- end
187
+ settings :partial_flush do
188
+ option :enabled, default: false
189
+ option :min_spans_threshold
177
190
  end
191
+
192
+ option :port # TODO: Deprecate
193
+ option :priority_sampling # TODO: Deprecate
194
+ option :sampler
195
+ option :transport_options, default: ->(_i) { {} }, lazy: true # TODO: Deprecate
196
+ option :writer # TODO: Deprecate
197
+ option :writer_options, default: ->(_i) { {} }, lazy: true # TODO: Deprecate
198
+ end
199
+
200
+ # Backwards compatibility for configuring tracer e.g. `c.tracer debug: true`
201
+ def tracer(options = nil)
202
+ settings = get_option(:tracer)
203
+ return settings if options.nil?
204
+
205
+ # If options were provided (old style) then raise warnings and apply them:
206
+ options = options.dup
207
+
208
+ if options.key?(:log)
209
+ # TODO: Raise deprecation warning
210
+ get_option(:logger).instance = options.delete(:log)
211
+ end
212
+
213
+ if options.key?(:tags)
214
+ # TODO: Raise deprecation warning
215
+ set_option(:tags, options.delete(:tags))
216
+ end
217
+
218
+ if options.key?(:env)
219
+ # TODO: Raise deprecation warning
220
+ set_option(:env, options.delete(:env))
221
+ end
222
+
223
+ if options.key?(:debug)
224
+ # TODO: Raise deprecation warning
225
+ get_option(:diagnostics).debug = options.delete(:debug)
226
+ end
227
+
228
+ if options.key?(:partial_flush)
229
+ # TODO: Raise deprecation warning
230
+ settings.partial_flush.enabled = options.delete(:partial_flush)
231
+ end
232
+
233
+ if options.key?(:min_spans_before_partial_flush)
234
+ # TODO: Raise deprecation warning
235
+ settings.partial_flush.min_spans_threshold = options.delete(:min_spans_before_partial_flush)
236
+ end
237
+
238
+ # Forward remaining options to settings
239
+ options.each do |key, value|
240
+ setter = :"#{key}="
241
+ settings.send(setter, value) if settings.respond_to?(setter)
242
+ end
243
+ end
244
+
245
+ def tracer=(tracer)
246
+ get_option(:tracer).instance = tracer
178
247
  end
179
248
 
180
249
  option :version do |o|
181
250
  o.default { ENV.fetch(Ext::Environment::ENV_VERSION, nil) }
182
251
  o.lazy
183
- o.on_set { |value| get_option(:tracer).set_tags('version' => value) }
184
252
  end
185
253
  end
186
254
  end