bitfab 0.65.4 → 0.65.5
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/lib/bitfab/client.rb +9 -1
- data/lib/bitfab/http_client.rb +2 -2
- data/lib/bitfab/simulation_plan.rb +29 -11
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9c94aca223ea9794e110a16dae0e3e4f23ef45a2cf345c6bbaf396fc6b10b5f
|
|
4
|
+
data.tar.gz: 9c99a4266ec0109d155caeea5e1bb7792fb38c5e9d510e3552a2df60d192160a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa01c2d028e06cc338df64527d011df63e0a01dcec25559b4816523c951aed2b55ab0034075c7c09babec22d927bb4e5f0654456e82fd76e5d41815d0851fa30
|
|
7
|
+
data.tar.gz: 6f865c897e2ac1975c1b2a64cfbdf5c933f24356db7294e97a8ce11712cbf1937b942701c5237cd62dd79a68ae422dfaf46ed6eba3545e6c8522bdf0070831af
|
data/lib/bitfab/client.rb
CHANGED
|
@@ -58,7 +58,8 @@ module Bitfab
|
|
|
58
58
|
@resolved_api_key = nil
|
|
59
59
|
@api_key_warned = false
|
|
60
60
|
@http_client = HttpClient.new(api_key: -> { resolve_api_key }, service_url: @service_url, timeout:)
|
|
61
|
-
@http_client.configure_simulation_plan(enabled: simulation_plan, start: !api_key_resolved_lazily
|
|
61
|
+
@http_client.configure_simulation_plan(enabled: simulation_plan, start: !api_key_resolved_lazily?,
|
|
62
|
+
can_read: -> { simulation_plan_readable? })
|
|
62
63
|
@datasets = Datasets.new(@http_client)
|
|
63
64
|
@categories = Categories.new(@http_client)
|
|
64
65
|
@organization_members = OrganizationMembers.new(@http_client)
|
|
@@ -853,6 +854,13 @@ module Bitfab
|
|
|
853
854
|
!resolve_api_key.nil?
|
|
854
855
|
end
|
|
855
856
|
|
|
857
|
+
def simulation_plan_readable?
|
|
858
|
+
recording = capture_configured? || ReplayContext.current || SeedContext.current
|
|
859
|
+
recording && !lookup_api_key.nil?
|
|
860
|
+
rescue
|
|
861
|
+
false
|
|
862
|
+
end
|
|
863
|
+
|
|
856
864
|
def tracing_enabled?
|
|
857
865
|
return false unless capture_configured?
|
|
858
866
|
|
data/lib/bitfab/http_client.rb
CHANGED
|
@@ -56,8 +56,8 @@ module Bitfab
|
|
|
56
56
|
@close_condition = ConditionVariable.new
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def configure_simulation_plan(enabled: true, start: true)
|
|
60
|
-
@simulation_plan = SimulationPlan.new(self, enabled:)
|
|
59
|
+
def configure_simulation_plan(enabled: true, start: true, can_read: nil)
|
|
60
|
+
@simulation_plan = SimulationPlan.new(self, enabled:, can_read:)
|
|
61
61
|
@simulation_plan.refresh if start
|
|
62
62
|
@simulation_plan
|
|
63
63
|
end
|
|
@@ -42,9 +42,10 @@ module Bitfab
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def initialize(reader, enabled: true)
|
|
45
|
+
def initialize(reader, enabled: true, can_read: nil)
|
|
46
46
|
@reader = reader
|
|
47
47
|
@enabled = enabled
|
|
48
|
+
@can_read = can_read
|
|
48
49
|
@pid = Process.pid
|
|
49
50
|
@mutex = Mutex.new
|
|
50
51
|
@condition = ConditionVariable.new
|
|
@@ -56,25 +57,26 @@ module Bitfab
|
|
|
56
57
|
@stopped = false
|
|
57
58
|
@first_read_finished = false
|
|
58
59
|
@first_read_deadline = nil
|
|
60
|
+
@read_started = false
|
|
59
61
|
self.class.register(self)
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
def disabled?
|
|
63
|
-
|
|
65
|
+
switched_off? || (!@read_started && !readable?)
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
def refresh
|
|
67
69
|
reset_after_fork
|
|
68
|
-
return if disabled?
|
|
70
|
+
return if disabled?
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
refresh_for_record
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
def send_span(payload, declared_node: false, discard: nil, &submit)
|
|
74
|
-
|
|
76
|
+
refresh_for_record
|
|
75
77
|
data = payload.dig("rawSpan", "span_data")
|
|
76
78
|
key = payload["rootTraceFunctionKey"] || payload["traceFunctionKey"]
|
|
77
|
-
if
|
|
79
|
+
if switched_off? || key.nil? || !data.is_a?(Hash) || framework?(payload)
|
|
78
80
|
submit.call(payload)
|
|
79
81
|
return
|
|
80
82
|
end
|
|
@@ -84,11 +86,11 @@ module Bitfab
|
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
def send_trace(payload, &submit)
|
|
87
|
-
|
|
89
|
+
refresh_for_record
|
|
88
90
|
entry = [payload, nil, submit]
|
|
89
91
|
ready = @mutex.synchronize do
|
|
90
92
|
id = trace_id(payload)
|
|
91
|
-
if !
|
|
93
|
+
if !switched_off? && !@stopped && id && (@draining.include?(id) || @held.any? { |held| held[1] && trace_id(held[0]) == id })
|
|
92
94
|
hold(entry)
|
|
93
95
|
else
|
|
94
96
|
entry
|
|
@@ -172,6 +174,21 @@ module Bitfab
|
|
|
172
174
|
|
|
173
175
|
private
|
|
174
176
|
|
|
177
|
+
def refresh_for_record
|
|
178
|
+
reset_after_fork
|
|
179
|
+
return if switched_off? || @stopped
|
|
180
|
+
|
|
181
|
+
@mutex.synchronize { start_reader(0) if @thread.nil? && now >= @refresh_after }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def switched_off?
|
|
185
|
+
!@enabled || !ENV.fetch("BITFAB_DISABLE_SIM_PLAN", "").strip.empty?
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def readable?
|
|
189
|
+
@can_read.nil? || @can_read.call == true
|
|
190
|
+
end
|
|
191
|
+
|
|
175
192
|
def now
|
|
176
193
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
177
194
|
end
|
|
@@ -194,7 +211,7 @@ module Bitfab
|
|
|
194
211
|
|
|
195
212
|
def hold(entry)
|
|
196
213
|
@held << entry
|
|
197
|
-
start_reader([@refresh_after - now, 0].max) if @thread.nil? && !@stopped && !
|
|
214
|
+
start_reader([@refresh_after - now, 0].max) if @thread.nil? && !@stopped && !switched_off?
|
|
198
215
|
@held.shift if @held.length > MAX_HELD
|
|
199
216
|
end
|
|
200
217
|
|
|
@@ -210,7 +227,7 @@ module Bitfab
|
|
|
210
227
|
end
|
|
211
228
|
|
|
212
229
|
def prepare(payload, key)
|
|
213
|
-
return payload if key.nil? ||
|
|
230
|
+
return payload if key.nil? || switched_off?
|
|
214
231
|
return apply(payload, key) if @mutex.synchronize { @content_off }
|
|
215
232
|
|
|
216
233
|
without_unread_content(payload)
|
|
@@ -232,6 +249,7 @@ module Bitfab
|
|
|
232
249
|
end
|
|
233
250
|
|
|
234
251
|
def start_reader(delay)
|
|
252
|
+
@read_started = true
|
|
235
253
|
@first_read_deadline ||= now + delay + READ_TIMEOUT
|
|
236
254
|
@thread = Thread.new { read_until_loaded(delay) }
|
|
237
255
|
@thread.name = "bitfab-sim-plan"
|
|
@@ -270,7 +288,7 @@ module Bitfab
|
|
|
270
288
|
|
|
271
289
|
def read_until_loaded(delay)
|
|
272
290
|
pause(delay) if delay.positive?
|
|
273
|
-
parsed = (
|
|
291
|
+
parsed = (switched_off? || @stopped) ? nil : read_once
|
|
274
292
|
entries = @mutex.synchronize do
|
|
275
293
|
@first_read_finished = true
|
|
276
294
|
@content_off = parsed if parsed
|
data/lib/bitfab/version.rb
CHANGED