Skip to content
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

avoiding overwriting of tags with key named as 'tags' #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions lib/logstash/codecs/fluent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def decode(data, &block)
end # def decode

def encode(event)
tag = event.get("tags") || "log"
tag = event.get("tags") || "log"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this indentation changes, this will make the PR less noisy and more concise.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i completed that. Thanks for notifying


epochtime = event.timestamp.to_i

# use normalize to make sure returned Hash is pure Ruby for
Expand Down Expand Up @@ -70,31 +71,34 @@ def decode_event(data, &block)
entries_decoder.feed_each(entries) do |entry|
epochtime = entry[0]
map = entry[1]
event = LogStash::Event.new(map.merge(
arr= []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try to follow the core conventions present in this file. when assigning to a variable, we use spaces before and after the equals sign, so arr = [] instead of arr= []

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mad the changes. Thanks for Notifying

event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
end
when Array
# Forward
entries.each do |entry|
epochtime = entry[0]
map = entry[1]
event = LogStash::Event.new(map.merge(
arr= []
event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
end
when Fixnum
# Message
epochtime = entries
map = data[2]
event = LogStash::Event.new(map.merge(
arr = []
event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
else
raise(LogStash::Error, "Unknown event type")
Expand Down