lightstep 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e17230ecc78ae73de113ba2db6b086fc007171d
4
- data.tar.gz: 01f13faeac326e6031884098fa445f16a19650d5
3
+ metadata.gz: d77e4a3fbc58434184011abfd31e4c323af79615
4
+ data.tar.gz: 4cd3e0df3b6f019633e6c2f581a42122cdba81cb
5
5
  SHA512:
6
- metadata.gz: bf53ed6852d161ad21d6b29d5f4ac28f22a83b7419a3dda1f461008e1af89604b6314ad83f66f37c353c6903eecbf704f732acae57f7ba59faf6662b28e160f6
7
- data.tar.gz: f239a8dc089f5b2a944ebf9134da3e17a91feee8c1b27e683e5907938883f178820d2c3a85e14c01e41cf63bff680ed082724e78f0d1d7d6ec344d5fe4cf125b
6
+ metadata.gz: da86124b4d723ee69d538cae3139c4ddf3d3dbe08918122d52638e75000eb98e56b125383c555db2033d64cb9dd2daa39f2ec80b45dc43f00703294488cee1b7
7
+ data.tar.gz: 2bc31803d7967cf329764aace93653f851a53b88fd4801a3852f71dafdc5a114d71b3d1a1d28f250aa67aee24a96dc277a3e05e5895737e264afe84296e38423
@@ -51,3 +51,4 @@ mutex.unlock
51
51
  watchThread.join
52
52
 
53
53
  puts 'Done!'
54
+ LightStep.flush
data/example.rb CHANGED
@@ -29,6 +29,6 @@ thread2 = Thread.new do
29
29
  end
30
30
  [thread1, thread2].each(&:join)
31
31
  span.finish
32
-
32
+ LightStep.flush
33
33
  puts 'Done!'
34
34
  puts "https://app.lightstep.com/#{access_token}/trace?span_guid=#{span.guid}&at_micros=#{span.start_micros}"
@@ -19,6 +19,7 @@ puts 'Starting...'
19
19
  sleep(0.0025 * rand(k))
20
20
  span.finish
21
21
  end
22
+ LightStep.flush
22
23
  end
23
24
 
24
25
  10.times do
@@ -47,3 +48,5 @@ puts 'Starting...'
47
48
  end
48
49
 
49
50
  puts 'Done!'
51
+
52
+ LightStep.flush
@@ -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
- @thread = Thread.new do
113
+ return if @period <= 0
114
+ Thread.new do
128
115
  begin
129
116
  loop do
130
- min_reached = false
131
- max_reached = false
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
@@ -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.
@@ -1,3 +1,3 @@
1
1
  module LightStep
2
- VERSION = '0.9.8'.freeze
2
+ VERSION = '0.9.9'.freeze
3
3
  end
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.8
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