Class: SplitIoClient::Engine::Common::ImpressionManager
- Inherits:
-
Object
- Object
- SplitIoClient::Engine::Common::ImpressionManager
- Defined in:
- lib/splitclient-rb/engine/common/impressions_manager.rb
Instance Method Summary collapse
- #build_impression(matching_key, bucketing_key, split_name, treatment, params = {}) ⇒ Object
-
#initialize(config, impressions_repository, impression_counter, telemetry_runtime_producer, impression_observer, unique_keys_tracker) ⇒ ImpressionManager
constructor
A new instance of ImpressionManager.
- #track(impressions) ⇒ Object
Constructor Details
#initialize(config, impressions_repository, impression_counter, telemetry_runtime_producer, impression_observer, unique_keys_tracker) ⇒ ImpressionManager
Returns a new instance of ImpressionManager.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/splitclient-rb/engine/common/impressions_manager.rb', line 7 def initialize(config, impressions_repository, impression_counter, telemetry_runtime_producer, impression_observer, unique_keys_tracker) @config = config @impressions_repository = impressions_repository @impression_counter = impression_counter @impression_observer = impression_observer @telemetry_runtime_producer = telemetry_runtime_producer @unique_keys_tracker = unique_keys_tracker end |
Instance Method Details
#build_impression(matching_key, bucketing_key, split_name, treatment, params = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/splitclient-rb/engine/common/impressions_manager.rb', line 21 def build_impression(matching_key, bucketing_key, split_name, treatment, params = {}) impression_data = impression_data(matching_key, bucketing_key, split_name, treatment, params[:time]) begin case @config.impressions_mode when :debug # In DEBUG mode we should calculate the pt only. impression_data[:pt] = @impression_observer.test_and_set(impression_data) when :none # In NONE mode we should track the total amount of evaluations and the unique keys. @impression_counter.inc(split_name, impression_data[:m]) @unique_keys_tracker.track(split_name, matching_key) else # In OPTIMIZED mode we should track the total amount of evaluations and deduplicate the impressions. impression_data[:pt] = @impression_observer.test_and_set(impression_data) @impression_counter.inc(split_name, impression_data[:m]) unless impression_data[:pt].nil? end rescue StandardError => e @config.log_found_exception(__method__.to_s, e) end impression(impression_data, params[:attributes]) end |
#track(impressions) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/splitclient-rb/engine/common/impressions_manager.rb', line 43 def track(impressions) return if impressions.empty? stats = { dropped: 0, queued: 0, dedupe: 0 } begin case @config.impressions_mode when :none return when :debug track_debug_mode(impressions, stats) when :optimized track_optimized_mode(impressions, stats) end rescue StandardError => e @config.log_found_exception(__method__.to_s, e) ensure record_stats(stats) impression_router.add_bulk(impressions) end end |