Class: TingYun::Configuration::ServerSource
- Inherits:
-
DottedHash
- Object
- Hash
- DottedHash
- TingYun::Configuration::ServerSource
show all
- Defined in:
- lib/ting_yun/configuration/server_source.rb
Constant Summary
collapse
- TOP_LEVEL_KEYSV2 =
These keys appear outside of the agent_config hash in the connect response, but should still be merged in as config settings to the main agent configuration.
[
"applicationId",
"tingyunIdSecret",
"enabled",
"appSessionKey",
"dataSentInterval",
"apdex_t",
"config"
]
- TOP_LEVEL_KEYS =
[
"appId",
"idSecret",
"sessionKey",
"config"
]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from DottedHash
#inspect, symbolize, #to_hash
Constructor Details
#initialize(connect_reply) ⇒ ServerSource
Returns a new instance of ServerSource.
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/ting_yun/configuration/server_source.rb', line 37
def initialize(connect_reply)
merged_settings = {}
merge_top_level_keys(merged_settings, connect_reply)
merge_agent_config_hash(merged_settings, connect_reply)
filter_keys(merged_settings)
super(merged_settings)
end
|
Class Method Details
.add_top_level_keys_for_testing(add_array) ⇒ Object
29
30
31
|
# File 'lib/ting_yun/configuration/server_source.rb', line 29
def self.add_top_level_keys_for_testing(add_array)
TOP_LEVEL_KEYS.concat add_array
end
|
.remove_top_level_keys_for_testing(remove_arry) ⇒ Object
33
34
35
|
# File 'lib/ting_yun/configuration/server_source.rb', line 33
def self.remove_top_level_keys_for_testing(remove_arry)
remove_arry.each{|i| TOP_LEVEL_KEYS.delete(i)}
end
|
Instance Method Details
#filter_keys(merged_settings) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/ting_yun/configuration/server_source.rb', line 75
def filter_keys(merged_settings)
merged_settings.delete_if do |key, _|
setting_spec = DEFAULTS[key.to_sym]
if setting_spec
if setting_spec[:allowed_from_server]
false else
TingYun::Agent.logger.warn("Ignoring server-sent config for '#{key}' - this setting cannot be set from the server")
true end
else
TingYun::Agent.logger.debug("Ignoring unrecognized config key from server: '#{key}'")
true
end
end
end
|
#fix_transaction_threshold(merged_settings) ⇒ Object
68
69
70
71
72
73
|
# File 'lib/ting_yun/configuration/server_source.rb', line 68
def fix_transaction_threshold(merged_settings)
if merged_settings['transaction_tracer.transaction_threshold'] =~ /apdex_f/i
merged_settings.delete('transaction_tracer.transaction_threshold')
end
end
|
#merge_agent_config_hash(merged_settings, connect_reply) ⇒ Object
62
63
64
65
66
|
# File 'lib/ting_yun/configuration/server_source.rb', line 62
def merge_agent_config_hash(merged_settings, connect_reply)
if connect_reply['config']
merged_settings.merge!(connect_reply['config'])
end
end
|
#merge_top_level_keys(merged_settings, connect_reply) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/ting_yun/configuration/server_source.rb', line 54
def merge_top_level_keys(merged_settings, connect_reply)
TOP_LEVEL_KEYS.each do |key_name|
if connect_reply[key_name]
merged_settings[key_name] = connect_reply[key_name]
end
end
end
|