Module: AppOptics::Metrics::Processor
- Included in:
- Aggregator, Queue
- Defined in:
- lib/appoptics/metrics/processor.rb
Overview
Mixin which provides common logic between Queue and Aggregator objects.
Constant Summary collapse
- MEASUREMENTS_PER_REQUEST =
500
Instance Attribute Summary collapse
-
#last_submit_time ⇒ Object
readonly
Returns the value of attribute last_submit_time.
-
#per_request ⇒ Object
readonly
Returns the value of attribute per_request.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#client ⇒ AppOptics::Metrics::Client
The current Client instance this queue is using to authenticate and connect to Appoptics.
- #has_tags? ⇒ Boolean (also: #tags?)
-
#persister ⇒ Object
The object this MetricSet will use to persist.
-
#submit ⇒ Object
Persist currently queued metrics.
-
#time(name, options = {}) ⇒ Object
(also: #benchmark)
Capture execution time for a block and queue it as the value for a metric.
Instance Attribute Details
#last_submit_time ⇒ Object (readonly)
Returns the value of attribute last_submit_time.
11 12 13 |
# File 'lib/appoptics/metrics/processor.rb', line 11 def last_submit_time @last_submit_time end |
#per_request ⇒ Object (readonly)
Returns the value of attribute per_request.
11 12 13 |
# File 'lib/appoptics/metrics/processor.rb', line 11 def per_request @per_request end |
#prefix ⇒ Object
Returns the value of attribute prefix.
12 13 14 |
# File 'lib/appoptics/metrics/processor.rb', line 12 def prefix @prefix end |
#tags ⇒ Object
Returns the value of attribute tags.
12 13 14 |
# File 'lib/appoptics/metrics/processor.rb', line 12 def @tags end |
Instance Method Details
#client ⇒ AppOptics::Metrics::Client
The current Client instance this queue is using to authenticate and connect to Appoptics. This will default to the primary client used by the AppOptics::Metrics module unless it has been set to something else.
24 25 26 |
# File 'lib/appoptics/metrics/processor.rb', line 24 def client @client ||= AppOptics::Metrics.client end |
#has_tags? ⇒ Boolean Also known as:
28 29 30 |
# File 'lib/appoptics/metrics/processor.rb', line 28 def !@tags.empty? end |
#persister ⇒ Object
The object this MetricSet will use to persist
35 36 37 |
# File 'lib/appoptics/metrics/processor.rb', line 35 def persister @persister ||= create_persister end |
#submit ⇒ Object
Persist currently queued metrics
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/appoptics/metrics/processor.rb', line 42 def submit return true if self.empty? = {per_request: @per_request} if persister.persist(self.client, self.queued, ) @last_submit_time = Time.now clear and return true end false rescue ClientError # clean up if we hit exceptions if asked to clear if @clear_on_failure raise end |
#time(name, options = {}) ⇒ Object Also known as: benchmark
Capture execution time for a block and queue it as the value for a metric. Times are recorded in milliseconds.
Options are the same as for #add.
74 75 76 77 78 79 80 81 |
# File 'lib/appoptics/metrics/processor.rb', line 74 def time(name, ={}) start = Time.now yield.tap do duration = (Time.now - start) * 1000.0 # milliseconds metric = {name => .merge({value: duration})} add metric end end |