Class: Statsig::Diagnostics
- Inherits:
-
Object
- Object
- Statsig::Diagnostics
show all
- Extended by:
- T::Sig
- Defined in:
- lib/diagnostics.rb
Defined Under Namespace
Classes: Context, Tracker
Constant Summary
collapse
- API_CALL_KEYS =
%w[check_gate get_config get_experiment get_layer].freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(context) ⇒ Diagnostics
Returns a new instance of Diagnostics.
15
16
17
18
|
# File 'lib/diagnostics.rb', line 15
def initialize(context)
@context = context
@markers = []
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
10
11
12
|
# File 'lib/diagnostics.rb', line 10
def context
@context
end
|
#markers ⇒ Object
Returns the value of attribute markers.
13
14
15
|
# File 'lib/diagnostics.rb', line 13
def markers
@markers
end
|
Class Method Details
.sample(rate) ⇒ Object
72
73
74
|
# File 'lib/diagnostics.rb', line 72
def self.sample(rate)
rand(rate).zero?
end
|
Instance Method Details
#clear_markers ⇒ Object
68
69
70
|
# File 'lib/diagnostics.rb', line 68
def clear_markers
@markers.clear
end
|
#mark(key, action, step, tags) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/diagnostics.rb', line 29
def mark(key, action, step, tags)
marker = {
key: key,
action: action,
timestamp: (Time.now.to_f * 1000).to_i
}
if !step.nil?
marker[:step] = step
end
tags.each do |key, val|
unless val.nil?
marker[key] = val
end
end
@markers.push(marker)
end
|
#serialize ⇒ Object
61
62
63
64
65
66
|
# File 'lib/diagnostics.rb', line 61
def serialize
{
context: @context.clone,
markers: @markers.clone
}
end
|
#track(key, step = nil, tags = {}) ⇒ Object
53
54
55
56
57
|
# File 'lib/diagnostics.rb', line 53
def track(key, step = nil, tags = {})
tracker = Tracker.new(self, key, step, tags)
tracker.start(**tags)
tracker
end
|