logstash-output-newrelic 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 919ba065702c9f7774dd7898efa8a0c830005c042d626d0d9702436ddc04041e
4
- data.tar.gz: 291a24c6aee606b51a571510d00f82038b2b343ac8fb883a6cdf0931cdab4892
3
+ metadata.gz: f099ad9c408ec722141c72268c3bdc038adbe98c0760da028f5149f87077a0eb
4
+ data.tar.gz: 45817bcb9ada5fa8ca81a57f102878fc752111f7a0b7e3d3a7fc9c681a6df480
5
5
  SHA512:
6
- metadata.gz: '056379637da0ddc0534dd534d9ab2641a1e10717054f48f722f18cf4bf412871ba21d820d32ffae0a6982575f67ee36842a84f3e30fb5257376c4de3baadc03c'
7
- data.tar.gz: 6e53748461e7cd38826ae76e37e7c35a7fc0630c7315ee691a800e7a7f6275f396270807888fd3d3a09381b32af3baa7034c70ca20374a51d51b8b51138e56b0
6
+ metadata.gz: de3784b9f1ca8300c99a7adea011e95b5ac5140ffd01d7a18dfc6cf5c5c5bbd2767cc4ac519e763bea7e0e7d12a509b9dcde98cc890b52d41ae901d750086511
7
+ data.tar.gz: acfc744ccc74de945848c3b76ade20b6e858fce52d1951e1533b302a2c55b4ae2f6156f507a8b0f949967981a5a304f293973f632f8c3863ab04fc1f1463a82b
@@ -0,0 +1,26 @@
1
+ # Developing the plugin
2
+
3
+ # Getting started
4
+
5
+ * Install JRuby: `rbenv install jruby-9.2.5.0`
6
+ * Use that JRuby: `rbenv local jruby-9.2.5.0`
7
+ * Install Bundler gem: `jruby -S gem install bundler`
8
+
9
+ # Developing
10
+
11
+ * Install dependencies: `jruby -S bundle install`
12
+ * Write tests and production code!
13
+ * Bump version: edit version file `version.rb`
14
+ * Run tests: `jruby -S bundle exec rspec`
15
+ * Build the gem: `jruby -S gem build logstash-output-newrelic.gemspec`
16
+
17
+ # Testing it with a local Logstash install
18
+
19
+ Note: you may need to run the following commands outside of your checkout, since these should not
20
+ be run with the JRuby version that you've configured your checkout to use (by using rbenv).
21
+
22
+ * Remove previous version: `logstash-plugin remove logstash-output-newrelic`
23
+ * Add new version: `logstash-plugin install logstash-output-newrelic-<version>.gem`
24
+ * Restart logstash: For Homebrew: `brew services restart logstash`
25
+ * Cause a change that you've configured Logstash to pick up (for instance, append to a file you're having it monitor)
26
+ * Look in `https://one.newrelic.com/launcher/logger.log-launcher` for your log message
@@ -0,0 +1,24 @@
1
+ require 'bigdecimal'
2
+
3
+ class BigDecimal
4
+ # Floating-point numbers that go through the 'json' Logstash filter get automatically converted into BigDecimals.
5
+ # Example of such a filter:
6
+ #
7
+ # filter {
8
+ # json {
9
+ # source => "message"
10
+ # }
11
+ # }
12
+ #
13
+ # The problem is that { "value" => BigDecimal('0.12345') } gets serialized into { "value": "0.12345e0"}. We do
14
+ # want to keep floating point numbers serialized as floating point numbers, even at the expense of loosing a little
15
+ # bit of precision during the conversion. So, in the above example, the correct serialization would be:
16
+ # { "value": 0.12345}
17
+ def to_json(options = nil) #:nodoc:
18
+ if finite?
19
+ self.to_f.to_s
20
+ else
21
+ 'null'
22
+ end
23
+ end
24
+ end
@@ -6,6 +6,7 @@ require 'uri'
6
6
  require 'zlib'
7
7
  require 'json'
8
8
  require 'java'
9
+ require_relative './config/bigdecimal_patch'
9
10
 
10
11
  class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
11
12
  java_import java.util.concurrent.Executors;
@@ -1,7 +1,7 @@
1
1
  module LogStash
2
2
  module Outputs
3
3
  module NewRelicVersion
4
- VERSION = "1.1.3"
4
+ VERSION = "1.1.4"
5
5
  end
6
6
  end
7
7
  end
@@ -21,7 +21,6 @@ describe LogStash::Outputs::NewRelic do
21
21
  }
22
22
  }
23
23
 
24
-
25
24
  before(:each) do
26
25
  @newrelic_output = LogStash::Plugin.lookup("output", "newrelic").new(simple_config)
27
26
  @newrelic_output.register
@@ -32,6 +31,7 @@ describe LogStash::Outputs::NewRelic do
32
31
  @newrelic_output.shutdown
33
32
  end
34
33
  end
34
+
35
35
  context "license key tests" do
36
36
  it "sets license key when given in the header" do
37
37
  stub_request(:any, base_uri).to_return(status: 200)
@@ -280,4 +280,48 @@ describe LogStash::Outputs::NewRelic do
280
280
  .to have_been_made
281
281
  end
282
282
  end
283
+
284
+ context "JSON serialization" do
285
+ it "serializes floating point numbers as floating point numbers" do
286
+ stub_request(:any, base_uri).to_return(status: 200)
287
+
288
+ event = LogStash::Event.new({ "floatingpoint" => 0.12345 })
289
+ @newrelic_output.multi_receive([event])
290
+
291
+ wait_for(a_request(:post, base_uri)
292
+ .with { |request|
293
+ message = single_gzipped_message(request.body)
294
+ message['attributes']['floatingpoint'] == 0.12345
295
+ }
296
+ ).to have_been_made
297
+ end
298
+
299
+ it "serializes BigDecimals as floating point numbers" do
300
+ stub_request(:any, base_uri).to_return(status: 200)
301
+
302
+ event = LogStash::Event.new({ "bigdecimal" => BigDecimal('0.12345') })
303
+ @newrelic_output.multi_receive([event])
304
+
305
+ wait_for(a_request(:post, base_uri)
306
+ .with { |request|
307
+ message = single_gzipped_message(request.body)
308
+ message['attributes']['bigdecimal'] == 0.12345
309
+ }
310
+ ).to have_been_made
311
+ end
312
+
313
+ it "serializes NaN as null" do
314
+ stub_request(:any, base_uri).to_return(status: 200)
315
+
316
+ event = LogStash::Event.new({ "nan" => BigDecimal('NaN') })
317
+ @newrelic_output.multi_receive([event])
318
+
319
+ wait_for(a_request(:post, base_uri)
320
+ .with { |request|
321
+ message = single_gzipped_message(request.body)
322
+ message['attributes']['nan'] == nil
323
+ }
324
+ ).to have_been_made
325
+ end
326
+ end
283
327
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - New Relic Logging Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-22 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -116,9 +116,11 @@ extra_rdoc_files: []
116
116
  files:
117
117
  - CHANGELOG.md
118
118
  - CONTRIBUTORS
119
+ - DEVELOPER.md
119
120
  - Gemfile
120
121
  - LICENSE
121
122
  - README.md
123
+ - lib/logstash/outputs/config/bigdecimal_patch.rb
122
124
  - lib/logstash/outputs/newrelic.rb
123
125
  - lib/logstash/outputs/newrelic_version/version.rb
124
126
  - logstash-output-newrelic.gemspec