Class: MetricsProcessor
- Defined in:
- lib/ff/ruby/server/sdk/api/metrics_processor.rb
Instance Method Summary collapse
- #close ⇒ Object
- #init(connector, config, callback) ⇒ Object
- #register_evaluation(target, feature_name, variation_identifier) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Instance Method Details
#close ⇒ Object
74 75 76 77 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 74 def close stop @config.logger.debug "Closing metrics processor" end |
#init(connector, config, callback) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 12 def init(connector, config, callback) unless connector.kind_of?(Connector) raise "The 'connector' must be of '" + Connector.to_s + "' data type" end unless callback.kind_of?(MetricsCallback) raise "The 'callback' must be of '" + MetricsCallback.to_s + "' data type" end unless config.kind_of?(Config) raise "The 'config' must be of '" + Config.to_s + "' data type" end @config = config @callback = callback @connector = connector @sdk_type = "SDK_TYPE" @target_attribute = "target" @global_target_identifier = "__global__cf_target" # <--- This target identifier is used to aggregate and send data for all # targets as a summary @ready = false @jar_version = Ff::Ruby::Server::Sdk::VERSION @server = "server" @sdk_version = "SDK_VERSION" @sdk_language = "SDK_LANGUAGE" @global_target_name = "Global Target" @feature_name_attribute = "featureName" @variation_identifier_attribute = "variationIdentifier" # Evaluation and target metrics @metric_maps_mutex = Mutex.new @evaluation_metrics = {} @target_metrics = {} # Keep track of targets that have already been sent to avoid sending them again. We track a max 500K targets # to prevent unbounded growth. @seen_targets_mutex = Mutex.new @seen_targets = Set.new @max_seen_targets = 500000 @seen_targets_full = false # Mutex to protect aggregation and sending metrics at the end of an interval @send_data_mutex = Mutex.new @callback.on_metrics_ready end |
#register_evaluation(target, feature_name, variation_identifier) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 79 def register_evaluation(target, feature_name, variation_identifier) register_evaluation_metric(feature_name, variation_identifier) if target register_target_metric(target) end end |
#start ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 61 def start @config.logger.debug "Starting metrics processor with request interval: #{@config.frequency}" if @running @config.logger.warn "Metrics processor is already running." else start_async end end |
#stop ⇒ Object
69 70 71 72 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 69 def stop @config.logger.debug "Stopping metrics processor" stop_async end |