brainzlab 0.1.28 → 0.1.29
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/brainzlab/pulse/client.rb +16 -0
- data/lib/brainzlab/pulse/tracer.rb +2 -13
- data/lib/brainzlab/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: 66b1827b6976d4cc3f0b16536eda54ac36ebc3fdba1f49369d93089198a99d73
|
|
4
|
+
data.tar.gz: 6a5d234eb169b6401ff226fe0944006fc3fea60df64a574aeb86f98466fd7c7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e958e58fdf83b5b472e3353a3f14b5b8d8a39315942eb74668735a2faefef9413d561b06b511bfff63fe2f633e8261320d3a8a7a25cf269ff0454283bfe6e36
|
|
7
|
+
data.tar.gz: 7601dbd331048b5fc8dd184c218ce9605ef010efd47d5b51fbeee52506f692bd4bad768219a4b8ad95562e9e28a006696886643c492fae303008ae8ca8c2795f
|
|
@@ -20,6 +20,13 @@ module BrainzLab
|
|
|
20
20
|
def send_trace(payload)
|
|
21
21
|
return unless @config.pulse_enabled && @config.pulse_valid?
|
|
22
22
|
|
|
23
|
+
# Per-trace sampling — the single chokepoint every trace path funnels
|
|
24
|
+
# through (request middleware, jobs, sidekiq, delayed_job, grape, manual
|
|
25
|
+
# traces). Decided once per complete trace (spans travel inline in the
|
|
26
|
+
# payload, so they never orphan) and BEFORE buffering, so dropped traces
|
|
27
|
+
# never reach the buffer/batch. Error traces are always kept.
|
|
28
|
+
return unless keep_trace?(payload)
|
|
29
|
+
|
|
23
30
|
if @config.pulse_buffer_size > 1
|
|
24
31
|
buffer_trace(payload)
|
|
25
32
|
else
|
|
@@ -61,6 +68,15 @@ module BrainzLab
|
|
|
61
68
|
|
|
62
69
|
private
|
|
63
70
|
|
|
71
|
+
# Keep error traces always; otherwise keep with probability = the
|
|
72
|
+
# effective per-tier sample rate (internal=0.1, standard=0.5, client=1.0).
|
|
73
|
+
def keep_trace?(payload)
|
|
74
|
+
return true if payload[:error] == true || payload['error'] == true
|
|
75
|
+
|
|
76
|
+
rate = @config.effective_pulse_sample_rate
|
|
77
|
+
rate >= 1.0 || rand < rate
|
|
78
|
+
end
|
|
79
|
+
|
|
64
80
|
def buffer_trace(payload)
|
|
65
81
|
should_flush = false
|
|
66
82
|
|
|
@@ -17,7 +17,6 @@ module BrainzLab
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def start_trace(name, kind: 'custom', **attributes)
|
|
20
|
-
sample_rate = @config.effective_pulse_sample_rate
|
|
21
20
|
trace = {
|
|
22
21
|
trace_id: SecureRandom.uuid,
|
|
23
22
|
name: name,
|
|
@@ -26,10 +25,6 @@ module BrainzLab
|
|
|
26
25
|
environment: @config.environment,
|
|
27
26
|
commit: @config.commit,
|
|
28
27
|
host: @config.host,
|
|
29
|
-
sample_rate: sample_rate,
|
|
30
|
-
# Per-trace sampling decision (atomic, so spans never orphan). Errors
|
|
31
|
-
# override this at finish_trace and are always kept.
|
|
32
|
-
sampled: sample_rate >= 1.0 || rand < sample_rate,
|
|
33
28
|
**attributes
|
|
34
29
|
}
|
|
35
30
|
|
|
@@ -43,14 +38,8 @@ module BrainzLab
|
|
|
43
38
|
trace = current_trace
|
|
44
39
|
return unless trace
|
|
45
40
|
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
unless error || trace.fetch(:sampled, true)
|
|
49
|
-
Thread.current[:brainzlab_pulse_trace] = nil
|
|
50
|
-
Thread.current[:brainzlab_pulse_spans] = nil
|
|
51
|
-
return
|
|
52
|
-
end
|
|
53
|
-
|
|
41
|
+
# Sampling is applied at the single send chokepoint (Pulse::Client#send_trace),
|
|
42
|
+
# which every trace path funnels through — so finish_trace just builds + sends.
|
|
54
43
|
ended_at = Time.now.utc
|
|
55
44
|
duration_ms = ((ended_at - trace[:started_at]) * 1000).round(2)
|
|
56
45
|
|
data/lib/brainzlab/version.rb
CHANGED