Class: MetricsProcessor

Inherits:
Closeable show all
Defined in:
lib/ff/ruby/server/sdk/api/metrics_processor.rb

Defined Under Namespace

Classes: FrequencyMap

Instance Method Summary collapse

Instance Method Details

#closeObject



107
108
109
110
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 107

def close
  stop
  @config.logger.debug "Closing metrics processor"
end

#init(connector, config, callback) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 46

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
  @global_target = Target.new("RubySDK1", identifier = @global_target_identifier, name = @global_target_name)
  @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"

  @executor = Concurrent::FixedThreadPool.new(10)

  @evaluation_metrics = FrequencyMap.new
  @target_metrics = Concurrent::Map.new

  # Keep track of targets that have already been sent to avoid sending them again
  @seen_targets = Concurrent::Map.new

  @max_buffer_size = config.buffer_size - 1

  # Max 100k targets per interval
  @max_targets_buffer_size = 100000

  @evaluation_warning_issued = Concurrent::AtomicBoolean.new
  @target_warning_issued = Concurrent::AtomicBoolean.new

  @callback.on_metrics_ready
end

#register_evaluation(target, feature_config, variation) ⇒ Object



112
113
114
115
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 112

def register_evaluation(target, feature_config, variation)
  register_evaluation_metric(feature_config, variation)
  register_target_metric(target)
end

#startObject



97
98
99
100
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 97

def start
  @config.logger.debug "Starting metrics processor with request interval: " + @config.frequency.to_s
  start_async
end

#stopObject



102
103
104
105
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 102

def stop
  @config.logger.debug "Stopping metrics processor"
  stop_async
end