Class: NewRelic::Agent::Utilization::Vendor
- Inherits:
-
Object
- Object
- NewRelic::Agent::Utilization::Vendor
show all
- Defined in:
- lib/new_relic/agent/utilization/vendor.rb
Constant Summary
collapse
- SUCCESS =
'200'.freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Vendor
Returns a new instance of Vendor.
45
46
47
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 45
def initialize
@metadata = {}
end
|
Instance Attribute Details
Returns the value of attribute metadata.
43
44
45
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 43
def metadata
@metadata
end
|
Class Method Details
.endpoint(endpoint = nil) ⇒ Object
16
17
18
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 16
def endpoint(endpoint = nil)
endpoint ? @endpoint = URI(endpoint) : @endpoint
end
|
20
21
22
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 20
def ( = nil)
? @headers = .freeze :
end
|
28
29
30
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 28
def key_transforms(key_transforms = nil)
key_transforms ? @key_transforms = Array(key_transforms).freeze : @key_transforms
end
|
.keys(keys = nil) ⇒ Object
24
25
26
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 24
def keys(keys = nil)
keys ? @keys = keys.freeze : @keys
end
|
32
33
34
35
36
37
38
39
40
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 32
def
return unless @headers
@headers.each_with_object({}) do |(key, value), processed_hash|
processed_hash[key] = value.class.eql?(Proc) ? value.call || :error : value
end
end
|
.vendor_name(vendor_name = nil) ⇒ Object
12
13
14
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 12
def vendor_name(vendor_name = nil)
vendor_name ? @vendor_name = vendor_name.freeze : @vendor_name
end
|
Instance Method Details
#detect ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/new_relic/agent/utilization/vendor.rb', line 55
def detect
response = request_metadata
return false unless response
begin
if response.code == SUCCESS
process_response(prepare_response(response))
else
false
end
rescue => e
NewRelic::Agent.logger.error("Error occurred detecting: #{vendor_name}", e)
record_supportability_metric
false
end
end
|