Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated telemetry classes #485

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/splitclient-rb/telemetry/domain/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class Constants
TREATMENTS = 'treatments'
TREATMENT_WITH_CONFIG = 'treatmentWithConfig'
TREATMENTS_WITH_CONFIG = 'treatmentsWithConfig'
TREATMENTS_BY_FLAG_SET = 'treatmentsByFlagSet'
TREATMENTS_BY_FLAG_SETS = 'treatmentsByFlagSets'
TREATMENTS_WITH_CONFIG_BY_FLAG_SET = 'treatmentWithConfigByFlagSet'
TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = 'treatmentsWithConfigByFlagSets'
TRACK = 'track'

SPLITS = 'splits'
Expand Down
8 changes: 4 additions & 4 deletions lib/splitclient-rb/telemetry/domain/structs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module Telemetry
# om: operationMode, st: storage, af: activeFactories, rf: redundantActiveFactories, t: tags, se: streamingEnabled,
# rr: refreshRate, uo: urlOverrides, iq: impressionsQueueSize, eq: eventsQueueSize, im: impressionsMode,
# il: impressionListenerEnabled, hp: httpProxyDetected, tr: timeUntilSdkReady, bt: burTimeouts,
# nr: sdkNotReadyUsage, i: integrations
ConfigInit = Struct.new(:om, :st, :af, :rf, :t, :se, :rr, :uo, :iq, :eq, :im, :il, :hp, :tr, :bt, :nr, :i)
# nr: sdkNotReadyUsage, i: integrations, fsT: Total flagsets, fsI: Invalid flagsets
ConfigInit = Struct.new(:om, :st, :af, :rf, :t, :fsT, :fsI, :se, :rr, :uo, :iq, :eq, :im, :il, :hp, :tr, :bt, :nr, :i)

# ls: lastSynchronization, ml: clientMethodLatencies, me: clientMethodExceptions, he: httpErros, hl: httpLatencies,
# tr: tokenRefreshes, ar: authRejections, iq: impressionsQueued, ide: impressionsDeduped, idr: impressionsDropped,
Expand All @@ -26,8 +26,8 @@ module Telemetry
Usage = Struct.new(:ls, :ml, :me, :he, :hl, :tr, :ar, :iq, :ide, :idr, :spc, :sec, :skc, :sl, :eq, :ed, :se, :t, :ufs)

# t: treatment, ts: treatments, tc: treatmentWithConfig, tcs: treatmentsWithConfig, tr: track
ClientMethodLatencies = Struct.new(:t, :ts, :tc, :tcs, :tr)
ClientMethodExceptions = Struct.new(:t, :ts, :tc, :tcs, :tr)
ClientMethodLatencies = Struct.new(:t, :ts, :tc, :tcs, :tf, :tfs, :tcf, :tcfs, :tr)
ClientMethodExceptions = Struct.new(:t, :ts, :tc, :tcs, :tf, :tfs, :tcf, :tcfs, :tr)

# sp: splits
UpdatesFromSSE = Struct.new(:sp)
Expand Down
16 changes: 14 additions & 2 deletions lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def synchronize_stats
@config.log_found_exception(__method__.to_s, e)
end

def synchronize_config(active_factories = nil, redundant_active_factories = nil, time_until_ready = nil)
def synchronize_config(active_factories = nil, redundant_active_factories = nil, time_until_ready = nil, flag_sets = nil, flag_sets_invalid = nil)
rates = Rates.new(@config.features_refresh_rate,
@config.segments_refresh_rate,
@config.impressions_refresh_rate,
Expand All @@ -64,6 +64,8 @@ def synchronize_config(active_factories = nil, redundant_active_factories = nil,
active_factories,
redundant_active_factories,
@telemetry_runtime_consumer.pop_tags,
flag_sets,
flag_sets_invalid,
@config.streaming_enabled,
rates,
url_overrides,
Expand Down Expand Up @@ -113,7 +115,9 @@ def fornat_init_config(init)
bT: init.bt,
nR: init.nr,
t: init.t,
i: init.i
i: init.i,
fsT: init.fsT,
fsI: init.fsI
}
end

Expand All @@ -125,13 +129,21 @@ def format_stats(usage)
ts: usage.ml[Telemetry::Domain::Constants::TREATMENTS],
tc: usage.ml[Telemetry::Domain::Constants::TREATMENT_WITH_CONFIG],
tcs: usage.ml[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG],
tf: usage.ml[Telemetry::Domain::Constants::TREATMENTS_BY_FLAG_SET],
tfs: usage.ml[Telemetry::Domain::Constants::TREATMENTS_BY_FLAG_SETS],
tcf: usage.ml[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET],
tcfs: usage.ml[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS],
tr: usage.ml[Telemetry::Domain::Constants::TRACK]
},
mE: {
t: usage.me[Telemetry::Domain::Constants::TREATMENT],
ts: usage.me[Telemetry::Domain::Constants::TREATMENTS],
tc: usage.me[Telemetry::Domain::Constants::TREATMENT_WITH_CONFIG],
tcs: usage.me[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG],
tf: usage.me[Telemetry::Domain::Constants::TREATMENTS_BY_FLAG_SET],
tfs: usage.me[Telemetry::Domain::Constants::TREATMENTS_BY_FLAG_SETS],
tcf: usage.me[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET],
tcfs: usage.me[Telemetry::Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS],
tr: usage.me[Telemetry::Domain::Constants::TRACK]
},
hE: {
Expand Down
2 changes: 1 addition & 1 deletion lib/splitclient-rb/telemetry/redis/redis_init_producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(config)
def record_config(config_data)
return if config_data.nil?

data = { t: { oM: config_data.om, st: config_data.st, aF: config_data.af, rF: config_data.rf, t: config_data.t } }
data = { t: { oM: config_data.om, st: config_data.st, aF: config_data.af, rF: config_data.rf, t: config_data.t, fsT: config_data.fsT, fsI: config_data.fsI } }
field = "#{@config.language}-#{@config.version}/#{@config.machine_name}/#{@config.machine_ip}"

@adapter.add_to_map(config_key, field, data.to_json)
Expand Down
4 changes: 2 additions & 2 deletions lib/splitclient-rb/telemetry/redis/redis_synchronizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def synchronize_stats
# No-op
end

def synchronize_config(active_factories = nil, redundant_active_factories = nil, tags = nil)
def synchronize_config(active_factories = nil, redundant_active_factories = nil, tags = nil, flag_sets = nil, flag_sets_invalid = nil)
active_factories ||= SplitIoClient.split_factory_registry.active_factories
redundant_active_factories ||= SplitIoClient.split_factory_registry.redundant_active_factories

init_config = ConfigInit.new(@config.mode, 'redis', active_factories, redundant_active_factories, tags)
init_config = ConfigInit.new(@config.mode, 'redis', active_factories, redundant_active_factories, tags, flag_sets, flag_sets_invalid)

@telemetry_init_producer.record_config(init_config)
rescue StandardError => e
Expand Down
8 changes: 8 additions & 0 deletions lib/splitclient-rb/telemetry/storages/memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def init_latencies
@latencies << { method: Domain::Constants::TREATMENTS, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENT_WITH_CONFIG, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENTS_WITH_CONFIG, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENTS_BY_FLAG_SET, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENTS_BY_FLAG_SETS, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, latencies: Concurrent::Array.new(array_size, 0) }
@latencies << { method: Domain::Constants::TRACK, latencies: Concurrent::Array.new(array_size, 0) }
end

Expand All @@ -54,6 +58,10 @@ def init_exceptions
@exceptions << { method: Domain::Constants::TREATMENTS, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENT_WITH_CONFIG, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENTS_WITH_CONFIG, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENTS_BY_FLAG_SET, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENTS_BY_FLAG_SETS, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SET, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, exceptions: Concurrent::AtomicFixnum.new(0) }
@exceptions << { method: Domain::Constants::TRACK, exceptions: Concurrent::AtomicFixnum.new(0) }
end

Expand Down
Loading