logstash-output-newrelic 1.0.5.pre.beta → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab807cb889166e953912511aea7ed369826f33eb682a38132b92ce80dcc8ce53
4
- data.tar.gz: 9f6a065d41735423e91a70de67098251d1f46d4f23595b683e4a191ff0b5d7df
3
+ metadata.gz: e227255c0f05ab2bbd664c45fd3ed25e7edfc9e15481255052688c5dfd1ddd2e
4
+ data.tar.gz: f3add56ccb74bac8b9f6106f9862254250c6adab4d79723c9fb89940dd5f2c5d
5
5
  SHA512:
6
- metadata.gz: bc33bfc42f9ef925200fa214b9e37964dc62c4e5a7ed1e492f3bba5a25a7a5b09657683009f90b3e7a9a033d9769511bebdb0e1cda87357e57c0356e0a5e702b
7
- data.tar.gz: 84f94a970f6371fd18c3f8344f6bb587bd56cdc7347beb83bacd006bb8b5fd8578fdbce4922d7e1249bdca657d997ca71ec5e2d9db1bb596da15e791e36a4600
6
+ metadata.gz: 5b1e8ffc8dacea562486112bdca20cff806da7b21336d3e03612cda334fbb0882c26b6f3ce6e230f1f53c5b8e56627bd675009b0c4bc2741d2628999a434375c
7
+ data.tar.gz: 6bd40c68709a7c1fc63bcb9002e538b49a340526c00e617cdfb3e7b988393b705b12179732cf4a93fcab05dad067789e8c1219b3466483d248d3d23878b1f39f
@@ -49,17 +49,18 @@ class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
49
49
 
50
50
  def encode(event_hash)
51
51
  log_message_hash = {
52
- :attributes => {}
52
+ # non-intrinsic attributes get put into 'attributes'
53
+ :attributes => event_hash
53
54
  }
54
55
 
55
- event_hash.each do |key, value|
56
- if key == 'message' || key == 'timestamp'
57
- # intrinsic attributes go at the top level
58
- log_message_hash[key] = value
59
- else
60
- # non-intrinsic attributes get put into 'attributes'
61
- log_message_hash[:attributes][key] = value
62
- end
56
+ # intrinsic attributes go at the top level
57
+ if event_hash['message']
58
+ log_message_hash['message'] = event_hash['message']
59
+ log_message_hash[:attributes].delete('message')
60
+ end
61
+ if event_hash['timestamp']
62
+ log_message_hash['timestamp'] = event_hash['timestamp']
63
+ log_message_hash[:attributes].delete('timestamp')
63
64
  end
64
65
 
65
66
  log_message_hash
@@ -101,11 +102,22 @@ class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
101
102
  end
102
103
 
103
104
  def sleep_duration(attempt)
104
- [max_delay, (2 ** attempt) * retry_seconds].min
105
+ if attempt == 0
106
+ return 0
107
+ end
108
+
109
+ [max_delay, (2 ** (attempt - 1)) * retry_seconds].min
110
+ end
111
+
112
+ def sleep_on_retry(attempt)
113
+ duration = sleep_duration(attempt)
114
+ if duration > 0
115
+ sleep duration
116
+ end
105
117
  end
106
118
 
107
119
  def attempt_send(payload, attempt)
108
- sleep sleep_duration(attempt)
120
+ sleep_on_retry(attempt)
109
121
  attempt_send(payload, attempt + 1) unless was_successful?(nr_send(payload)) if should_retry?(attempt)
110
122
  end
111
123
 
@@ -1,7 +1,7 @@
1
1
  module LogStash
2
2
  module Outputs
3
3
  module NewRelicVersion
4
- VERSION = "1.0.5-beta"
4
+ VERSION = "1.0.7"
5
5
  end
6
6
  end
7
7
  end
@@ -224,12 +224,13 @@ describe LogStash::Outputs::NewRelic do
224
224
  @newrelic_output = LogStash::Plugin.lookup("output", "newrelic").new(specific_config)
225
225
  @newrelic_output.register
226
226
 
227
- expect(@newrelic_output.sleep_duration(0)).to equal(5)
228
- expect(@newrelic_output.sleep_duration(1)).to equal(10)
229
- expect(@newrelic_output.sleep_duration(2)).to equal(20)
230
- expect(@newrelic_output.sleep_duration(3)).to equal(40)
231
- expect(@newrelic_output.sleep_duration(4)).to equal(60)
232
- expect(@newrelic_output.sleep_duration(5)).to equal(60) # Never gets bigger than this
227
+ expect(@newrelic_output.sleep_duration(0)).to equal(0)
228
+ expect(@newrelic_output.sleep_duration(1)).to equal(5)
229
+ expect(@newrelic_output.sleep_duration(2)).to equal(10)
230
+ expect(@newrelic_output.sleep_duration(3)).to equal(20)
231
+ expect(@newrelic_output.sleep_duration(4)).to equal(40)
232
+ expect(@newrelic_output.sleep_duration(5)).to equal(60)
233
+ expect(@newrelic_output.sleep_duration(6)).to equal(60) # Never gets bigger than this
233
234
  end
234
235
 
235
236
  it "first call fails, should retry" do
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.0.5.pre.beta
4
+ version: 1.0.7
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-07-29 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -113,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">"
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 1.3.1
118
+ version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
121
  rubygems_version: 2.7.6