lib/metricize/forwarder.rb in metricize-0.5.0 vs lib/metricize/forwarder.rb in metricize-0.5.1
- old
+ new
@@ -5,14 +5,13 @@
def initialize(options)
@password = options.fetch(:password)
@username = options.fetch(:username)
@remote_url = options[:remote_url] || 'metrics-api.librato.com/v1/metrics'
@remote_timeout = options[:remote_timeout] || 10
- @max_batch_size = options[:max_batch_size] || 5000
+ @batch_size = options[:batch_size] || 5000
establish_logger(options)
initialize_redis(options)
- establish_redis_connection
end
def go!
process_metric_queue
end
@@ -27,12 +26,12 @@
end
end
def lshift_queue
return [] unless queue_length > 0
- current_batch = @redis.lrange(@queue_name, 0, @max_batch_size - 1)
+ current_batch = @redis.lrange(@queue_name, 0, @batch_size - 1)
# ltrim indexes are 0 based and somewhat confusing -- see http://redis.io/commands/ltrim
- @redis.ltrim(@queue_name, 0, -1-@max_batch_size)
+ @redis.ltrim(@queue_name, 0, -1-@batch_size)
current_batch.map {|metric| JSON.parse(metric, :symbolize_names => true) }
end
def queue_length
log_message "queue_length=#{length = @redis.llen(@queue_name)}", :info