Class: MetricsProcessor
- Defined in:
- lib/ff/ruby/server/sdk/api/metrics_processor.rb
Constant Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #init(connector, config, callback) ⇒ Object
- #register_evaluation(target, feature_config, variation) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Instance Method Details
#close ⇒ Object
77 78 79 80 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 77 def close stop @config.logger.debug "Closing metrics processor" end |
#init(connector, config, callback) ⇒ Object
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 60 61 62 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 15 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_config, variation) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 82 def register_evaluation(target, feature_config, variation) register_evaluation_metric(feature_config, variation) if target register_target_metric(target) end end |
#start ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 64 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
72 73 74 75 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 72 def stop @config.logger.debug "Stopping metrics processor" stop_async end |