Class: Librato::Metrics::Persistence::Direct

Inherits:
Object
  • Object
show all
Defined in:
lib/librato/metrics/persistence/direct.rb

Constant Summary collapse

MEASUREMENT_TYPES =
[:gauges, :counters]

Instance Method Summary collapse

Instance Method Details

#persist(client, queued, options = {}) ⇒ Object

Persist the queued metrics directly to the Metrics web API.


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/librato/metrics/persistence/direct.rb', line 13

def persist(client, queued, options={})
  per_request = options[:per_request]
  if per_request
    requests = chunk_queued(queued, per_request)
  else
    requests = [queued]
  end
  requests.each do |request|
    payload = SmartJSON.write(request)
    # expects 200
    client.connection.post('metrics', payload)
  end
end