lightstep 0.9.3 → 0.9.6
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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/examples/fork_children/main.rb +4 -9
- data/lib/lightstep/global_tracer.rb +1 -1
- data/lib/lightstep/reporter.rb +166 -0
- data/lib/lightstep/tracer.rb +22 -134
- data/lib/lightstep/transport/base.rb +0 -9
- data/lib/lightstep/transport/callback.rb +0 -9
- data/lib/lightstep/transport/http_json.rb +7 -61
- data/lib/lightstep/version.rb +1 -1
- data/lightstep.gemspec +4 -3
- metadata +23 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d70ce2d0c73411b078a2855f102fb267db8cbc1
|
4
|
+
data.tar.gz: 6db2ee7c8186a11a4e7ace242c43eea628f4221d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 101ec7f4c34bcca170f4152cc57289eefb3d7963d23b1ab3ff1f7615e825542a0aa120a9ade836706444accbdadff95da7c0d2edb0e49067afafd09cca4f31bc
|
7
|
+
data.tar.gz: 7031358b6681e84a40e26d75cf4403dabdd0c74bc272bbae2aa1303c95164f1322ae669d3eb5f468800ffafe0552c87894413c4e2549a3517a7bf655d76c5aec
|
data/README.md
CHANGED
@@ -45,9 +45,9 @@ The LightStep Tracer is threadsafe. For increased performance, you can add the
|
|
45
45
|
`concurrent-ruby-ext` gem to your Gemfile. This will enable C extensions for
|
46
46
|
concurrent operations.
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
The LightStep Tracer is also Fork-safe. When forking, the child process will
|
49
|
+
not inherit the unflushed spans of the parent, so they will only be flushed
|
50
|
+
once.
|
51
51
|
|
52
52
|
## Development
|
53
53
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# A simple, manual test ensuring that tracer instances still report after a
|
2
|
-
# Process.fork.
|
3
|
-
# disabled before the fork and reenabled afterward.
|
2
|
+
# Process.fork.
|
4
3
|
|
5
4
|
require 'bundler/setup'
|
6
5
|
require 'lightstep'
|
@@ -14,10 +13,7 @@ puts 'Starting...'
|
|
14
13
|
(1..20).each do |k|
|
15
14
|
puts "Explicit reset iteration #{k}..."
|
16
15
|
|
17
|
-
# NOTE: the tracer is disabled and reenabled on either side of the fork
|
18
|
-
LightStep.disable
|
19
16
|
pid = Process.fork do
|
20
|
-
LightStep.enable
|
21
17
|
10.times do
|
22
18
|
span = LightStep.start_span("my_forked_span-#{Process.pid}")
|
23
19
|
sleep(0.0025 * rand(k))
|
@@ -25,9 +21,6 @@ puts 'Starting...'
|
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
28
|
-
# Also renable the parent process' tracer
|
29
|
-
LightStep.enable
|
30
|
-
|
31
24
|
10.times do
|
32
25
|
span = LightStep.start_span("my_process_span-#{Process.pid}")
|
33
26
|
sleep(0.0025 * rand(k))
|
@@ -35,6 +28,8 @@ puts 'Starting...'
|
|
35
28
|
end
|
36
29
|
|
37
30
|
# Make sure redundant enable calls don't cause problems
|
31
|
+
# NOTE: disabling discards the buffer by default, so all spans
|
32
|
+
# get cleared here except the final toggle span
|
38
33
|
10.times do
|
39
34
|
LightStep.disable
|
40
35
|
LightStep.enable
|
@@ -48,7 +43,7 @@ puts 'Starting...'
|
|
48
43
|
end
|
49
44
|
|
50
45
|
puts "Parent, pid #{Process.pid}, waiting on child pid #{pid}"
|
51
|
-
Process.wait
|
46
|
+
Process.wait(pid)
|
52
47
|
end
|
53
48
|
|
54
49
|
puts 'Done!'
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'concurrent/channel'
|
2
|
+
|
3
|
+
module LightStep
|
4
|
+
# Reporter builds up reports of spans and flushes them to a transport
|
5
|
+
class Reporter
|
6
|
+
attr_accessor :max_span_records
|
7
|
+
|
8
|
+
def initialize(max_span_records:, transport:, guid:, component_name:)
|
9
|
+
@max_span_records = max_span_records
|
10
|
+
@span_records = Concurrent::Array.new
|
11
|
+
@dropped_spans = Concurrent::AtomicFixnum.new
|
12
|
+
@dropped_span_logs = Concurrent::AtomicFixnum.new
|
13
|
+
@transport = transport
|
14
|
+
|
15
|
+
start_time = LightStep.micros(Time.now)
|
16
|
+
@guid = LightStep.guid
|
17
|
+
@report_start_time = start_time
|
18
|
+
|
19
|
+
@runtime = {
|
20
|
+
guid: guid,
|
21
|
+
start_micros: start_time,
|
22
|
+
group_name: component_name,
|
23
|
+
attrs: [
|
24
|
+
{Key: "lightstep.tracer_platform", Value: "ruby"},
|
25
|
+
{Key: "lightstep.tracer_version", Value: LightStep::VERSION},
|
26
|
+
{Key: "lightstep.tracer_platform_version", Value: RUBY_VERSION}
|
27
|
+
]
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
reset_on_fork
|
31
|
+
|
32
|
+
at_exit do
|
33
|
+
@quit_signal << true
|
34
|
+
@thread.join
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_span(span)
|
39
|
+
reset_on_fork
|
40
|
+
|
41
|
+
@span_records.push(span.to_h)
|
42
|
+
if @span_records.size > max_span_records
|
43
|
+
dropped = @span_records.shift
|
44
|
+
@dropped_spans.increment
|
45
|
+
@dropped_span_logs.increment(dropped[:log_records].size + dropped[:dropped_logs])
|
46
|
+
end
|
47
|
+
|
48
|
+
@span_signal << true
|
49
|
+
end
|
50
|
+
|
51
|
+
def clear
|
52
|
+
span_records = @span_records.slice!(0, @span_records.length)
|
53
|
+
@dropped_spans.increment(span_records.size)
|
54
|
+
@dropped_span_logs.increment(
|
55
|
+
span_records.reduce(0) {|memo, span|
|
56
|
+
memo + span[:log_records].size + span[:dropped_logs]
|
57
|
+
}
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def flush
|
62
|
+
@flush_signal << true
|
63
|
+
~@flush_response_signal
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
MIN_PERIOD_SECS = 1.5
|
68
|
+
MAX_PERIOD_SECS = 30.0
|
69
|
+
|
70
|
+
# When the process forks, reset the child. All data that was copied will be handled
|
71
|
+
# by the parent. Also, restart the thread since forking killed it
|
72
|
+
def reset_on_fork
|
73
|
+
if @pid != $$
|
74
|
+
@pid = $$
|
75
|
+
@span_signal = Concurrent::Channel.new(buffer: :dropping, capacity: 1)
|
76
|
+
@quit_signal = Concurrent::Channel.new(buffer: :dropping, capacity: 1)
|
77
|
+
@flush_signal = Concurrent::Channel.new
|
78
|
+
@flush_response_signal = Concurrent::Channel.new
|
79
|
+
@span_records.clear
|
80
|
+
@dropped_spans.value = 0
|
81
|
+
@dropped_span_logs.value = 0
|
82
|
+
report_spans
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def perform_flush
|
87
|
+
reset_on_fork
|
88
|
+
return if @span_records.empty?
|
89
|
+
|
90
|
+
now = LightStep.micros(Time.now)
|
91
|
+
|
92
|
+
span_records = @span_records.slice!(0, @span_records.length)
|
93
|
+
dropped_spans = 0
|
94
|
+
@dropped_spans.update{|old| dropped_spans = old; 0 }
|
95
|
+
|
96
|
+
old_dropped_span_logs = 0
|
97
|
+
@dropped_span_logs.update{|old| old_dropped_span_logs = old; 0 }
|
98
|
+
dropped_logs = old_dropped_span_logs
|
99
|
+
dropped_logs = span_records.reduce(dropped_logs) do |memo, span|
|
100
|
+
memo += span.delete :dropped_logs
|
101
|
+
end
|
102
|
+
|
103
|
+
report_request = {
|
104
|
+
runtime: @runtime,
|
105
|
+
oldest_micros: @report_start_time,
|
106
|
+
youngest_micros: now,
|
107
|
+
span_records: span_records,
|
108
|
+
counters: [
|
109
|
+
{Name: "dropped_logs", Value: dropped_logs},
|
110
|
+
{Name: "dropped_spans", Value: dropped_spans},
|
111
|
+
]
|
112
|
+
}
|
113
|
+
|
114
|
+
@report_start_time = now
|
115
|
+
|
116
|
+
begin
|
117
|
+
@transport.report(report_request)
|
118
|
+
rescue
|
119
|
+
# an error occurs, add the previous dropped logs to the logs
|
120
|
+
# that were going to get reported, as well as the previous dropped
|
121
|
+
# spans and spans that would have been recorded
|
122
|
+
@dropped_spans.increment(dropped_spans + span_records.length)
|
123
|
+
@dropped_span_logs.increment(old_dropped_span_logs)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def report_spans
|
128
|
+
@thread = Thread.new do
|
129
|
+
begin
|
130
|
+
loop do
|
131
|
+
min_reached = false
|
132
|
+
max_reached = false
|
133
|
+
min_timer = Concurrent::Channel.timer(MIN_PERIOD_SECS)
|
134
|
+
max_timer = Concurrent::Channel.timer(MAX_PERIOD_SECS)
|
135
|
+
loop do
|
136
|
+
Concurrent::Channel.select do |s|
|
137
|
+
s.take(@span_signal) do
|
138
|
+
# we'll check span count below
|
139
|
+
end
|
140
|
+
s.take(min_timer) do
|
141
|
+
min_reached = true
|
142
|
+
end
|
143
|
+
s.take(max_timer) do
|
144
|
+
max_reached = true
|
145
|
+
end
|
146
|
+
s.take(@quit_signal) do
|
147
|
+
perform_flush
|
148
|
+
Thread.exit
|
149
|
+
end
|
150
|
+
s.take(@flush_signal) do
|
151
|
+
perform_flush
|
152
|
+
@flush_response_signal << true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
if max_reached || (min_reached && @span_records.size >= max_span_records / 2)
|
156
|
+
perform_flush
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
rescue => ex
|
161
|
+
# TODO: internally log the exception
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
data/lib/lightstep/tracer.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'concurrent'
|
3
3
|
|
4
4
|
require 'lightstep/span'
|
5
|
+
require 'lightstep/reporter'
|
5
6
|
require 'lightstep/transport/http_json'
|
6
7
|
require 'lightstep/transport/nil'
|
7
8
|
require 'lightstep/transport/callback'
|
@@ -11,16 +12,6 @@ module LightStep
|
|
11
12
|
FORMAT_TEXT_MAP = 1
|
12
13
|
FORMAT_BINARY = 2
|
13
14
|
|
14
|
-
CARRIER_TRACER_STATE_PREFIX = 'ot-tracer-'.freeze
|
15
|
-
CARRIER_BAGGAGE_PREFIX = 'ot-baggage-'.freeze
|
16
|
-
|
17
|
-
DEFAULT_MAX_LOG_RECORDS = 1000
|
18
|
-
MIN_MAX_LOG_RECORDS = 1
|
19
|
-
DEFAULT_MAX_SPAN_RECORDS = 1000
|
20
|
-
MIN_MAX_SPAN_RECORDS = 1
|
21
|
-
DEFAULT_MIN_REPORTING_PERIOD_SECS = 1.5
|
22
|
-
DEFAULT_MAX_REPORTING_PERIOD_SECS = 30.0
|
23
|
-
|
24
15
|
class Error < LightStep::Error; end
|
25
16
|
class ConfigurationError < LightStep::Tracer::Error; end
|
26
17
|
|
@@ -51,22 +42,7 @@ module LightStep
|
|
51
42
|
|
52
43
|
def max_span_records=(max)
|
53
44
|
@max_span_records = [MIN_MAX_SPAN_RECORDS, max].max
|
54
|
-
|
55
|
-
|
56
|
-
def min_flush_period_micros
|
57
|
-
@min_flush_period_micros ||= DEFAULT_MIN_REPORTING_PERIOD_SECS * 1E6
|
58
|
-
end
|
59
|
-
|
60
|
-
def min_reporting_period_secs=(secs)
|
61
|
-
@min_flush_period_micros = [DEFAULT_MIN_REPORTING_PERIOD_SECS, secs].max * 1E6
|
62
|
-
end
|
63
|
-
|
64
|
-
def max_flush_period_micros
|
65
|
-
@max_flush_period_micros ||= DEFAULT_MAX_REPORTING_PERIOD_SECS * 1E6
|
66
|
-
end
|
67
|
-
|
68
|
-
def max_reporting_period_secs=(secs)
|
69
|
-
@max_flush_period_micros = [DEFAULT_MAX_REPORTING_PERIOD_SECS, secs].min * 1E6
|
45
|
+
@reporter.max_span_records = @max_span_records
|
70
46
|
end
|
71
47
|
|
72
48
|
# TODO(ngauthier@gmail.com) inherit SpanContext from references
|
@@ -146,93 +122,50 @@ module LightStep
|
|
146
122
|
# @param discard [Boolean] whether to discard queued data
|
147
123
|
def disable(discard: true)
|
148
124
|
@enabled = false
|
149
|
-
@
|
150
|
-
@
|
125
|
+
@reporter.clear if discard
|
126
|
+
@reporter.flush
|
151
127
|
end
|
152
128
|
|
153
129
|
# Flush to the Transport
|
154
130
|
def flush
|
155
|
-
|
131
|
+
return unless enabled?
|
132
|
+
@reporter.flush
|
156
133
|
end
|
157
134
|
|
158
135
|
# Internal use only.
|
159
136
|
# @private
|
160
137
|
def finish_span(span)
|
161
138
|
return unless enabled?
|
162
|
-
@
|
163
|
-
if @span_records.size > max_span_records
|
164
|
-
@span_records.shift
|
165
|
-
@dropped_spans.increment
|
166
|
-
@dropped_span_logs.increment(span.logs_count + span.dropped_logs_count)
|
167
|
-
end
|
168
|
-
flush_if_needed
|
139
|
+
@reporter.add_span(span)
|
169
140
|
end
|
170
141
|
|
171
142
|
protected
|
172
143
|
|
173
|
-
def access_token=(token)
|
174
|
-
if !access_token.nil?
|
175
|
-
raise ConfigurationError, "access token cannot be changed"
|
176
|
-
end
|
177
|
-
@access_token = token
|
178
|
-
end
|
179
|
-
|
180
144
|
def configure(component_name:, access_token: nil, transport: nil)
|
181
145
|
raise ConfigurationError, "component_name must be a string" unless String === component_name
|
182
146
|
raise ConfigurationError, "component_name cannot be blank" if component_name.empty?
|
183
147
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
start_time = LightStep.micros(Time.now)
|
189
|
-
@guid = LightStep.guid
|
190
|
-
@report_start_time = start_time
|
191
|
-
@last_flush_micros = start_time
|
148
|
+
transport = Transport::HTTPJSON.new(access_token: access_token) if !access_token.nil?
|
149
|
+
raise ConfigurationError, "you must provide an access token or a transport" if transport.nil?
|
150
|
+
raise ConfigurationError, "#{transport} is not a LightStep transport class" if !(LightStep::Transport::Base === transport)
|
192
151
|
|
193
|
-
@
|
152
|
+
@reporter = LightStep::Reporter.new(
|
153
|
+
max_span_records: max_span_records,
|
154
|
+
transport: transport,
|
194
155
|
guid: guid,
|
195
|
-
|
196
|
-
|
197
|
-
attrs: [
|
198
|
-
{Key: "lightstep.tracer_platform", Value: "ruby"},
|
199
|
-
{Key: "lightstep.tracer_version", Value: LightStep::VERSION},
|
200
|
-
{Key: "lightstep.tracer_platform_version", Value: RUBY_VERSION}
|
201
|
-
]
|
202
|
-
}.freeze
|
203
|
-
|
204
|
-
if !transport.nil?
|
205
|
-
if !(LightStep::Transport::Base === transport)
|
206
|
-
raise ConfigurationError, "transport is not a LightStep transport class: #{transport}"
|
207
|
-
end
|
208
|
-
@transport = transport
|
209
|
-
else
|
210
|
-
if access_token.nil?
|
211
|
-
raise ConfigurationError, "you must provide an access token or a transport"
|
212
|
-
end
|
213
|
-
@transport = Transport::HTTPJSON.new(access_token: access_token)
|
214
|
-
end
|
215
|
-
|
216
|
-
# At exit, flush this objects data to the transport and close the transport
|
217
|
-
# (which in turn will send the flushed data over the network).
|
218
|
-
at_exit do
|
219
|
-
flush
|
220
|
-
@transport.close
|
221
|
-
end
|
156
|
+
component_name: component_name
|
157
|
+
)
|
222
158
|
end
|
223
159
|
|
224
|
-
|
225
|
-
return unless enabled?
|
226
|
-
|
227
|
-
delta = LightStep.micros(Time.now) - @last_flush_micros
|
228
|
-
return if delta < min_flush_period_micros
|
160
|
+
private
|
229
161
|
|
230
|
-
|
231
|
-
|
232
|
-
end
|
233
|
-
end
|
162
|
+
CARRIER_TRACER_STATE_PREFIX = 'ot-tracer-'.freeze
|
163
|
+
CARRIER_BAGGAGE_PREFIX = 'ot-baggage-'.freeze
|
234
164
|
|
235
|
-
|
165
|
+
DEFAULT_MAX_LOG_RECORDS = 1000
|
166
|
+
MIN_MAX_LOG_RECORDS = 1
|
167
|
+
DEFAULT_MAX_SPAN_RECORDS = 1000
|
168
|
+
MIN_MAX_SPAN_RECORDS = 1
|
236
169
|
|
237
170
|
def inject_to_text_map(span, carrier)
|
238
171
|
carrier[CARRIER_TRACER_STATE_PREFIX + 'spanid'] = span.guid
|
@@ -261,50 +194,5 @@ module LightStep
|
|
261
194
|
end
|
262
195
|
span
|
263
196
|
end
|
264
|
-
|
265
|
-
def _flush_worker
|
266
|
-
return unless enabled?
|
267
|
-
# The thrift configuration has not yet been set: allow logs and spans
|
268
|
-
# to be buffered in this case, but flushes won't yet be possible.
|
269
|
-
return if @runtime.nil?
|
270
|
-
return if @span_records.empty?
|
271
|
-
|
272
|
-
now = LightStep.micros(Time.now)
|
273
|
-
|
274
|
-
span_records = @span_records.slice!(0, @span_records.length)
|
275
|
-
dropped_spans = 0
|
276
|
-
@dropped_spans.update{|old| dropped_spans = old; 0 }
|
277
|
-
|
278
|
-
old_dropped_span_logs = 0
|
279
|
-
@dropped_span_logs.update{|old| old_dropped_span_logs = old; 0 }
|
280
|
-
dropped_logs = old_dropped_span_logs
|
281
|
-
dropped_logs = span_records.reduce(dropped_logs) do |memo, span|
|
282
|
-
memo += span.delete :dropped_logs
|
283
|
-
end
|
284
|
-
|
285
|
-
report_request = {
|
286
|
-
runtime: @runtime,
|
287
|
-
oldest_micros: @report_start_time,
|
288
|
-
youngest_micros: now,
|
289
|
-
span_records: span_records,
|
290
|
-
counters: [
|
291
|
-
{Name: "dropped_logs", Value: dropped_logs},
|
292
|
-
{Name: "dropped_spans", Value: dropped_spans},
|
293
|
-
]
|
294
|
-
}
|
295
|
-
|
296
|
-
@last_flush_micros = now
|
297
|
-
@report_start_time = now
|
298
|
-
|
299
|
-
begin
|
300
|
-
@transport.report(report_request)
|
301
|
-
rescue LightStep::Transport::HTTPJSON::QueueFullError
|
302
|
-
# If the queue is full, add the previous dropped logs to the logs
|
303
|
-
# that were going to get reported, as well as the previous dropped
|
304
|
-
# spans and spans that would have been recorded
|
305
|
-
@dropped_spans.increment(dropped_spans + span_records.length)
|
306
|
-
@dropped_span_logs.increment(old_dropped_span_logs)
|
307
|
-
end
|
308
|
-
end
|
309
197
|
end
|
310
198
|
end
|
@@ -13,18 +13,15 @@ module LightStep
|
|
13
13
|
class HTTPJSON < Base
|
14
14
|
LIGHTSTEP_HOST = "collector.lightstep.com"
|
15
15
|
LIGHTSTEP_PORT = 443
|
16
|
-
QUEUE_SIZE = 16
|
17
16
|
|
18
17
|
ENCRYPTION_TLS = 'tls'
|
19
18
|
ENCRYPTION_NONE = 'none'
|
20
19
|
|
21
|
-
class QueueFullError < LightStep::Error; end
|
22
|
-
|
23
20
|
# Initialize the transport
|
24
21
|
# @param host [String] host of the domain to the endpoind to push data
|
25
22
|
# @param port [Numeric] port on which to connect
|
26
23
|
# @param verbose [Numeric] verbosity level. Right now 0-3 are supported
|
27
|
-
# @param
|
24
|
+
# @param encryption [ENCRYPTION_TLS, ENCRYPTION_NONE] kind of encryption to use
|
28
25
|
# @param access_token [String] access token for LightStep server
|
29
26
|
# @return [HTTPJSON]
|
30
27
|
def initialize(host: LIGHTSTEP_HOST, port: LIGHTSTEP_PORT, verbose: 0, encryption: ENCRYPTION_TLS, access_token:)
|
@@ -36,75 +33,24 @@ module LightStep
|
|
36
33
|
raise ConfigurationError, "access_token must be a string" unless String === access_token
|
37
34
|
raise ConfigurationError, "access_token cannot be blank" if access_token.empty?
|
38
35
|
@access_token = access_token
|
39
|
-
|
40
|
-
start_queue
|
41
36
|
end
|
42
37
|
|
43
38
|
# Queue a report for sending
|
44
39
|
def report(report)
|
45
40
|
p report if @verbose >= 3
|
46
|
-
# TODO(ngauthier@gmail.com): the queue could be full here if we're
|
47
|
-
# lagging, which would cause this to block!
|
48
|
-
@queue.push({
|
49
|
-
host: @host,
|
50
|
-
port: @port,
|
51
|
-
encryption: @encryption,
|
52
|
-
access_token: @access_token,
|
53
|
-
content: report,
|
54
|
-
verbose: @verbose
|
55
|
-
}, true)
|
56
|
-
nil
|
57
|
-
rescue ThreadError
|
58
|
-
raise QueueFullError
|
59
|
-
end
|
60
|
-
|
61
|
-
# Flush the current queue
|
62
|
-
def flush
|
63
|
-
close
|
64
|
-
start_queue
|
65
|
-
end
|
66
|
-
|
67
|
-
# Clear the current queue, deleting pending items
|
68
|
-
def clear
|
69
|
-
@queue.clear
|
70
|
-
end
|
71
41
|
|
72
|
-
|
73
|
-
|
74
|
-
@queue.close
|
75
|
-
@thread.join
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def start_queue
|
81
|
-
@queue = SizedQueue.new(QUEUE_SIZE)
|
82
|
-
@thread = start_thread(@queue)
|
83
|
-
end
|
84
|
-
|
85
|
-
# TODO(ngauthier@gmail.com) abort on exception?
|
86
|
-
def start_thread(queue)
|
87
|
-
Thread.new do
|
88
|
-
while item = queue.pop
|
89
|
-
post_report(item)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def post_report(params)
|
95
|
-
https = Net::HTTP.new(params[:host], params[:port])
|
96
|
-
https.use_ssl = params[:encryption] == ENCRYPTION_TLS
|
42
|
+
https = Net::HTTP.new(@host, @port)
|
43
|
+
https.use_ssl = @encryption == ENCRYPTION_TLS
|
97
44
|
req = Net::HTTP::Post.new('/api/v0/reports')
|
98
|
-
req['LightStep-Access-Token'] =
|
45
|
+
req['LightStep-Access-Token'] = @access_token
|
99
46
|
req['Content-Type'] = 'application/json'
|
100
47
|
req['Connection'] = 'keep-alive'
|
101
|
-
req.body =
|
48
|
+
req.body = report.to_json
|
102
49
|
res = https.request(req)
|
103
50
|
|
104
|
-
puts res.to_s if
|
51
|
+
puts res.to_s if @verbose >= 3
|
105
52
|
|
106
|
-
|
107
|
-
# TODO(ngauthier@gmail.com): log errors from server
|
53
|
+
nil
|
108
54
|
end
|
109
55
|
end
|
110
56
|
end
|
data/lib/lightstep/version.rb
CHANGED
data/lightstep.gemspec
CHANGED
@@ -16,9 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_dependency 'concurrent-ruby', '~> 1.0
|
20
|
-
spec.
|
21
|
-
spec.add_development_dependency '
|
19
|
+
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
20
|
+
spec.add_dependency 'concurrent-ruby-edge', '= 0.2.2'
|
21
|
+
spec.add_development_dependency 'rake', '~> 11.3'
|
22
|
+
spec.add_development_dependency 'rack', '~> 2.0'
|
22
23
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
spec.add_development_dependency 'bump', '~> 0.5'
|
24
25
|
spec.add_development_dependency 'simplecov', '~> 0.12.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bcronin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -16,42 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: concurrent-ruby-edge
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 11.3
|
47
|
+
version: '11.3'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 11.3
|
54
|
+
version: '11.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rack
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0
|
61
|
+
version: '2.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0
|
68
|
+
version: '2.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ files:
|
|
132
146
|
- examples/rack/hello.rb
|
133
147
|
- lib/lightstep.rb
|
134
148
|
- lib/lightstep/global_tracer.rb
|
149
|
+
- lib/lightstep/reporter.rb
|
135
150
|
- lib/lightstep/span.rb
|
136
151
|
- lib/lightstep/tracer.rb
|
137
152
|
- lib/lightstep/transport/base.rb
|