Class: Cabin::Metrics
- Inherits:
-
Object
- Object
- Cabin::Metrics
- Includes:
- Enumerable
- Defined in:
- lib/cabin/metrics.rb,
lib/cabin/namespace.rb
Overview
What type of metrics do we want?
What metrics should come by default? Per-call/transaction/request metrics like:
- hit (count++ type metrics)
- latencies/timings
Per app or generally long-lifetime metrics like:
- "uptime"
- cpu usage
- memory usage
- count of active/in-flight actions/requests/calls/transactions
- peer metrics (number of cluster members, etc)
github.com/codahale/metrics/tree/master/metrics-core/src/main/java/com/yammer/metrics/core Reading what Coda Hale’s “Metrics” stuff has, here’s my summary:
gauges (callback to return a number)
counters (.inc and .dec methods)
meters (.mark to track each 'hit')
Also exposes 1, 5, 15 minute moving averages
histograms: (.update(value) to record a new value)
like meter, but takes values more than simply '1'
as a result, exposes percentiles, median, etc.
timers
combination of meter + histogram
meter for invocations, histogram for duration
With the exception of gauges, all the other metrics are all active/pushed. Gauges take callbacks, so their values are pulled, not pushed. The active metrics can be represented as events since they the update occurs at the time of the change.
These active/push metrics can therefore be considered events.
All metrics (active/passive) can be queried for ‘current state’, too, making this suitable for serving to interested parties like monitoring and management tools.
Defined Under Namespace
Classes: Counter, Gauge, Meter, Timer
Instance Method Summary collapse
- #counter(instance, name = nil) ⇒ Object
-
#each(&block) ⇒ Object
iterate over each metric.
-
#initialize ⇒ Metrics
constructor
A new instance of Metrics.
- #meter(instance, name = nil) ⇒ Object
- #timer(instance, name = nil) ⇒ Object
Constructor Details
#initialize ⇒ Metrics
Returns a new instance of Metrics.
51 52 53 |
# File 'lib/cabin/metrics.rb', line 51 def initialize @metrics = {} end |
Instance Method Details
#counter(instance, name = nil) ⇒ Object
63 64 65 |
# File 'lib/cabin/metrics.rb', line 63 def counter(instance, name=nil) return create(instance, name, Cabin::Metrics::Counter.new) end |
#each(&block) ⇒ Object
iterate over each metric. yields identifer, metric
83 84 85 86 |
# File 'lib/cabin/metrics.rb', line 83 def each(&block) # delegate to the @metrics hash until we need something fancier @metrics.each(&block) end |