Skip to content

Commit

Permalink
refactor: factorize process event between udp and tcp
Browse files Browse the repository at this point in the history
  • Loading branch information
Cactusbone committed Mar 7, 2023
1 parent eafb220 commit 8847b43
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/logstash/inputs/gelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ def tcp_listener(output_queue)
event = self.class.new_event(data_in, client.peeraddr[3])
next if event.nil?

remap_gelf(event) if @remap
strip_leading_underscore(event) if @strip_leading_underscore
decorate(event)
process_event(event)
output_queue << event
end

Expand Down Expand Up @@ -206,9 +204,7 @@ def udp_listener(output_queue)
event = self.class.new_event(data, client[3])
next if event.nil?

remap_gelf(event) if @remap
strip_leading_underscore(event) if @strip_leading_underscore
decorate(event)
process_event(event)

output_queue << event
end
Expand Down Expand Up @@ -236,6 +232,12 @@ def self.new_event(json_gelf, host)
event
end

def process_event(event)
remap_gelf(event) if @remap
strip_leading_underscore(event) if @strip_leading_underscore
decorate(event)
end

# transform a given timestamp value into a proper LogStash::Timestamp, preserving microsecond precision
# and work around a JRuby issue with Time.at loosing fractional part with BigDecimal.
# @param timestamp [Numeric] a Numeric (integer, float or bigdecimal) timestampo representation
Expand Down

0 comments on commit 8847b43

Please sign in to comment.