Skip to content

Commit

Permalink
- update changelog
Browse files Browse the repository at this point in the history
- call the sleep-every-n-events feature 'every' not 'unslept_count'
  • Loading branch information
jordansissel committed May 3, 2013
1 parent 16e9303 commit 6526dd9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
## outputs
- feature: irc output now supports 'secure' setting to use ssl (LOGSTASH-139)
- feature: nagios_nsca has new setting 'message_format'
- bugfix: fix graphite plugin broken in 1.1.10 (LOGSTASH-968)
- bugfix: elasticsearch_http was broken in 1.1.10 (LOGSTASH-1004)
- bugfix: rabbitmq was broken by the previous release (LOGSTASH-1003,
LOGSTASH-1038; Patch by Jason Koppe)
- feature: hipchat 'notify' setting now called 'trigger_notify' (#467, patch
by Richard Pijnenburg)

1.1.10 (April 16, 2013)
## general
Expand Down
29 changes: 15 additions & 14 deletions lib/logstash/filters/sleep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ class LogStash::Filters::Sleep < LogStash::Filters::Base
# }
config :time, :validate => :string

# Sleep on every N'th even where unslept_count=N, defaults to every event.
# This option is ignored in replay mode.
# Sleep on every N'th. This option is ignored in replay mode.
#
# Example:
#
# filter {
# sleep {
# # Sleep 1 second on every 10'th event.
# time => "1"
# count => 10
# time => "1" # Sleep 1 second
# every => 10 # on every 10th event
# }
# }
config :unslept_count, :validate => :string, :default => 1

config :every, :validate => :string, :default => 1

# Enable replay mode.
#
Expand Down Expand Up @@ -73,12 +70,16 @@ def register
# Default time multiplier is 1 when replay is set.
@time = 1
end
@events_unslept = 0
if @time.nil?
raise ArgumentError, "Missing required parameter 'time' for input/eventlog"
end
@count = 0
end # def register

public
def filter(event)
return unless filter?(event)
@count += 1

case @time
when Fixnum, Float; time = @time
Expand All @@ -90,18 +91,18 @@ def filter(event)
clock = event.ruby_timestamp.to_f
if @last_clock
delay = clock - @last_clock
sleeptime = delay/time
time = delay/time
if sleeptime > 0
@logger.debug? && @logger.debug("Sleeping", :delay => sleeptime)
sleep(sleeptime)
@logger.debug? && @logger.debug("Sleeping", :delay => time)
sleep(time)
end
end
@last_clock = clock
else
@events_unslept += 1
if @events_unslept >= @unslept_count
if @count >= @every
@count = 0
@logger.debug? && @logger.debug("Sleeping", :delay => time)
sleep(time)
@events_unslept = 0
end
end
filter_matched(event)
Expand Down

0 comments on commit 6526dd9

Please sign in to comment.