newrelic_plugin 1.3.0 → 1.3.1

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.
@@ -1,8 +1,10 @@
1
1
  ## New Relic Ruby SDK Change Log ##
2
2
 
3
- ### vNext - Future Date ###
3
+ ### v1.3.1 - November 4, 2013 ###
4
4
 
5
- **Features**
5
+ **Bug Fixes**
6
+
7
+ * Properly handle null values in epoch_counter_processor
6
8
 
7
9
  ### v1.3.0 - October 3, 2013 ###
8
10
 
@@ -1,21 +1,26 @@
1
1
  module NewRelic::Processor
2
2
  class EpochCounter<NewRelic::Plugin::Processor::Base
3
3
  def initialize
4
- super :epoch_counter,"Epoch Counter"
4
+ super :epoch_counter, "Epoch Counter"
5
5
  end
6
+
6
7
  def process val
7
- val=val.to_f
8
- ret=nil
9
- curr_time=Time.now
10
- if @last_value and @last_time and curr_time>@last_time
11
- ret=(val-@last_value)/(curr_time-@last_time).to_f
8
+ ret = nil
9
+ curr_time = Time.now
10
+
11
+ if val && @last_value && @last_time && curr_time > @last_time
12
+ val = val.to_f
13
+ ret = (val - @last_value.to_f) / (curr_time - @last_time).to_f
12
14
  end
13
- @last_value=val
14
- @last_time=curr_time
15
+
16
+ @last_value = val
17
+ @last_time = curr_time
18
+
15
19
  # This next line is to avoid large negative spikes during epoch reset events...
16
- return nil if ret.nil? or ret<0
20
+ return nil if ret.nil? || ret < 0
17
21
  ret
18
22
  end
23
+
19
24
  #Component::Setup.install_processor EpochCounter
20
25
  end
21
26
  end
@@ -1,5 +1,5 @@
1
1
  module NewRelic
2
2
  module Plugin
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency "minitest", '>= 5.0.6'
34
34
  s.add_development_dependency 'fakeweb'
35
35
  s.add_development_dependency 'pry'
36
- s.add_development_dependency 'timecop'
36
+ s.add_development_dependency 'timecop', '= 0.6.1'
37
37
 
38
38
  s.files = `git ls-files`.split($\)
39
39
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -0,0 +1,61 @@
1
+ require 'test_helper'
2
+
3
+ class EpochCounterTest < Minitest::Test
4
+
5
+ def test_with_two_valid_pollcycles
6
+ @counter = NewRelic::Processor::EpochCounter.new
7
+ firstProcess = @counter.process(5)
8
+ modify_counter_clock(@counter, 1)
9
+ secondProcess = @counter.process(6)
10
+
11
+ assert_nil(firstProcess)
12
+ assert(secondProcess > 0)
13
+ end
14
+
15
+ def test_with_null_second_pollcycle
16
+ @counter = NewRelic::Processor::EpochCounter.new
17
+ firstProcess = @counter.process(5)
18
+ modify_counter_clock(@counter, 1)
19
+ secondProcess = @counter.process(nil)
20
+ modify_counter_clock(@counter, 1)
21
+ thirdProcess = @counter.process(6)
22
+ modify_counter_clock(@counter, 1)
23
+ fourthProcess = @counter.process(7)
24
+
25
+ assert_nil(firstProcess)
26
+ assert_nil(secondProcess)
27
+ assert_nil(thirdProcess)
28
+ assert(fourthProcess > 0)
29
+ end
30
+
31
+ def test_with_null_first_pollcycle
32
+ @counter = NewRelic::Processor::EpochCounter.new
33
+ firstProcess = @counter.process(nil)
34
+ modify_counter_clock(@counter, 1)
35
+ secondProcess = @counter.process(5)
36
+ modify_counter_clock(@counter, 1)
37
+ thirdProcess = @counter.process(6)
38
+
39
+ assert_nil(firstProcess)
40
+ assert_nil(secondProcess)
41
+ assert(thirdProcess > 0)
42
+ end
43
+
44
+ def test_with_string_values
45
+ @counter = NewRelic::Processor::EpochCounter.new
46
+ firstProcess = @counter.process("5")
47
+ modify_counter_clock(@counter, 1)
48
+ secondProcess = @counter.process("6")
49
+ modify_counter_clock(@counter, 1)
50
+ thirdProcess = @counter.process(7)
51
+
52
+ assert_nil(firstProcess)
53
+ assert(secondProcess > 0)
54
+ assert(thirdProcess > 0)
55
+ end
56
+
57
+ def modify_counter_clock(counter, seconds)
58
+ time = counter.instance_variable_get(:@last_time)
59
+ counter.instance_variable_set(:@last_time, counter.instance_variable_get(:@last_time) - seconds)
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-09 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -96,17 +96,17 @@ dependencies:
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: '0'
101
+ version: 0.6.1
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - ! '>='
107
+ - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 0.6.1
110
110
  description: The New Relic Plugin Gem is used to send plugin data to New Relic from
111
111
  non-application sources.
112
112
  email:
@@ -152,6 +152,7 @@ files:
152
152
  - test/newrelic_platform_binding/platform_logger_test.rb
153
153
  - test/newrelic_platform_binding/request_test.rb
154
154
  - test/newrelic_plugin/agent_test.rb
155
+ - test/newrelic_plugin/epoch_counter_processor_test.rb
155
156
  - test/newrelic_plugin/run_test.rb
156
157
  - test/newrelic_plugin/setup_test.rb
157
158
  - test/test_helper.rb