Class: NewRelic::Agent::Utilization::Vendor
- Inherits:
-
Object
- Object
- NewRelic::Agent::Utilization::Vendor
- Defined in:
- lib/new_relic/agent/utilization/vendor.rb
Constant Summary collapse
- SUCCESS =
'200'.freeze
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
- .endpoint(endpoint = nil) ⇒ Object
- .headers(headers = nil) ⇒ Object
- .key_transforms(key_transforms = nil) ⇒ Object
- .keys(keys = nil) ⇒ Object
- .processed_headers ⇒ Object
- .vendor_name(vendor_name = nil) ⇒ Object
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize ⇒ Vendor
constructor
A new instance of Vendor.
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
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
43 44 45 |
# File 'lib/new_relic/agent/utilization/vendor.rb', line 43 def @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 |
.headers(headers = nil) ⇒ Object
20 21 22 |
# File 'lib/new_relic/agent/utilization/vendor.rb', line 20 def headers(headers = nil) headers ? @headers = headers.freeze : processed_headers end |
.key_transforms(key_transforms = nil) ⇒ Object
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 |
.processed_headers ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/new_relic/agent/utilization/vendor.rb', line 32 def processed_headers return unless @headers @headers.each_with_object({}) do |(key, value), processed_hash| # Header lambdas are expected to return string values. If nil comes back, replace it with :error # to signify that the call failed. 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 = 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 |