Class: SplitIoClient::Telemetry::Storages::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/telemetry/storages/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 22

def initialize
  init_latencies
  init_exceptions
  init_factory_counters
  init_impressions_data_records
  init_events_data_records
  init_last_synchronization
  init_http_errors
  init_http_latencies
  init_auth_rejections
  init_token_refreshes
  init_streaming_events
  init_session_length
  init_tags
  init_updates_from_sse
end

Instance Attribute Details

#auth_rejectionsObject (readonly)

Returns the value of attribute auth_rejections.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def auth_rejections
  @auth_rejections
end

#events_data_recordsObject (readonly)

Returns the value of attribute events_data_records.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def events_data_records
  @events_data_records
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def exceptions
  @exceptions
end

#factory_countersObject (readonly)

Returns the value of attribute factory_counters.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def factory_counters
  @factory_counters
end

#http_errorsObject (readonly)

Returns the value of attribute http_errors.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def http_errors
  @http_errors
end

#http_latenciesObject (readonly)

Returns the value of attribute http_latencies.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def http_latencies
  @http_latencies
end

#impressions_data_recordsObject (readonly)

Returns the value of attribute impressions_data_records.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def impressions_data_records
  @impressions_data_records
end

#last_synchronizationObject (readonly)

Returns the value of attribute last_synchronization.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def last_synchronization
  @last_synchronization
end

#latenciesObject (readonly)

Returns the value of attribute latencies.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def latencies
  @latencies
end

#session_lengthObject (readonly)

Returns the value of attribute session_length.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def session_length
  @session_length
end

#streaming_eventsObject (readonly)

Returns the value of attribute streaming_events.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def streaming_events
  @streaming_events
end

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def tags
  @tags
end

#token_refreshesObject (readonly)

Returns the value of attribute token_refreshes.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def token_refreshes
  @token_refreshes
end

#updates_from_sseObject (readonly)

Returns the value of attribute updates_from_sse.



7
8
9
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 7

def updates_from_sse
  @updates_from_sse
end

Instance Method Details

#init_auth_rejectionsObject



135
136
137
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 135

def init_auth_rejections
  @auth_rejections = Concurrent::AtomicFixnum.new(0)
end

#init_events_data_recordsObject



87
88
89
90
91
92
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 87

def init_events_data_records
  @events_data_records = Concurrent::Array.new

  @events_data_records << { type: Domain::Constants::EVENTS_DROPPED, value: Concurrent::AtomicFixnum.new(0) }
  @events_data_records << { type: Domain::Constants::EVENTS_QUEUED, value: Concurrent::AtomicFixnum.new(0) }
end

#init_exceptionsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 56

def init_exceptions
  @exceptions = Concurrent::Array.new
  treatment_with_config_by_flag_set_const = Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET
  treatment_with_config_by_flag_sets_const = Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS

  @exceptions << { method: Domain::Constants::TREATMENT, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TREATMENTS, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TREATMENT_WITH_CONFIG, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TREATMENTS_WITH_CONFIG, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TREATMENTS_BY_FLAG_SET, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TREATMENTS_BY_FLAG_SETS, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: treatment_with_config_by_flag_set_const, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: treatment_with_config_by_flag_sets_const, exceptions: Concurrent::AtomicFixnum.new(0) }
  @exceptions << { method: Domain::Constants::TRACK, exceptions: Concurrent::AtomicFixnum.new(0) }
end

#init_factory_countersObject



72
73
74
75
76
77
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 72

def init_factory_counters
  @factory_counters = Concurrent::Array.new

  @factory_counters << { action: Domain::Constants::BUR_TIMEOUT, counts: Concurrent::AtomicFixnum.new(0) }
  @factory_counters << { action: Domain::Constants::NON_READY_USAGES, counts: Concurrent::AtomicFixnum.new(0) }
end

#init_http_errorsObject



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 110

def init_http_errors
  @http_errors = Concurrent::Array.new

  @http_errors << { type: Domain::Constants::SPLIT_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::SEGMENT_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::EVENT_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::IMPRESSION_COUNT_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::IMPRESSIONS_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::TELEMETRY_SYNC, value: Concurrent::Hash.new }
  @http_errors << { type: Domain::Constants::TOKEN_SYNC, value: Concurrent::Hash.new }
end

#init_http_latenciesObject



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 122

def init_http_latencies
  @http_latencies = Concurrent::Array.new

  array_size = BinarySearchLatencyTracker::BUCKETS.length
  @http_latencies << { type: Domain::Constants::SPLIT_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::SEGMENT_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::EVENT_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::IMPRESSION_COUNT_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::IMPRESSIONS_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::TELEMETRY_SYNC, value: Concurrent::Array.new(array_size, 0) }
  @http_latencies << { type: Domain::Constants::TOKEN_SYNC, value: Concurrent::Array.new(array_size, 0) }
end

#init_impressions_data_recordsObject



79
80
81
82
83
84
85
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 79

def init_impressions_data_records
  @impressions_data_records = Concurrent::Array.new

  @impressions_data_records << { type: Domain::Constants::IMPRESSIONS_DEDUPE, value: Concurrent::AtomicFixnum.new(0) }
  @impressions_data_records << { type: Domain::Constants::IMPRESSIONS_DROPPED, value: Concurrent::AtomicFixnum.new(0) }
  @impressions_data_records << { type: Domain::Constants::IMPRESSIONS_QUEUED, value: Concurrent::AtomicFixnum.new(0) }
end

#init_last_synchronizationObject



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 94

def init_last_synchronization
  @last_synchronization = Concurrent::Array.new

  @last_synchronization << { type: Domain::Constants::SPLIT_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::SEGMENT_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::EVENT_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::IMPRESSION_COUNT_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::IMPRESSIONS_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::TELEMETRY_SYNC, value: Concurrent::AtomicFixnum.new(0) }
  @last_synchronization << { type: Domain::Constants::TOKEN_SYNC, value: Concurrent::AtomicFixnum.new(0) }
end

#init_latenciesObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 39

def init_latencies
  @latencies = Concurrent::Array.new
  treatment_with_config_by_flag_set_const = Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET
  treatment_with_config_by_flag_sets_const = Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS

  array_size = BinarySearchLatencyTracker::BUCKETS.length
  @latencies << { method: Domain::Constants::TREATMENT, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TREATMENTS, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TREATMENT_WITH_CONFIG, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TREATMENTS_WITH_CONFIG, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TREATMENTS_BY_FLAG_SET, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TREATMENTS_BY_FLAG_SETS, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: treatment_with_config_by_flag_set_const, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: treatment_with_config_by_flag_sets_const, latencies: Concurrent::Array.new(array_size, 0) }
  @latencies << { method: Domain::Constants::TRACK, latencies: Concurrent::Array.new(array_size, 0) }
end

#init_session_lengthObject



147
148
149
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 147

def init_session_length
  @session_length = Concurrent::AtomicFixnum.new(0)
end

#init_streaming_eventsObject



143
144
145
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 143

def init_streaming_events
  @streaming_events = Concurrent::Array.new
end

#init_tagsObject



106
107
108
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 106

def init_tags
  @tags = Concurrent::Array.new
end

#init_token_refreshesObject



139
140
141
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 139

def init_token_refreshes
  @token_refreshes = Concurrent::AtomicFixnum.new(0)
end

#init_updates_from_sseObject



151
152
153
154
155
# File 'lib/splitclient-rb/telemetry/storages/memory.rb', line 151

def init_updates_from_sse
  @updates_from_sse = Concurrent::Hash.new

  @updates_from_sse[Domain::Constants::SPLITS] = 0
end