ddtrace 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -6
- data/.circleci/images/primary/Dockerfile-1.9.3 +6 -2
- data/.circleci/images/primary/Dockerfile-2.0.0 +6 -2
- data/.circleci/images/primary/Dockerfile-2.1.10 +6 -2
- data/.circleci/images/primary/Dockerfile-2.2.10 +6 -2
- data/.circleci/images/primary/{Dockerfile-2.4.4 → Dockerfile-2.3.8} +5 -3
- data/.circleci/images/primary/{Dockerfile-2.3.7 → Dockerfile-2.4.6} +2 -2
- data/CHANGELOG.md +36 -0
- data/docker-compose.yml +6 -6
- data/docs/DevelopmentGuide.md +63 -0
- data/docs/GettingStarted.md +73 -3
- data/lib/ddtrace/configuration.rb +20 -1
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +39 -11
- data/lib/ddtrace/contrib/http/instrumentation.rb +2 -11
- data/lib/ddtrace/ext/forced_tracing.rb +18 -2
- data/lib/ddtrace/ext/manual_tracing.rb +9 -0
- data/lib/ddtrace/ext/metrics.rb +0 -1
- data/lib/ddtrace/ext/runtime.rb +0 -1
- data/lib/ddtrace/forced_tracing.rb +3 -3
- data/lib/ddtrace/metrics.rb +0 -3
- data/lib/ddtrace/runtime/metrics.rb +0 -1
- data/lib/ddtrace/sync_writer.rb +1 -1
- data/lib/ddtrace/tracer.rb +78 -17
- data/lib/ddtrace/transport.rb +9 -0
- data/lib/ddtrace/transport/http.rb +85 -0
- data/lib/ddtrace/transport/http/adapters/net.rb +112 -0
- data/lib/ddtrace/transport/http/adapters/registry.rb +24 -0
- data/lib/ddtrace/transport/http/adapters/test.rb +77 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +64 -0
- data/lib/ddtrace/transport/http/api.rb +46 -0
- data/lib/ddtrace/transport/http/api/endpoint.rb +27 -0
- data/lib/ddtrace/transport/http/api/fallbacks.rb +22 -0
- data/lib/ddtrace/transport/http/api/instance.rb +29 -0
- data/lib/ddtrace/transport/http/api/map.rb +14 -0
- data/lib/ddtrace/transport/http/api/spec.rb +15 -0
- data/lib/ddtrace/transport/http/builder.rb +165 -0
- data/lib/ddtrace/transport/http/client.rb +108 -0
- data/lib/ddtrace/transport/http/env.rb +48 -0
- data/lib/ddtrace/transport/http/response.rb +22 -0
- data/lib/ddtrace/transport/http/traces.rb +140 -0
- data/lib/ddtrace/transport/parcel.rb +13 -0
- data/lib/ddtrace/transport/request.rb +13 -0
- data/lib/ddtrace/transport/response.rb +49 -0
- data/lib/ddtrace/transport/statistics.rb +44 -0
- data/lib/ddtrace/transport/traces.rb +33 -0
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace/workers.rb +6 -2
- data/lib/ddtrace/writer.rb +48 -21
- metadata +26 -4
data/lib/ddtrace/version.rb
CHANGED
data/lib/ddtrace/workers.rb
CHANGED
@@ -53,14 +53,18 @@ module Datadog
|
|
53
53
|
# ensures that the thread will not die because of an exception.
|
54
54
|
# TODO[manu]: findout the reason and reschedule the send if it's not
|
55
55
|
# a fatal exception
|
56
|
-
Datadog::Tracer.log.error(
|
56
|
+
Datadog::Tracer.log.error(
|
57
|
+
"Error during traces flush: dropped #{traces.length} items. Cause: #{e} Location: #{e.backtrace.first}"
|
58
|
+
)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
62
|
def callback_runtime_metrics
|
61
63
|
@runtime_metrics_task.call unless @runtime_metrics_task.nil?
|
62
64
|
rescue StandardError => e
|
63
|
-
Datadog::Tracer.log.error(
|
65
|
+
Datadog::Tracer.log.error(
|
66
|
+
"Error during runtime metrics flush. Cause: #{e} Location: #{e.backtrace.first}"
|
67
|
+
)
|
64
68
|
end
|
65
69
|
|
66
70
|
# Start the timer execution.
|
data/lib/ddtrace/writer.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
require 'ddtrace/ext/net'
|
2
4
|
require 'ddtrace/runtime/socket'
|
3
5
|
|
4
6
|
require 'ddtrace/transport'
|
7
|
+
require 'ddtrace/transport/http'
|
5
8
|
require 'ddtrace/encoding'
|
6
9
|
require 'ddtrace/workers'
|
7
10
|
|
@@ -23,13 +26,12 @@ module Datadog
|
|
23
26
|
# priority sampling
|
24
27
|
if options[:priority_sampler]
|
25
28
|
@priority_sampler = options[:priority_sampler]
|
26
|
-
transport_options[:api_version] ||=
|
27
|
-
transport_options[:response_callback] ||= method(:sampling_updater)
|
29
|
+
transport_options[:api_version] ||= Transport::HTTP::API::V4
|
28
30
|
end
|
29
31
|
|
30
32
|
# transport and buffers
|
31
33
|
@transport = options.fetch(:transport) do
|
32
|
-
|
34
|
+
Transport::HTTP.default(transport_options)
|
33
35
|
end
|
34
36
|
|
35
37
|
# Runtime metrics
|
@@ -65,7 +67,8 @@ module Datadog
|
|
65
67
|
|
66
68
|
# stops worker for spans.
|
67
69
|
def stop
|
68
|
-
|
70
|
+
return if worker.nil?
|
71
|
+
@worker.stop
|
69
72
|
@worker = nil
|
70
73
|
end
|
71
74
|
|
@@ -76,11 +79,29 @@ module Datadog
|
|
76
79
|
# Inject hostname if configured to do so
|
77
80
|
inject_hostname!(traces) if Datadog.configuration.report_hostname
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
+
if transport.is_a?(Datadog::HTTPTransport)
|
83
|
+
# For older Datadog::HTTPTransport...
|
84
|
+
code = transport.send(:traces, traces)
|
85
|
+
(!transport.server_error?(code)).tap do |status|
|
86
|
+
@traces_flushed += traces.length if status
|
87
|
+
end
|
88
|
+
else
|
89
|
+
# For newer Datadog::Transports...
|
90
|
+
# Send traces an get a response.
|
91
|
+
response = transport.send_traces(traces)
|
82
92
|
|
83
|
-
|
93
|
+
unless response.internal_error?
|
94
|
+
@traces_flushed += traces.length unless response.server_error?
|
95
|
+
|
96
|
+
# Update priority sampler
|
97
|
+
unless priority_sampler.nil? || response.service_rates.nil?
|
98
|
+
priority_sampler.update(response.service_rates)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Return if server error occurred.
|
103
|
+
!response.server_error?
|
104
|
+
end
|
84
105
|
end
|
85
106
|
|
86
107
|
def send_runtime_metrics
|
@@ -130,19 +151,12 @@ module Datadog
|
|
130
151
|
}
|
131
152
|
end
|
132
153
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
hostname = Datadog::Runtime::Socket.hostname
|
140
|
-
unless hostname.nil? || hostname.empty?
|
141
|
-
trace.first.set_tag(Ext::NET::TAG_HOSTNAME, hostname)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
154
|
+
# Updates the priority sampler with rates from transport response.
|
155
|
+
# action (Symbol): Symbol representing data submitted.
|
156
|
+
# response: A Datadog::Transport::Response object.
|
157
|
+
# api: API version used to process this request.
|
158
|
+
#
|
159
|
+
# NOTE: Used only by old Datadog::HTTPTransport; will be removed.
|
146
160
|
def sampling_updater(action, response, api)
|
147
161
|
return unless action == :traces && response.is_a?(Net::HTTPOK)
|
148
162
|
|
@@ -156,5 +170,18 @@ module Datadog
|
|
156
170
|
false
|
157
171
|
end
|
158
172
|
end
|
173
|
+
|
174
|
+
private
|
175
|
+
|
176
|
+
def inject_hostname!(traces)
|
177
|
+
traces.each do |trace|
|
178
|
+
next if trace.first.nil?
|
179
|
+
|
180
|
+
hostname = Datadog::Runtime::Socket.hostname
|
181
|
+
unless hostname.nil? || hostname.empty?
|
182
|
+
trace.first.set_tag(Ext::NET::TAG_HOSTNAME, hostname)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
159
186
|
end
|
160
187
|
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.
|
4
|
+
version: 0.25.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: 2019-
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -291,8 +291,8 @@ files:
|
|
291
291
|
- ".circleci/images/primary/Dockerfile-2.0.0"
|
292
292
|
- ".circleci/images/primary/Dockerfile-2.1.10"
|
293
293
|
- ".circleci/images/primary/Dockerfile-2.2.10"
|
294
|
-
- ".circleci/images/primary/Dockerfile-2.3.
|
295
|
-
- ".circleci/images/primary/Dockerfile-2.4.
|
294
|
+
- ".circleci/images/primary/Dockerfile-2.3.8"
|
295
|
+
- ".circleci/images/primary/Dockerfile-2.4.6"
|
296
296
|
- ".dockerignore"
|
297
297
|
- ".env"
|
298
298
|
- ".gitignore"
|
@@ -532,6 +532,7 @@ files:
|
|
532
532
|
- lib/ddtrace/ext/errors.rb
|
533
533
|
- lib/ddtrace/ext/forced_tracing.rb
|
534
534
|
- lib/ddtrace/ext/http.rb
|
535
|
+
- lib/ddtrace/ext/manual_tracing.rb
|
535
536
|
- lib/ddtrace/ext/metrics.rb
|
536
537
|
- lib/ddtrace/ext/net.rb
|
537
538
|
- lib/ddtrace/ext/priority.rb
|
@@ -578,6 +579,27 @@ files:
|
|
578
579
|
- lib/ddtrace/sync_writer.rb
|
579
580
|
- lib/ddtrace/tracer.rb
|
580
581
|
- lib/ddtrace/transport.rb
|
582
|
+
- lib/ddtrace/transport/http.rb
|
583
|
+
- lib/ddtrace/transport/http/adapters/net.rb
|
584
|
+
- lib/ddtrace/transport/http/adapters/registry.rb
|
585
|
+
- lib/ddtrace/transport/http/adapters/test.rb
|
586
|
+
- lib/ddtrace/transport/http/adapters/unix_socket.rb
|
587
|
+
- lib/ddtrace/transport/http/api.rb
|
588
|
+
- lib/ddtrace/transport/http/api/endpoint.rb
|
589
|
+
- lib/ddtrace/transport/http/api/fallbacks.rb
|
590
|
+
- lib/ddtrace/transport/http/api/instance.rb
|
591
|
+
- lib/ddtrace/transport/http/api/map.rb
|
592
|
+
- lib/ddtrace/transport/http/api/spec.rb
|
593
|
+
- lib/ddtrace/transport/http/builder.rb
|
594
|
+
- lib/ddtrace/transport/http/client.rb
|
595
|
+
- lib/ddtrace/transport/http/env.rb
|
596
|
+
- lib/ddtrace/transport/http/response.rb
|
597
|
+
- lib/ddtrace/transport/http/traces.rb
|
598
|
+
- lib/ddtrace/transport/parcel.rb
|
599
|
+
- lib/ddtrace/transport/request.rb
|
600
|
+
- lib/ddtrace/transport/response.rb
|
601
|
+
- lib/ddtrace/transport/statistics.rb
|
602
|
+
- lib/ddtrace/transport/traces.rb
|
581
603
|
- lib/ddtrace/utils.rb
|
582
604
|
- lib/ddtrace/utils/database.rb
|
583
605
|
- lib/ddtrace/utils/time.rb
|