Skip to content

Commit 17c2c80

Browse files
committed
FFM-12192 Only create global target once
1 parent e2fa8d9 commit 17c2c80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/ff/ruby/server/sdk/api/metrics_processor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
require_relative "../api/summary_metrics"
1010

1111
class MetricsProcessor < Closeable
12+
GLOBAL_TARGET = Target.new(identifier: "__global__cf_target", name: "Global Target").freeze
1213

1314
class FrequencyMap < Concurrent::Map
1415
def initialize(options = nil, &block)
@@ -66,7 +67,6 @@ def init(connector, config, callback)
6667
@target_attribute = "target"
6768
@global_target_identifier = "__global__cf_target" # <--- This target identifier is used to aggregate and send data for all
6869
# targets as a summary
69-
@global_target = Target.new("RubySDK1", identifier = @global_target_identifier, name = @global_target_name)
7070
@ready = false
7171
@jar_version = Ff::Ruby::Server::Sdk::VERSION
7272
@server = "server"
@@ -129,8 +129,8 @@ def register_evaluation_metric(feature_config, variation)
129129
return
130130
end
131131

132-
if @global_target.nil? || !@global_target.respond_to?(:identifier) || @global_target.identifier.nil?
133-
@config.logger.warn("Skipping invalid MetricsEvent: global_target is missing or incomplete. global_target=#{@global_target.inspect}")
132+
if GLOBAL_TARGET.nil? || !GLOBAL_TARGET.respond_to?(:identifier) || GLOBAL_TARGET.identifier.nil?
133+
@config.logger.warn("Skipping invalid MetricsEvent: global_target is missing or incomplete. global_target=#{GLOBAL_TARGET.inspect}")
134134
return
135135
end
136136

@@ -148,7 +148,7 @@ def register_evaluation_metric(feature_config, variation)
148148
return
149149
end
150150

151-
event = MetricsEvent.new(feature_config, @global_target, variation, @config.logger)
151+
event = MetricsEvent.new(feature_config, GLOBAL_TARGET, variation, @config.logger)
152152
@evaluation_metrics.increment event
153153
end
154154

0 commit comments

Comments
 (0)