Use metric#time instead of computing duration locally.

Fix a bug in the metric that called 'milliseconds' 1_000_000 for a
multiplier when it should be 1000.

Fixes #5472
This commit is contained in:
Jordan Sissel 2016-06-14 05:46:51 -07:00
parent c8f7aee9b1
commit 07be0dcb3b
2 changed files with 4 additions and 4 deletions

View file

@ -37,9 +37,9 @@ module LogStash
def multi_filter(events)
@metric_events.increment(:in, events.size)
start = Time.now
clock = @filter.metric.time(:duration_in_millis)
new_events = @filter.multi_filter(events)
@filter.metric.increment(:duration_in_millis, ((Time.now - start)*1000).to_i)
clock.stop
# There is no garantee in the context of filter
# that EVENTS_INT == EVENTS_OUT, see the aggregates and

View file

@ -46,7 +46,7 @@ module LogStash module Instrument
end
def report_time(namespace, key, duration)
collector.push(namespace, key, :mean, :increment, duration)
collector.push(namespace, key, :counter, :increment, duration)
end
# This method return a metric instance tied to a specific namespace
@ -81,7 +81,7 @@ module LogStash module Instrument
#
# @see LogStash::Instrument::Metric#time
class TimedExecution
MILLISECONDS = 1_000_000.0.freeze
MILLISECONDS = 1_000.0.freeze
def initialize(metric, namespace, key)
@metric = metric