Class: Statsig::Diagnostics

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/diagnostics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Diagnostics

Returns a new instance of Diagnostics.



17
18
19
20
# File 'lib/diagnostics.rb', line 17

def initialize(context)
  @context = context
  @markers = []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



10
11
12
# File 'lib/diagnostics.rb', line 10

def context
  @context
end

#markersObject (readonly)

Returns the value of attribute markers.



13
14
15
# File 'lib/diagnostics.rb', line 13

def markers
  @markers
end

Instance Method Details

#mark(key, action, step = nil, value = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/diagnostics.rb', line 24

def mark(key, action, step = nil, value = nil)
  @markers.push({
                  key: key,
                  step: step,
                  action: action,
                  value: value,
                  timestamp: (Time.now.to_f * 1000).to_i
                })
end

#serializeObject



36
37
38
39
40
41
# File 'lib/diagnostics.rb', line 36

def serialize
  {
    context: @context,
    markers: @markers
  }
end