-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test new configs logstash #77
Open
monishkadas-ms
wants to merge
26
commits into
master
Choose a base branch
from
testNewConfigsLogstash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
58c2772
added custom_size_based_buffer class
monishkadas-ms cbb7444
added custom_size_based_buffer class
monishkadas-ms 5b2af15
added custom_size_based_buffer class
monishkadas-ms 806e57f
added custom_size_based_buffer class
monishkadas-ms 117a2b4
Merge branch 'master' of https://github.com/Azure/logstash-output-kus…
MonishkaDas 0110ae6
Added warning for deprecated path config var
MonishkaDas f334a4b
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 28fc7a3
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 79b8c3f
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 47a3db2
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 4b66790
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 3b50bdb
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 521c21f
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 531046c
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas c813a5b
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas ab1f66f
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 9994da5
Updated kusto_spec.rb and ingestor_spec.rb
MonishkaDas 649bb0d
Updated max_size config
MonishkaDas ed85986
Updated max_size config
MonishkaDas 43f9bea
Added tests in kusto_spec.rb
MonishkaDas 4a85b94
Added tests in kusto_spec.rb
MonishkaDas 9c84304
Updated custom_size_based_buffer.rb
MonishkaDas fce671f
Updated custom_size_based_buffer.rb
MonishkaDas 379da3b
Updated custom_size_based_buffer.rb
MonishkaDas b7aba1a
Adds temp file buffer used during network downtime
MonishkaDas ca981ba
Updated custom_size_based_buffer.rb
MonishkaDas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module LogStash | ||
module Outputs | ||
class CustomSizeBasedBuffer | ||
def initialize(max_size, max_interval, &flush_callback) | ||
@max_size = max_size | ||
@max_interval = max_interval | ||
@flush_callback = flush_callback | ||
@buffer = [] | ||
@mutex = Mutex.new | ||
@last_flush_time = Time.now | ||
@shutdown = false | ||
@flusher_condition = ConditionVariable.new | ||
|
||
start_flusher_thread | ||
end | ||
|
||
def <<(event) | ||
@mutex.synchronize do | ||
@buffer << event | ||
flush if @buffer.size >= @max_size | ||
end | ||
end | ||
|
||
def shutdown | ||
@mutex.synchronize do | ||
@shutdown = true | ||
@flusher_condition.signal # Wake up the flusher thread | ||
end | ||
@flusher_thread.join | ||
flush # Ensure final flush after shutdown | ||
end | ||
|
||
private | ||
|
||
def start_flusher_thread | ||
@flusher_thread = Thread.new do | ||
loop do | ||
@mutex.synchronize do | ||
break if @shutdown | ||
if Time.now - @last_flush_time >= @max_interval | ||
flush | ||
end | ||
@flusher_condition.wait(@mutex, @max_interval) # Wait for either the interval or shutdown signal | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
def flush_if_needed | ||
@mutex.synchronize do | ||
if Time.now - @last_flush_time >= @max_interval | ||
flush | ||
end | ||
end | ||
end | ||
|
||
def flush | ||
return if @buffer.empty? | ||
|
||
begin | ||
@flush_callback.call(@buffer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, during gracefully shutdown of the buffer, how do we ensure all events are flushed before the application exits? may be add a graceful shutdown |
||
rescue => e | ||
# Log the error and continue, | ||
puts "Error during flush: #{e.message}" | ||
puts e.backtrace.join("\n") | ||
ensure | ||
@buffer.clear | ||
@last_flush_time = Time.now | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it all add up ? It is just a buffer that is added.
Currently there is events written to file and then these files are flushed. With the new approach these files should go away
Right now the code changes are
a) Buffer that is taken from LA plugin
b) We write the events to the buffer and flush. How is this message encoded ?
c) can we remove the file part ? or the file buffers based on size on file ?
d) Where are the Tests ?
e) Time based flushes ?