EasyAwscr::CloudWatch::Counters
Counts events in memory and uploads them to CloudWatch: one data point per metric and flush interval, so a busy application sends one request per minute instead of one per event.
By default, a background loop uploads the counters periodically. With
flush_interval: nil there is no loop and flush uploads on demand.
Configure once, afterwards it is only count:
metrics = EasyAwscr::CloudWatch::Counters.new("MyApp")
metrics.count("Requests")
Constants
AWS allows at most 1000 data points and 1 MB per request. The size grows with the length of the metric names and dimensions, but stays well below 1 MB for typical counters (a full batch is around 300 KB).
Constructors
flush_interval starts a background loop that uploads the counters
periodically (every minute by default). nil starts no loop: call flush
to upload instead.
dimensions are attached to every metric, e.g. {"Environment" => "Dev"}.
Instance methods
Sends what is left and stops the background upload, e.g. at shutdown.
Later calls to close or flush are ignored.
Whether close was called. Once closed, nothing is uploaded anymore:
counters counted afterwards stay in pending (flush is a no-op).
Uploads everything counted so far. What could not be uploaded stays and
goes out with the next flush. Ignored after close.