ddtrace 0.40.0 → 0.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/Rakefile +0 -23
- data/ddtrace.gemspec +1 -0
- data/lib/ddtrace/buffer.rb +154 -43
- data/lib/ddtrace/configuration.rb +4 -1
- data/lib/ddtrace/configuration/options.rb +3 -1
- data/lib/ddtrace/configuration/settings.rb +5 -1
- data/lib/ddtrace/contrib/active_record/events/sql.rb +4 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -2
- data/lib/ddtrace/contrib/aws/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/dalli/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +4 -0
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +4 -2
- data/lib/ddtrace/contrib/ethon/multi_patch.rb +4 -0
- data/lib/ddtrace/contrib/excon/middleware.rb +4 -0
- data/lib/ddtrace/contrib/faraday/middleware.rb +4 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +6 -4
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +4 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -0
- data/lib/ddtrace/contrib/http/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +3 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +4 -0
- data/lib/ddtrace/contrib/mysql2/instrumentation.rb +4 -0
- data/lib/ddtrace/contrib/presto/instrumentation.rb +3 -0
- data/lib/ddtrace/contrib/racecar/event.rb +4 -0
- data/lib/ddtrace/contrib/redis/tags.rb +4 -0
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +4 -0
- data/lib/ddtrace/contrib/sequel/database.rb +3 -1
- data/lib/ddtrace/contrib/sequel/dataset.rb +3 -2
- data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
- data/lib/ddtrace/contrib/sequel/utils.rb +16 -5
- data/lib/ddtrace/ext/integration.rb +8 -0
- data/lib/ddtrace/ext/runtime.rb +1 -0
- data/lib/ddtrace/opentracer/distributed_headers.rb +1 -1
- data/lib/ddtrace/propagation/grpc_propagator.rb +2 -2
- data/lib/ddtrace/runtime/metrics.rb +6 -2
- data/lib/ddtrace/sampler.rb +2 -2
- data/lib/ddtrace/span.rb +152 -27
- data/lib/ddtrace/tracer.rb +3 -4
- data/lib/ddtrace/transport/http/adapters/net.rb +8 -2
- data/lib/ddtrace/transport/http/statistics.rb +14 -1
- data/lib/ddtrace/transport/traces.rb +7 -2
- data/lib/ddtrace/utils.rb +7 -3
- data/lib/ddtrace/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbda933f09b8f29d20edc57d6825f6491158161b7e5164252deb006931e0e7d
|
4
|
+
data.tar.gz: b3aaa6718e835fbfe97db64faa62f82b2f3ff76aefadb53cb27fb9b236b842e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60d239de8c63091ede6a810127ad580629428b96181982cf543e77f45a89087dfdd238b98418fe72f0e27ebefae6d5f730208c5f6149541dfe1d1c6923579826
|
7
|
+
data.tar.gz: 1d3657bc28458d0b50d0c2c68d3397b20ef6b2d4c2a0adf2ec834f701fd2c7701bcdac7f6fbce913743482e5eb2492a6409baf7c9c37c3467677ead705fd752e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,38 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [0.41.0] - 2020-09-30
|
6
|
+
|
7
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.41.0
|
8
|
+
|
9
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.40.0...v0.41.0
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Improve duration counting using monotonic clock (#424, #1173) (@soulcutter)
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Add peer.service tag to external services and skip tagging external services with language tag for runtime metrics (#934, #935, #1180)
|
18
|
+
- This helps support the way runtime metrics are associated with spans in the UI.
|
19
|
+
- Faster TraceBuffer for CRuby (#1172)
|
20
|
+
- Reduce memory usage during gem statup (#1090)
|
21
|
+
- Reduce memory usage of the HTTP transport (#1165)
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
- Improved prepared statement support for Sequel integrations (#1186)
|
26
|
+
- Fix Sequel instrumentation when executing literal strings (#1185) (@matchbookmac)
|
27
|
+
- Remove explicit `Logger` class verification (#1181) (@bartekbsh)
|
28
|
+
- This allows users to pass in a custom logger that does not inherit from `Logger` class.
|
29
|
+
- Correct tracer buffer metric counting (#1182)
|
30
|
+
- Fix Span#pretty_print for empty duration (#1183)
|
31
|
+
|
32
|
+
### Refactored
|
33
|
+
|
34
|
+
- Improvements to test suite & CI (#1179, #1184, #1177, #1178, #1176)
|
35
|
+
- Reduce generated Span ID range to fit in Fixnum (#1189)
|
36
|
+
|
5
37
|
## [0.40.0] - 2020-09-08
|
6
38
|
|
7
39
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.40.0
|
@@ -1395,7 +1427,8 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
1395
1427
|
|
1396
1428
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
1397
1429
|
|
1398
|
-
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v0.
|
1430
|
+
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v0.41.0...master
|
1431
|
+
[0.41.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.40.0...v0.41.0
|
1399
1432
|
[0.40.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.39.0...v0.40.0
|
1400
1433
|
[0.39.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.38.0...v0.39.0
|
1401
1434
|
[0.38.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.37.0...v0.38.0
|
data/Rakefile
CHANGED
@@ -209,8 +209,6 @@ task :ci do
|
|
209
209
|
declare 'bundle exec rake test:main'
|
210
210
|
declare 'bundle exec rake spec:main'
|
211
211
|
declare 'bundle exec rake spec:contrib'
|
212
|
-
# Benchmarks
|
213
|
-
declare 'bundle exec rake spec:benchmark'
|
214
212
|
|
215
213
|
if RUBY_PLATFORM != 'java'
|
216
214
|
# Contrib minitests
|
@@ -265,8 +263,6 @@ task :ci do
|
|
265
263
|
declare 'bundle exec rake spec:main'
|
266
264
|
declare 'bundle exec rake spec:contrib'
|
267
265
|
declare 'bundle exec rake spec:opentracer'
|
268
|
-
# Benchmarks
|
269
|
-
declare 'bundle exec rake spec:benchmark'
|
270
266
|
|
271
267
|
if RUBY_PLATFORM != 'java'
|
272
268
|
# Contrib minitests
|
@@ -328,8 +324,6 @@ task :ci do
|
|
328
324
|
declare 'bundle exec rake spec:main'
|
329
325
|
declare 'bundle exec rake spec:contrib'
|
330
326
|
declare 'bundle exec rake spec:opentracer'
|
331
|
-
# Benchmarks
|
332
|
-
declare 'bundle exec rake spec:benchmark'
|
333
327
|
|
334
328
|
if RUBY_PLATFORM != 'java'
|
335
329
|
# Contrib minitests
|
@@ -403,8 +397,6 @@ task :ci do
|
|
403
397
|
declare 'bundle exec rake spec:main'
|
404
398
|
declare 'bundle exec rake spec:contrib'
|
405
399
|
declare 'bundle exec rake spec:opentracer'
|
406
|
-
# Benchmarks
|
407
|
-
declare 'bundle exec rake spec:benchmark'
|
408
400
|
|
409
401
|
if RUBY_PLATFORM != 'java'
|
410
402
|
# Contrib minitests
|
@@ -481,12 +473,8 @@ task :ci do
|
|
481
473
|
declare 'bundle exec rake spec:contrib'
|
482
474
|
declare 'bundle exec rake spec:opentracer'
|
483
475
|
declare 'bundle exec rake spec:opentelemetry'
|
484
|
-
# Benchmarks
|
485
|
-
declare 'bundle exec rake spec:benchmark'
|
486
476
|
|
487
477
|
if RUBY_PLATFORM != 'java'
|
488
|
-
# Benchmarks
|
489
|
-
declare 'bundle exec rake benchmark'
|
490
478
|
# Contrib minitests
|
491
479
|
# Contrib specs
|
492
480
|
declare 'bundle exec appraisal contrib rake spec:action_pack'
|
@@ -546,9 +534,6 @@ task :ci do
|
|
546
534
|
declare 'bundle exec rake spec:contrib'
|
547
535
|
declare 'bundle exec rake spec:opentracer'
|
548
536
|
declare 'bundle exec rake spec:opentelemetry'
|
549
|
-
# Benchmarks
|
550
|
-
declare 'bundle exec rake spec:benchmark' if RUBY_PLATFORM != 'java' # Too slow due to repeated JVM instantiation
|
551
|
-
declare 'bundle exec rake benchmark'
|
552
537
|
# Contrib minitests
|
553
538
|
# Contrib specs
|
554
539
|
declare 'bundle exec appraisal contrib rake spec:action_pack'
|
@@ -617,12 +602,8 @@ task :ci do
|
|
617
602
|
declare 'bundle exec rake spec:contrib'
|
618
603
|
declare 'bundle exec rake spec:opentracer'
|
619
604
|
declare 'bundle exec rake spec:opentelemetry'
|
620
|
-
# Benchmarks
|
621
|
-
declare 'bundle exec rake spec:benchmark'
|
622
605
|
|
623
606
|
if RUBY_PLATFORM != 'java'
|
624
|
-
# Benchmarks
|
625
|
-
declare 'bundle exec rake benchmark'
|
626
607
|
# Contrib minitests
|
627
608
|
# Contrib specs
|
628
609
|
declare 'bundle exec appraisal contrib rake spec:action_pack'
|
@@ -691,12 +672,8 @@ task :ci do
|
|
691
672
|
declare 'bundle exec rake spec:contrib'
|
692
673
|
declare 'bundle exec rake spec:opentracer'
|
693
674
|
declare 'bundle exec rake spec:opentelemetry'
|
694
|
-
# Benchmarks
|
695
|
-
declare 'bundle exec rake spec:benchmark'
|
696
675
|
|
697
676
|
if RUBY_PLATFORM != 'java'
|
698
|
-
# Benchmarks
|
699
|
-
declare 'bundle exec rake benchmark'
|
700
677
|
# Contrib minitests
|
701
678
|
# Contrib specs
|
702
679
|
declare 'bundle exec appraisal contrib rake spec:action_pack'
|
data/ddtrace.gemspec
CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'opentracing', '>= 0.4.1'
|
42
42
|
|
43
43
|
# Development dependencies
|
44
|
+
spec.add_development_dependency 'concurrent-ruby' # Leave it open as we also have it as an integration and want Appraisal to control the version under test.
|
44
45
|
spec.add_development_dependency 'rake', '>= 10.5'
|
45
46
|
spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
|
46
47
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/lib/ddtrace/buffer.rb
CHANGED
@@ -2,23 +2,79 @@ require 'thread'
|
|
2
2
|
require 'ddtrace/diagnostics/health'
|
3
3
|
require 'ddtrace/runtime/object_space'
|
4
4
|
|
5
|
+
# Trace buffer that accumulates traces for a consumer.
|
6
|
+
# Consumption can happen from a different thread.
|
5
7
|
module Datadog
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
# Aggregate metrics:
|
9
|
+
# They reflect buffer activity since last #pop.
|
10
|
+
# These may not be as accurate or as granular, but they
|
11
|
+
# don't use as much network traffic as live stats.
|
12
|
+
class MeasuredBuffer
|
13
|
+
def initialize
|
14
|
+
@buffer_accepted = 0
|
15
|
+
@buffer_accepted_lengths = 0
|
16
|
+
@buffer_dropped = 0
|
17
|
+
@buffer_spans = 0
|
18
|
+
end
|
12
19
|
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
20
|
+
def measure_accept(trace)
|
21
|
+
@buffer_accepted += 1
|
22
|
+
@buffer_accepted_lengths += trace.length
|
23
|
+
|
24
|
+
@buffer_spans += trace.length
|
25
|
+
rescue StandardError => e
|
26
|
+
Datadog.logger.debug("Failed to measure queue accept. Cause: #{e.message} Source: #{e.backtrace.first}")
|
27
|
+
end
|
16
28
|
|
17
|
-
|
29
|
+
def measure_drop(trace)
|
30
|
+
@buffer_dropped += 1
|
31
|
+
|
32
|
+
@buffer_spans -= trace.length
|
33
|
+
rescue StandardError => e
|
34
|
+
Datadog.logger.debug("Failed to measure queue drop. Cause: #{e.message} Source: #{e.backtrace.first}")
|
35
|
+
end
|
36
|
+
|
37
|
+
def measure_pop(traces)
|
38
|
+
# Accepted, cumulative totals
|
39
|
+
Datadog.health_metrics.queue_accepted(@buffer_accepted)
|
40
|
+
Datadog.health_metrics.queue_accepted_lengths(@buffer_accepted_lengths)
|
41
|
+
|
42
|
+
# Dropped, cumulative totals
|
43
|
+
Datadog.health_metrics.queue_dropped(@buffer_dropped)
|
44
|
+
# TODO: are we missing a +queue_dropped_lengths+ metric?
|
45
|
+
|
46
|
+
# Queue gauges, current values
|
47
|
+
Datadog.health_metrics.queue_max_length(@max_size)
|
48
|
+
Datadog.health_metrics.queue_spans(@buffer_spans)
|
49
|
+
Datadog.health_metrics.queue_length(traces.length)
|
50
|
+
|
51
|
+
# Reset aggregated metrics
|
18
52
|
@buffer_accepted = 0
|
19
53
|
@buffer_accepted_lengths = 0
|
20
54
|
@buffer_dropped = 0
|
21
55
|
@buffer_spans = 0
|
56
|
+
rescue StandardError => e
|
57
|
+
Datadog.logger.debug("Failed to measure queue. Cause: #{e.message} Source: #{e.backtrace.first}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Trace buffer that stores application traces and
|
62
|
+
# can be safely used concurrently on any environment.
|
63
|
+
#
|
64
|
+
# This implementation uses a {Mutex} around public methods, incurring
|
65
|
+
# overhead in order to ensure full thread-safety.
|
66
|
+
#
|
67
|
+
# This is implementation is recommended for non-CRuby environments.
|
68
|
+
# If using CRuby, {Datadog::CRubyTraceBuffer} is a faster implementation with minimal compromise.
|
69
|
+
class ThreadSafeBuffer < MeasuredBuffer
|
70
|
+
def initialize(max_size)
|
71
|
+
super()
|
72
|
+
|
73
|
+
@max_size = max_size
|
74
|
+
|
75
|
+
@mutex = Mutex.new()
|
76
|
+
@traces = []
|
77
|
+
@closed = false
|
22
78
|
end
|
23
79
|
|
24
80
|
# Add a new ``trace`` in the local queue. This method doesn't block the execution
|
@@ -72,48 +128,103 @@ module Datadog
|
|
72
128
|
@closed = true
|
73
129
|
end
|
74
130
|
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Trace buffer that stores application traces and
|
134
|
+
# can be safely used concurrently with CRuby.
|
135
|
+
#
|
136
|
+
# Under extreme concurrency scenarios, this class can exceed
|
137
|
+
# its +max_size+ by up to 4%.
|
138
|
+
#
|
139
|
+
# Because singular +Array+ operations are thread-safe in CRuby,
|
140
|
+
# we can implement the trace buffer without an explicit lock,
|
141
|
+
# while making the compromise of allowing the buffer to go
|
142
|
+
# over its maximum limit under extreme circumstances.
|
143
|
+
#
|
144
|
+
# On the following scenario:
|
145
|
+
# * 4.5 million spans/second.
|
146
|
+
# * Pushed into a single CRubyTraceBuffer from 1000 threads.
|
147
|
+
# The buffer can exceed its maximum size by no more than 4%.
|
148
|
+
#
|
149
|
+
# This implementation allocates less memory and is faster
|
150
|
+
# than {Datadog::ThreadSafeBuffer}.
|
151
|
+
#
|
152
|
+
# @see spec/ddtrace/benchmark/buffer_benchmark_spec.rb Buffer benchmarks
|
153
|
+
# @see https://github.com/ruby-concurrency/concurrent-ruby/blob/c1114a0c6891d9634f019f1f9fe58dcae8658964/lib/concurrent-ruby/concurrent/array.rb#L23-L27
|
154
|
+
class CRubyTraceBuffer < MeasuredBuffer
|
155
|
+
def initialize(max_size)
|
156
|
+
super()
|
157
|
+
|
158
|
+
@max_size = max_size
|
159
|
+
|
160
|
+
@traces = []
|
161
|
+
@closed = false
|
162
|
+
end
|
75
163
|
|
76
|
-
#
|
77
|
-
#
|
78
|
-
|
79
|
-
|
164
|
+
# Add a new ``trace`` in the local queue. This method doesn't block the execution
|
165
|
+
# even if the buffer is full. In that case, a random trace is discarded.
|
166
|
+
def push(trace)
|
167
|
+
return if @closed
|
168
|
+
len = @traces.length
|
169
|
+
if len < @max_size || @max_size <= 0
|
170
|
+
@traces << trace
|
171
|
+
else
|
172
|
+
# we should replace a random trace with the new one
|
173
|
+
replace_index = rand(len)
|
174
|
+
replaced_trace = @traces.delete_at(replace_index)
|
175
|
+
@traces << trace
|
176
|
+
|
177
|
+
# Check if we deleted the element right when the buffer
|
178
|
+
# was popped. In that case we didn't actually delete anything,
|
179
|
+
# we just inserted into a newly cleared buffer instead.
|
180
|
+
measure_drop(replaced_trace) if replaced_trace
|
181
|
+
end
|
80
182
|
|
81
|
-
|
82
|
-
@buffer_spans += trace.length
|
83
|
-
@buffer_accepted += 1
|
84
|
-
@buffer_accepted_lengths += trace.length
|
85
|
-
rescue StandardError => e
|
86
|
-
Datadog.logger.debug("Failed to measure queue accept. Cause: #{e.message} Source: #{e.backtrace.first}")
|
183
|
+
measure_accept(trace)
|
87
184
|
end
|
88
185
|
|
89
|
-
|
90
|
-
|
91
|
-
@
|
92
|
-
@buffer_accepted_lengths -= trace.length
|
93
|
-
rescue StandardError => e
|
94
|
-
Datadog.logger.debug("Failed to measure queue drop. Cause: #{e.message} Source: #{e.backtrace.first}")
|
186
|
+
# Return the current number of stored traces.
|
187
|
+
def length
|
188
|
+
@traces.length
|
95
189
|
end
|
96
190
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
191
|
+
# Return if the buffer is empty.
|
192
|
+
def empty?
|
193
|
+
@traces.empty?
|
194
|
+
end
|
101
195
|
|
102
|
-
|
103
|
-
|
196
|
+
# Return all traces stored and reset buffer.
|
197
|
+
def pop
|
198
|
+
traces = @traces.pop(VERY_LARGE_INTEGER)
|
104
199
|
|
105
|
-
|
106
|
-
Datadog.health_metrics.queue_max_length(@max_size)
|
107
|
-
Datadog.health_metrics.queue_spans(@buffer_spans)
|
108
|
-
Datadog.health_metrics.queue_length(traces.length)
|
200
|
+
measure_pop(traces)
|
109
201
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
202
|
+
traces
|
203
|
+
end
|
204
|
+
|
205
|
+
# Very large value, to ensure that we drain the whole buffer.
|
206
|
+
# 1<<62-1 happens to be the largest integer that can be stored inline in CRuby.
|
207
|
+
VERY_LARGE_INTEGER = 1 << 62 - 1
|
208
|
+
|
209
|
+
def close
|
210
|
+
@closed = true
|
117
211
|
end
|
118
212
|
end
|
213
|
+
|
214
|
+
# Choose default TraceBuffer implementation for current platform.
|
215
|
+
BUFFER_IMPLEMENTATION = if Datadog::Ext::Runtime::RUBY_ENGINE == 'ruby'
|
216
|
+
CRubyTraceBuffer
|
217
|
+
else
|
218
|
+
ThreadSafeBuffer
|
219
|
+
end
|
220
|
+
private_constant :BUFFER_IMPLEMENTATION
|
221
|
+
|
222
|
+
# Trace buffer that stores application traces. The buffer has a maximum size and when
|
223
|
+
# the buffer is full, a random trace is discarded. This class is thread-safe and is used
|
224
|
+
# automatically by the ``Tracer`` instance when a ``Span`` is finished.
|
225
|
+
#
|
226
|
+
# TODO We should restructure this module, so that classes are not declared at top-level ::Datadog.
|
227
|
+
# TODO Making such a change is potentially breaking for users manually configuring the tracer.
|
228
|
+
class TraceBuffer < BUFFER_IMPLEMENTATION
|
229
|
+
end
|
119
230
|
end
|
@@ -56,7 +56,10 @@ module Datadog
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def shutdown!
|
59
|
-
|
59
|
+
if instance_variable_defined?(:@components) && @components
|
60
|
+
components.shutdown!
|
61
|
+
@components = nil
|
62
|
+
end
|
60
63
|
end
|
61
64
|
|
62
65
|
protected
|
@@ -26,7 +26,9 @@ module Datadog
|
|
26
26
|
builder = OptionDefinition::Builder.new(name, meta, &block)
|
27
27
|
options[name] = builder.to_definition.tap do
|
28
28
|
# Resolve and define helper functions
|
29
|
-
helpers = default_helpers(name)
|
29
|
+
helpers = default_helpers(name)
|
30
|
+
# Prevent unnecessary creation of an identical copy of helpers if there's nothing to merge
|
31
|
+
helpers = helpers.merge(builder.helpers) unless builder.helpers.empty?
|
30
32
|
define_helpers(helpers)
|
31
33
|
end
|
32
34
|
end
|
@@ -40,6 +40,11 @@ module Datadog
|
|
40
40
|
option :debug do |o|
|
41
41
|
o.default { env_to_bool(Datadog::Ext::Diagnostics::DD_TRACE_DEBUG, false) }
|
42
42
|
o.lazy
|
43
|
+
o.on_set do |enabled|
|
44
|
+
# Enable rich debug print statements.
|
45
|
+
# We do not need to unnecessarily load 'pp' unless in debugging mode.
|
46
|
+
require 'pp' if enabled
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
settings :health_metrics do
|
@@ -91,7 +96,6 @@ module Datadog
|
|
91
96
|
|
92
97
|
settings :logger do
|
93
98
|
option :instance do |o|
|
94
|
-
o.setter { |value, old_value| value.is_a?(::Logger) ? value : old_value }
|
95
99
|
o.on_set { |value| set_option(:level, value.level) unless value.nil? }
|
96
100
|
end
|
97
101
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ddtrace/ext/integration'
|
1
2
|
require 'ddtrace/ext/net'
|
2
3
|
require 'ddtrace/contrib/analytics'
|
3
4
|
require 'ddtrace/contrib/active_record/ext'
|
@@ -39,6 +40,9 @@ module Datadog
|
|
39
40
|
span.resource = payload.fetch(:sql)
|
40
41
|
span.span_type = Datadog::Ext::SQL::TYPE
|
41
42
|
|
43
|
+
# Tag as an external peer service
|
44
|
+
span.set_tag(Datadog::Ext::Integration::TAG_PEER_SERVICE, span.service)
|
45
|
+
|
42
46
|
# Set analytics sample rate
|
43
47
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
44
48
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
@@ -76,8 +76,8 @@ module Datadog
|
|
76
76
|
|
77
77
|
# Start a trace
|
78
78
|
tracer.trace(@span_name, @options.dup).tap do |span|
|
79
|
-
#
|
80
|
-
span.
|
79
|
+
# Start span if time is provided
|
80
|
+
span.start(start) unless start.nil?
|
81
81
|
payload[:datadog_span] = span
|
82
82
|
end
|
83
83
|
end
|