lightstep 0.9.8 → 0.9.9
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/benchmark/threading/thread_test.rb +1 -0
- data/example.rb +1 -1
- data/examples/fork_children/main.rb +3 -0
- data/lib/lightstep/reporter.rb +24 -63
- data/lib/lightstep/tracer.rb +6 -0
- data/lib/lightstep/version.rb +1 -1
- data/lightstep.gemspec +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d77e4a3fbc58434184011abfd31e4c323af79615
|
4
|
+
data.tar.gz: 4cd3e0df3b6f019633e6c2f581a42122cdba81cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da86124b4d723ee69d538cae3139c4ddf3d3dbe08918122d52638e75000eb98e56b125383c555db2033d64cb9dd2daa39f2ec80b45dc43f00703294488cee1b7
|
7
|
+
data.tar.gz: 2bc31803d7967cf329764aace93653f851a53b88fd4801a3852f71dafdc5a114d71b3d1a1d28f250aa67aee24a96dc277a3e05e5895737e264afe84296e38423
|
data/example.rb
CHANGED
data/lib/lightstep/reporter.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'concurrent/channel'
|
2
|
-
|
3
1
|
module LightStep
|
4
2
|
# Reporter builds up reports of spans and flushes them to a transport
|
5
3
|
class Reporter
|
4
|
+
DEFAULT_PERIOD_SECONDS = 3.0
|
6
5
|
attr_accessor :max_span_records
|
6
|
+
attr_accessor :period
|
7
7
|
|
8
8
|
def initialize(max_span_records:, transport:, guid:, component_name:)
|
9
9
|
@max_span_records = max_span_records
|
@@ -11,6 +11,7 @@ module LightStep
|
|
11
11
|
@dropped_spans = Concurrent::AtomicFixnum.new
|
12
12
|
@dropped_span_logs = Concurrent::AtomicFixnum.new
|
13
13
|
@transport = transport
|
14
|
+
@period = DEFAULT_PERIOD_SECONDS
|
14
15
|
|
15
16
|
start_time = LightStep.micros(Time.now)
|
16
17
|
@report_start_time = start_time
|
@@ -27,11 +28,6 @@ module LightStep
|
|
27
28
|
}.freeze
|
28
29
|
|
29
30
|
reset_on_fork
|
30
|
-
|
31
|
-
at_exit do
|
32
|
-
@quit_signal << true
|
33
|
-
@thread.join
|
34
|
-
end
|
35
31
|
end
|
36
32
|
|
37
33
|
def add_span(span)
|
@@ -43,11 +39,11 @@ module LightStep
|
|
43
39
|
@dropped_spans.increment
|
44
40
|
@dropped_span_logs.increment(dropped[:log_records].size + dropped[:dropped_logs])
|
45
41
|
end
|
46
|
-
|
47
|
-
@span_signal << true
|
48
42
|
end
|
49
43
|
|
50
44
|
def clear
|
45
|
+
reset_on_fork
|
46
|
+
|
51
47
|
span_records = @span_records.slice!(0, @span_records.length)
|
52
48
|
@dropped_spans.increment(span_records.size)
|
53
49
|
@dropped_span_logs.increment(
|
@@ -58,32 +54,8 @@ module LightStep
|
|
58
54
|
end
|
59
55
|
|
60
56
|
def flush
|
61
|
-
@flush_signal << true
|
62
|
-
~@flush_response_signal
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
MIN_PERIOD_SECS = 1.5
|
67
|
-
MAX_PERIOD_SECS = 30.0
|
68
|
-
|
69
|
-
# When the process forks, reset the child. All data that was copied will be handled
|
70
|
-
# by the parent. Also, restart the thread since forking killed it
|
71
|
-
def reset_on_fork
|
72
|
-
if @pid != $$
|
73
|
-
@pid = $$
|
74
|
-
@span_signal = Concurrent::Channel.new(buffer: :dropping, capacity: 1)
|
75
|
-
@quit_signal = Concurrent::Channel.new(buffer: :dropping, capacity: 1)
|
76
|
-
@flush_signal = Concurrent::Channel.new
|
77
|
-
@flush_response_signal = Concurrent::Channel.new
|
78
|
-
@span_records.clear
|
79
|
-
@dropped_spans.value = 0
|
80
|
-
@dropped_span_logs.value = 0
|
81
|
-
report_spans
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def perform_flush
|
86
57
|
reset_on_fork
|
58
|
+
|
87
59
|
return if @span_records.empty?
|
88
60
|
|
89
61
|
now = LightStep.micros(Time.now)
|
@@ -123,38 +95,27 @@ module LightStep
|
|
123
95
|
end
|
124
96
|
end
|
125
97
|
|
98
|
+
private
|
99
|
+
|
100
|
+
# When the process forks, reset the child. All data that was copied will be handled
|
101
|
+
# by the parent. Also, restart the thread since forking killed it
|
102
|
+
def reset_on_fork
|
103
|
+
if @pid != $$
|
104
|
+
@pid = $$
|
105
|
+
@span_records.clear
|
106
|
+
@dropped_spans.value = 0
|
107
|
+
@dropped_span_logs.value = 0
|
108
|
+
report_spans
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
126
112
|
def report_spans
|
127
|
-
@
|
113
|
+
return if @period <= 0
|
114
|
+
Thread.new do
|
128
115
|
begin
|
129
116
|
loop do
|
130
|
-
|
131
|
-
|
132
|
-
min_timer = Concurrent::Channel.timer(MIN_PERIOD_SECS)
|
133
|
-
max_timer = Concurrent::Channel.timer(MAX_PERIOD_SECS)
|
134
|
-
loop do
|
135
|
-
Concurrent::Channel.select do |s|
|
136
|
-
s.take(@span_signal) do
|
137
|
-
# we'll check span count below
|
138
|
-
end
|
139
|
-
s.take(min_timer) do
|
140
|
-
min_reached = true
|
141
|
-
end
|
142
|
-
s.take(max_timer) do
|
143
|
-
max_reached = true
|
144
|
-
end
|
145
|
-
s.take(@quit_signal) do
|
146
|
-
perform_flush
|
147
|
-
Thread.exit
|
148
|
-
end
|
149
|
-
s.take(@flush_signal) do
|
150
|
-
perform_flush
|
151
|
-
@flush_response_signal << true
|
152
|
-
end
|
153
|
-
end
|
154
|
-
if max_reached || (min_reached && @span_records.size >= max_span_records / 2)
|
155
|
-
perform_flush
|
156
|
-
end
|
157
|
-
end
|
117
|
+
sleep(@period)
|
118
|
+
flush
|
158
119
|
end
|
159
120
|
rescue => ex
|
160
121
|
# TODO: internally log the exception
|
data/lib/lightstep/tracer.rb
CHANGED
@@ -45,6 +45,12 @@ module LightStep
|
|
45
45
|
@reporter.max_span_records = @max_span_records
|
46
46
|
end
|
47
47
|
|
48
|
+
# Set the report flushing period. If set to 0, no flushing will be done, you
|
49
|
+
# must manually call flush.
|
50
|
+
def report_period_seconds=(seconds)
|
51
|
+
@reporter.period = seconds
|
52
|
+
end
|
53
|
+
|
48
54
|
# TODO(ngauthier@gmail.com) inherit SpanContext from references
|
49
55
|
|
50
56
|
# Starts a new span.
|
data/lib/lightstep/version.rb
CHANGED
data/lightstep.gemspec
CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
19
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
20
|
-
spec.add_dependency 'concurrent-ruby-edge', '= 0.2.2'
|
21
20
|
spec.add_development_dependency 'rake', '~> 11.3'
|
22
21
|
spec.add_development_dependency 'rack', '~> 2.0'
|
23
22
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bcronin
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
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
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|