lib/spectator/registry.rb in netflix-spectator-rb-0.1.1 vs lib/spectator/registry.rb in netflix-spectator-rb-0.1.3

- old
+ new

@@ -18,10 +18,11 @@ # :frequency the interval at which metrics will be sent to an # aggregator service, expressed in seconds # :uri the endpoint for the aggregator service def initialize(config, clock = SystemClock.new) @config = config + @batch_size = config[:batch_size] || 10_000 @clock = clock @meters = {} @common_tags = to_symbols(config[:common_tags]) || {} @lock = Mutex.new @publisher = Publisher.new(self) @@ -268,16 +269,19 @@ end # Send the current measurements to our aggregator service def send_metrics_now ms = registry_measurements + if ms.empty? Spectator.logger.debug 'No measurements to send' else - payload = payload_for_measurements(ms) uri = @registry.config[:uri] - Spectator.logger.info "Sending #{ms.length} measurements to #{uri}" - @http.post_json(uri, payload) + ms.each_slice(@registry.batch_size) do |batch| + payload = payload_for_measurements(batch) + Spectator.logger.info "Sending #{batch.length} measurements to #{uri}" + @http.post_json(uri, payload) + end end end # Publish loop: # send measurements to the aggregator endpoint ':uri',