Class: LaunchDarkly::Impl::DiagnosticAccumulator Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::DiagnosticAccumulator
- Defined in:
- lib/ldclient-rb/impl/diagnostic_events.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .create_diagnostic_id(sdk_key) ⇒ Object private
- .make_config_data(config) ⇒ Object private
- .make_platform_data ⇒ Object private
- .make_sdk_data(config) ⇒ Object private
- .normalize_os_name(name) ⇒ Object private
- .seconds_to_millis(s) ⇒ Object private
Instance Method Summary collapse
- #create_init_event(config) ⇒ Object private
- #create_periodic_event_and_reset(dropped_events, deduplicated_users, events_in_last_batch) ⇒ Object private
-
#initialize(diagnostic_id) ⇒ DiagnosticAccumulator
constructor
private
A new instance of DiagnosticAccumulator.
- #record_stream_init(timestamp, failed, duration_millis) ⇒ Object private
- #reset(time) ⇒ Object private
Constructor Details
#initialize(diagnostic_id) ⇒ DiagnosticAccumulator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DiagnosticAccumulator.
16 17 18 19 20 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 16 def initialize(diagnostic_id) @id = diagnostic_id @lock = Mutex.new self.reset(Util.current_time_millis) end |
Class Method Details
.create_diagnostic_id(sdk_key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 9 def self.create_diagnostic_id(sdk_key) { diagnosticId: SecureRandom.uuid, sdkKeySuffix: sdk_key[-6..-1] || sdk_key, } end |
.make_config_data(config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 66 def self.make_config_data(config) ret = { allAttributesPrivate: config.all_attributes_private, connectTimeoutMillis: self.seconds_to_millis(config.connect_timeout), customBaseURI: config.base_uri != Config.default_base_uri, customEventsURI: config.events_uri != Config.default_events_uri, customStreamURI: config.stream_uri != Config.default_stream_uri, diagnosticRecordingIntervalMillis: self.seconds_to_millis(config.diagnostic_recording_interval), eventsCapacity: config.capacity, eventsFlushIntervalMillis: self.seconds_to_millis(config.flush_interval), pollingIntervalMillis: self.seconds_to_millis(config.poll_interval), socketTimeoutMillis: self.seconds_to_millis(config.read_timeout), streamingDisabled: !config.stream?, userKeysCapacity: config.context_keys_capacity, userKeysFlushIntervalMillis: self.seconds_to_millis(config.context_keys_flush_interval), usingProxy: ENV.has_key?('http_proxy') || ENV.has_key?('https_proxy') || ENV.has_key?('HTTP_PROXY') || ENV.has_key?('HTTPS_PROXY'), usingRelayDaemon: config.use_ldd?, } ret end |
.make_platform_data ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 99 def self.make_platform_data conf = RbConfig::CONFIG { name: 'ruby', osArch: conf['host_cpu'], osName: self.normalize_os_name(conf['host_os']), osVersion: 'unknown', # there seems to be no portable way to detect this in Ruby rubyVersion: conf['ruby_version'], rubyImplementation: Object.constants.include?(:RUBY_ENGINE) ? RUBY_ENGINE : 'unknown', } end |
.make_sdk_data(config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 87 def self.make_sdk_data(config) ret = { name: 'ruby-server-sdk', version: LaunchDarkly::VERSION, } if config.wrapper_name ret[:wrapperName] = config.wrapper_name ret[:wrapperVersion] = config.wrapper_version end ret end |
.normalize_os_name(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 111 def self.normalize_os_name(name) case name when /linux|arch/i 'Linux' when /darwin/i 'MacOS' when /mswin|windows/i 'Windows' else name end end |
.seconds_to_millis(s) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 124 def self.seconds_to_millis(s) (s * 1000).to_i end |
Instance Method Details
#create_init_event(config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 27 def create_init_event(config) { kind: 'diagnostic-init', creationDate: Util.current_time_millis, id: @id, configuration: DiagnosticAccumulator.make_config_data(config), sdk: DiagnosticAccumulator.make_sdk_data(config), platform: DiagnosticAccumulator.make_platform_data, } end |
#create_periodic_event_and_reset(dropped_events, deduplicated_users, events_in_last_batch) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 44 def create_periodic_event_and_reset(dropped_events, deduplicated_users, events_in_last_batch) previous_stream_inits = @lock.synchronize do si = @stream_inits @stream_inits = [] si end current_time = Util.current_time_millis event = { kind: 'diagnostic', creationDate: current_time, id: @id, dataSinceDate: @data_since_date, droppedEvents: dropped_events, deduplicatedUsers: deduplicated_users, eventsInLastBatch: events_in_last_batch, streamInits: previous_stream_inits, } @data_since_date = current_time event end |
#record_stream_init(timestamp, failed, duration_millis) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 38 def record_stream_init(, failed, duration_millis) @lock.synchronize do @stream_inits.push({ timestamp: , failed: failed, durationMillis: duration_millis }) end end |
#reset(time) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 |
# File 'lib/ldclient-rb/impl/diagnostic_events.rb', line 22 def reset(time) @data_since_date = time @stream_inits = [] end |