lib/logstash/outputs/scalyr.rb in logstash-output-scalyr-0.1.21.beta vs lib/logstash/outputs/scalyr.rb in logstash-output-scalyr-0.1.22.beta
- old
+ new
@@ -287,10 +287,11 @@
end # def register
# Convenience method to create a fresh quantile estimator
def get_new_metrics
return {
+ :build_multi_duration_secs => Quantile::Estimator.new,
:multi_receive_duration_secs => Quantile::Estimator.new,
:multi_receive_event_count => Quantile::Estimator.new,
:event_attributes_count => Quantile::Estimator.new,
:flatten_values_duration_secs => Quantile::Estimator.new,
:batches_per_multi_receive => Quantile::Estimator.new
@@ -311,21 +312,29 @@
def multi_receive(events)
# Just return and pretend we did something if running in noop mode
return events if @noop_mode
begin
+ records_count = events.to_a.length
+
+ # We also time the duration of the build_multi_event_request_array method
start_time = Time.now.to_f
multi_event_request_array = build_multi_event_request_array(events)
- # Loop over all array of multi-event requests, sending each multi-event to Scalyr
+ if records_count > 0
+ @stats_lock.synchronize do
+ @plugin_metrics[:build_multi_duration_secs].observe(Time.now.to_f - start_time)
+ end
+ end
+
+ # Loop over all array of multi-event requests, sending each multi-event to Scalyr
sleep_interval = @retry_initial_interval
batch_num = 1
total_batches = multi_event_request_array.length unless multi_event_request_array.nil?
result = []
- records_count = events.to_a.length
while !multi_event_request_array.to_a.empty?
multi_event_request = multi_event_request_array.pop
# Variables to hold information about exceptions we run into, and our handling of retries for this request. We
# track this to log it when the retries succeed so we can be sure logs are going through.
@@ -813,9 +822,13 @@
# Retrieve batch and other event level metric values
def get_stats
@stats_lock.synchronize do
current_stats = @multi_receive_statistics.clone
+
+ current_stats[:build_multi_duration_secs_p50] = @plugin_metrics[:build_multi_duration_secs].query(0.5)
+ current_stats[:build_multi_duration_secs_p90] = @plugin_metrics[:build_multi_duration_secs].query(0.9)
+ current_stats[:build_multi_duration_secs_p99] = @plugin_metrics[:build_multi_duration_secs].query(0.99)
current_stats[:multi_receive_duration_p50] = @plugin_metrics[:multi_receive_duration_secs].query(0.5)
current_stats[:multi_receive_duration_p90] = @plugin_metrics[:multi_receive_duration_secs].query(0.9)
current_stats[:multi_receive_duration_p99] = @plugin_metrics[:multi_receive_duration_secs].query(0.99)