logstash_writer 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/logstash_writer.rb +5 -21
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56ff81449377331566f5125d7fa345461b53e1cd68722100ac35a109e67338a0
4
- data.tar.gz: cba2b98aa5bdb9955e857dd05ec9164d3c27c0eb9958a2b5934a2da54aa9c41c
3
+ metadata.gz: 0aee91f724739c7f2a3c573dc323048217ca5bcda61728bad1e0daa01b5b6928
4
+ data.tar.gz: 0e17940054d609ff3097b61b257d1488263c4eb1f13e6e5e3b14b00a9c561369
5
5
  SHA512:
6
- metadata.gz: 2e8eade114bd9db859908fff83df8a7da5ae5eaab00949adcbf6969dcf04770ad5d79ae72f61ce673b96a298d868a29710eaf3142ecac16e33c5620ff41ea7dd
7
- data.tar.gz: 5483adccb182f57023c0787328436d35d82f946e7b17823edb492b999d200152a2c4db53d963d47907d7d072dd416a14d1ed4448216ace4d8c0469aa338ec57e
6
+ metadata.gz: 7af085a2d487f1c21dedad9f7d897b219ae94047e5e38ce124a7a415f6a99e300220db21cb7ef3eaad3ad6cf474d68418b473bebe5d157b884acabebcf9e1ee0
7
+ data.tar.gz: 2c0fde510617bb7785deec8c7f16f7a21be006f9c2c087f07d50ae3e1d0ec278b285fdca288c97fc736a862d9e6438394fce45ecbd60113ccce025583750a993
data/README.md CHANGED
@@ -186,7 +186,7 @@ conduct](CODE_OF_CONDUCT.md).
186
186
  Unless otherwise stated, everything in this repo is covered by the following
187
187
  copyright notice:
188
188
 
189
- Copyright (C) 2015 Civilized Discourse Construction Kit, Inc.
189
+ Copyright (C) 2016,2017,2018 Civilized Discourse Construction Kit, Inc.
190
190
 
191
191
  This program is free software: you can redistribute it and/or modify it
192
192
  under the terms of the GNU General Public License version 3, as
@@ -8,8 +8,8 @@ require 'prometheus/client'
8
8
  #
9
9
  # Flings events, represented as JSON objects, to logstash using the
10
10
  # `json_lines` codec (over TCP). Doesn't do any munging or modification of
11
- # the event data given to it, other than adding `@timestamp` and
12
- # `[@metadata][_id]` fields if they do not already exist.
11
+ # the event data given to it, other than adding a `@timestamp` field if
12
+ # it doesn't already exist.
13
13
  #
14
14
  # We support highly-available logstash installations by means of multiple
15
15
  # address records, or via SRV records. See the docs for .new for details
@@ -104,8 +104,8 @@ class LogstashWriter
104
104
 
105
105
  # Add an event to the queue, to be sent to logstash. Actual event
106
106
  # delivery will happen in a worker thread that is started with
107
- # #run. If the event does not have a `@timestamp` or `[@metadata][_id]`
108
- # element, they will be added with appropriate values.
107
+ # #run. If the event does not have a `@timestamp` field, it will
108
+ # be added set to the current time.
109
109
  #
110
110
  # @param e [Hash] the event data to be sent.
111
111
  #
@@ -120,22 +120,6 @@ class LogstashWriter
120
120
  e[:@timestamp] = Time.now.utc.strftime("%FT%T.%NZ")
121
121
  end
122
122
 
123
- if e.has_key?("@metadata")
124
- e[:@metadata] = (e[:@metadata] || {}).merge(e.delete("@metadata"))
125
- end
126
-
127
- unless e.has_key?(:@metadata)
128
- e[:@metadata] = {}
129
- end
130
-
131
- unless e[:@metadata].has_key?(:_id) || e.has_key?("_id")
132
- # This is the quickest way I've found to get a long, random string.
133
- # We don't need any sort of cryptographic or unpredictability
134
- # guarantees for what we're doing here, so SecureRandom is unnecessary
135
- # overhead.
136
- e[:@metadata][:_id] = rand(0x1000_0000_0000_0000_0000_0000_0000_0000).to_s(36)
137
- end
138
-
139
123
  @queue_mutex.synchronize do
140
124
  @queue << { content: e, arrival_timestamp: Time.now }
141
125
  while @queue.length > @backlog
@@ -303,7 +287,7 @@ class LogstashWriter
303
287
  # server and recycle
304
288
  @metrics[:write_exception].increment(server: @current_target.describe_peer, class: ex.class.to_s)
305
289
  @metrics[:connected].set({ server: @current_target.describe_peer }, 0)
306
- @logger.info("LogstashWriter") { "Error while writing to current server #{@current_target.describe_peer}: #{ex.message} (#{ex.class})" }
290
+ @logger.error("LogstashWriter") { "Error while writing to current server #{@current_target.describe_peer}: #{ex.message} (#{ex.class})" }
307
291
  @current_target.close
308
292
  @current_target = nil
309
293
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash_writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer