Class: Files::FrontendMetric
- Inherits:
-
Object
- Object
- Files::FrontendMetric
- Defined in:
- lib/files.com/models/frontend_metric.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.create(params = {}, options = {}) ⇒ Object
Parameters: metric_type (required) - string - Statsd metric type.
Instance Method Summary collapse
-
#initialize(attributes = {}, options = {}) ⇒ FrontendMetric
constructor
A new instance of FrontendMetric.
-
#metric_type ⇒ Object
string - Statsd metric type.
- #metric_type=(value) ⇒ Object
-
#ms ⇒ Object
int64 - For timing metrics, the number of milliseconds.
- #ms=(value) ⇒ Object
- #save ⇒ Object
-
#subkey ⇒ Object
string - Where in statsd to store the metric.
- #subkey=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ FrontendMetric
Returns a new instance of FrontendMetric.
7 8 9 10 |
# File 'lib/files.com/models/frontend_metric.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/frontend_metric.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/frontend_metric.rb', line 5 def @options end |
Class Method Details
.create(params = {}, options = {}) ⇒ Object
Parameters:
metric_type (required) - string - Statsd metric type. Use `timing` to submit the amount of time something took, or `increment` to increment a counter
subkey (required) - string - Where in statsd to store the metric. The final key in statsd will be `files-react.[environment].[subkey]`
ms - int64 - For timing metrics, the number of milliseconds. Required if `metric_type` is `timing`.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/files.com/models/frontend_metric.rb', line 54 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: metric_type must be an String") if params[:metric_type] and !params[:metric_type].is_a?(String) raise InvalidParameterError.new("Bad parameter: subkey must be an String") if params[:subkey] and !params[:subkey].is_a?(String) raise InvalidParameterError.new("Bad parameter: ms must be an Integer") if params[:ms] and !params[:ms].is_a?(Integer) raise MissingParameterError.new("Parameter missing: metric_type") unless params[:metric_type] raise MissingParameterError.new("Parameter missing: subkey") unless params[:subkey] response, = Api.send_request("/frontend_metrics", :post, params, ) FrontendMetric.new(response.data, ) end |
Instance Method Details
#metric_type ⇒ Object
string - Statsd metric type
13 14 15 |
# File 'lib/files.com/models/frontend_metric.rb', line 13 def metric_type @attributes[:metric_type] end |
#metric_type=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/frontend_metric.rb', line 17 def metric_type=(value) @attributes[:metric_type] = value end |
#ms ⇒ Object
int64 - For timing metrics, the number of milliseconds. Required if metric_type is timing.
31 32 33 |
# File 'lib/files.com/models/frontend_metric.rb', line 31 def ms @attributes[:ms] end |
#ms=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/frontend_metric.rb', line 35 def ms=(value) @attributes[:ms] = value end |
#save ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/files.com/models/frontend_metric.rb', line 39 def save if @attributes[:id] raise NotImplementedError.new("The FrontendMetric object doesn't support updates.") else new_obj = FrontendMetric.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#subkey ⇒ Object
string - Where in statsd to store the metric. The final key in statsd will be files-react.[environment].[subkey]
22 23 24 |
# File 'lib/files.com/models/frontend_metric.rb', line 22 def subkey @attributes[:subkey] end |
#subkey=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/frontend_metric.rb', line 26 def subkey=(value) @attributes[:subkey] = value end |