newrelic_rpm 3.1.0 → 3.1.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +3 -0
- data/lib/new_relic/agent.rb +29 -12
- data/lib/new_relic/agent/agent.rb +355 -78
- data/lib/new_relic/agent/beacon_configuration.rb +49 -7
- data/lib/new_relic/agent/browser_monitoring.rb +20 -1
- data/lib/new_relic/agent/busy_calculator.rb +11 -3
- data/lib/new_relic/agent/chained_call.rb +2 -2
- data/lib/new_relic/agent/error_collector.rb +229 -183
- data/lib/new_relic/agent/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +5 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +5 -1
- data/lib/new_relic/agent/instrumentation/authlogic.rb +4 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +16 -5
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +5 -1
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +5 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +5 -1
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +0 -5
- data/lib/new_relic/agent/instrumentation/net.rb +5 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -3
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +5 -1
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +13 -6
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +5 -1
- data/lib/new_relic/agent/method_tracer.rb +205 -99
- data/lib/new_relic/agent/shim_agent.rb +0 -1
- data/lib/new_relic/agent/stats_engine.rb +1 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +23 -7
- data/lib/new_relic/agent/stats_engine/samplers.rb +8 -2
- data/lib/new_relic/agent/stats_engine/transactions.rb +26 -12
- data/lib/new_relic/agent/transaction_sampler.rb +3 -1
- data/lib/new_relic/agent/worker_loop.rb +13 -5
- data/lib/new_relic/collection_helper.rb +6 -3
- data/lib/new_relic/control.rb +1 -3
- data/lib/new_relic/control/class_methods.rb +8 -3
- data/lib/new_relic/control/configuration.rb +24 -5
- data/lib/new_relic/control/frameworks.rb +10 -0
- data/lib/new_relic/control/frameworks/external.rb +4 -4
- data/lib/new_relic/control/frameworks/merb.rb +1 -0
- data/lib/new_relic/control/frameworks/rails.rb +5 -5
- data/lib/new_relic/control/frameworks/rails3.rb +5 -3
- data/lib/new_relic/control/frameworks/ruby.rb +5 -5
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -4
- data/lib/new_relic/control/instance_methods.rb +23 -7
- data/lib/new_relic/control/instrumentation.rb +22 -3
- data/lib/new_relic/control/logging_methods.rb +25 -7
- data/lib/new_relic/control/server_methods.rb +16 -6
- data/lib/new_relic/data_serialization.rb +83 -14
- data/lib/new_relic/delayed_job_injection.rb +7 -1
- data/lib/new_relic/local_environment.rb +55 -25
- data/lib/new_relic/metric_data.rb +7 -2
- data/lib/new_relic/metric_spec.rb +5 -3
- data/lib/new_relic/stats.rb +16 -7
- data/lib/new_relic/transaction_analysis.rb +2 -1
- data/lib/new_relic/transaction_analysis/segment_summary.rb +4 -2
- data/lib/new_relic/transaction_sample.rb +33 -7
- data/lib/new_relic/transaction_sample/segment.rb +21 -3
- data/lib/new_relic/version.rb +2 -2
- data/newrelic_rpm.gemspec +7 -11
- data/test/config/newrelic.yml +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -4
- data/test/new_relic/agent/agent_test.rb +16 -0
- data/test/new_relic/agent/agent_test_controller.rb +1 -1
- data/test/new_relic/agent/agent_test_controller_test.rb +14 -19
- data/test/new_relic/agent/beacon_configuration_test.rb +2 -2
- data/test/new_relic/agent/browser_monitoring_test.rb +7 -3
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +13 -4
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -10
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent_test.rb +168 -0
- data/test/new_relic/collection_helper_test.rb +21 -3
- data/test/new_relic/control/configuration_test.rb +25 -0
- data/test/new_relic/data_serialization_test.rb +58 -3
- data/test/new_relic/delayed_job_injection_test.rb +17 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +14 -0
- data/test/new_relic/transaction_analysis_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +11 -0
- data/test/test_helper.rb +1 -1
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +4 -18
- metadata +13 -13
- data/lib/new_relic/histogram.rb +0 -91
- data/lib/new_relic/rack/metric_app.rb +0 -65
- data/lib/new_relic/rack/mongrel_rpm.ru +0 -28
- data/lib/new_relic/rack/newrelic.yml +0 -27
- data/lib/new_relic/rack_app.rb +0 -6
- data/vendor/gems/dependency_detection-0.0.1.build/README +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/LICENSE +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/README +0 -0
@@ -117,11 +117,29 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
117
117
|
#puts e.backtrace.grep(/trace/).join("\n")
|
118
118
|
#puts "\n\n"
|
119
119
|
clean_trace = strip_nr_from_backtrace(e.backtrace)
|
120
|
-
assert_equal
|
121
|
-
|
122
|
-
|
120
|
+
assert_equal(0, clean_trace.grep(/newrelic_rpm/).size,
|
121
|
+
"should remove all instances of new relic from backtrace but got: #{clean_trace.join("\n")}")
|
122
|
+
assert_equal(0, clean_trace.grep(/trace/).size,
|
123
|
+
"should remove trace method tags from method names but got: #{clean_trace.join("\n")}")
|
124
|
+
assert((clean_trace.grep(/find/).size >= 3),
|
125
|
+
"should see at least three frames with 'find' in them (#{e}): \n#{clean_trace.join("\n")}")
|
123
126
|
ensure
|
124
127
|
ActiveRecordFixtures.teardown
|
125
128
|
end
|
126
129
|
end if defined?(::ActiveRecord)
|
130
|
+
|
131
|
+
def test_disabled_strip_backtrace
|
132
|
+
NewRelic::Control.instance['disable_backtrace_cleanup'] = true
|
133
|
+
begin
|
134
|
+
flunk "should throw"
|
135
|
+
rescue => e
|
136
|
+
clean_trace = strip_nr_from_backtrace(e.backtrace)
|
137
|
+
assert_equal(1, clean_trace.grep(/new_relic/).size,
|
138
|
+
"should not remove instances of new relic from backtrace but got: #{clean_trace.join("\n")}")
|
139
|
+
assert_equal(1, clean_trace.grep(/trace/).size,
|
140
|
+
"should not remove trace method tags from method names but got: #{clean_trace.join("\n")}")
|
141
|
+
# assert (clean_trace.grep(/find/).size >= 3), "should see at least three frames with 'find' in them (#{e}): \n#{clean_trace.join("\n")}"
|
142
|
+
end
|
143
|
+
NewRelic::Control.instance['disable_backtrace_cleanup'] = false
|
144
|
+
end
|
127
145
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
|
2
|
+
class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
|
3
|
+
require 'new_relic/control/configuration'
|
4
|
+
include NewRelic::Control::Configuration
|
5
|
+
def test_license_key_defaults_to_env_variable
|
6
|
+
ENV['NEWRELIC_LICENSE_KEY'] = nil
|
7
|
+
self.expects(:fetch).with('license_key', nil)
|
8
|
+
license_key
|
9
|
+
|
10
|
+
ENV['NEWRELIC_LICENSE_KEY'] = "a string"
|
11
|
+
self.expects(:fetch).with('license_key', 'a string')
|
12
|
+
license_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_log_file_path_uses_default_if_not_set
|
16
|
+
root = ::Rails::VERSION::MAJOR == 3 ? Rails.root : RAILS_ROOT
|
17
|
+
assert_equal(File.join(root, 'log'),
|
18
|
+
NewRelic::Control.instance.log_file_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_log_file_path_uses_given_value
|
22
|
+
NewRelic::Control.instance['log_file_path'] = '/lerg'
|
23
|
+
assert_equal '/lerg', NewRelic::Control.instance.log_file_path
|
24
|
+
end
|
25
|
+
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
2
2
|
require 'new_relic/data_serialization'
|
3
3
|
class NewRelic::DataSerializationTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
NewRelic::Control.instance['log_file_path'] = './log'
|
7
|
+
FileUtils.rm_rf('./log/newrelic_agent_store.db')
|
8
|
+
FileUtils.rm_rf('./log/newrelic_agent_store.age')
|
9
|
+
end
|
10
|
+
|
4
11
|
def test_read_and_write_from_file_read_only
|
5
12
|
file = './log/newrelic_agent_store.db'
|
6
13
|
File.open(file, 'w') do |f|
|
@@ -55,16 +62,64 @@ class NewRelic::DataSerializationTest < Test::Unit::TestCase
|
|
55
62
|
assert(NewRelic::DataSerialization.should_send_data?, 'Should be over limit')
|
56
63
|
end
|
57
64
|
|
65
|
+
def test_read_until_eoferror
|
66
|
+
file = './log/newrelic_agent_store.db'
|
67
|
+
File.open(file, 'w') do |f|
|
68
|
+
f.write("a" * 10_001)
|
69
|
+
end
|
70
|
+
value = ""
|
71
|
+
File.open(file,'r') do |f|
|
72
|
+
value << NewRelic::DataSerialization.instance_eval { read_until_eof_error(f) }
|
73
|
+
end
|
74
|
+
assert_equal('a' * 10_001, value, "should retrieve all the contents from the string and not raise EOFerrors")
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_write_contents_nonblockingly
|
78
|
+
file = './log/newrelic_agent_store.db'
|
79
|
+
File.open(file, 'w') do |f|
|
80
|
+
f.write("") # write nothing! NOTHING
|
81
|
+
end
|
82
|
+
|
83
|
+
File.open(file, 'w') do |f|
|
84
|
+
NewRelic::DataSerialization.instance_eval { write_contents_nonblockingly(f, 'a' * 10_001) }
|
85
|
+
end
|
86
|
+
value = File.read(file)
|
87
|
+
assert_equal('a' * 10_001, value, "should write a couple thousand 'a's to a file without exploding")
|
88
|
+
end
|
89
|
+
|
58
90
|
def test_should_send_data_disabled
|
59
91
|
NewRelic::Control.instance.expects(:disable_serialization?).returns(true)
|
60
92
|
assert(NewRelic::DataSerialization.should_send_data?, 'should send data when disabled')
|
61
93
|
end
|
62
94
|
|
63
95
|
def test_should_send_data_under_limit
|
64
|
-
NewRelic::DataSerialization.expects(:max_size).returns(
|
65
|
-
NewRelic::DataSerialization.read_and_write_to_file do
|
96
|
+
NewRelic::DataSerialization.expects(:max_size).returns(2000)
|
97
|
+
NewRelic::DataSerialization.read_and_write_to_file do | old_data |
|
66
98
|
"a" * 5
|
67
99
|
end
|
68
|
-
|
100
|
+
|
101
|
+
assert(!NewRelic::DataSerialization.should_send_data?,
|
102
|
+
'Should be under the limit')
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_should_handle_empty_spool_file
|
106
|
+
NewRelic::Control.instance.log.expects(:error).never
|
107
|
+
assert_nil NewRelic::DataSerialization.instance_eval { load('') }
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_spool_file_location_respects_log_file_path_setting
|
111
|
+
NewRelic::Control.instance['log_file_path'] = "./tmp"
|
112
|
+
NewRelic::DataSerialization.read_and_write_to_file do |_|
|
113
|
+
'a' * 30
|
114
|
+
end
|
115
|
+
assert(File.exists?('./tmp/newrelic_agent_store.db'),
|
116
|
+
"Spool file not created at user specified location")
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_age_file_location_respects_log_file_path_setting
|
120
|
+
NewRelic::Control.instance['log_file_path'] = "./tmp"
|
121
|
+
NewRelic::DataSerialization.update_last_sent!
|
122
|
+
assert(File.exists?('./tmp/newrelic_agent_store.age'),
|
123
|
+
"Age file not created at user specified location")
|
69
124
|
end
|
70
125
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
2
|
+
module NewRelic
|
3
|
+
class DelayedJobInstrumentationTest < Test::Unit::TestCase
|
4
|
+
def test_skip_logging_if_no_logger_found
|
5
|
+
Object.const_set('Delayed', Module.new)
|
6
|
+
::Delayed.const_set('Worker', Class.new)
|
7
|
+
|
8
|
+
NewRelic::Agent.stubs(:logger).raises(NoMethodError,
|
9
|
+
'tempoarily not allowed')
|
10
|
+
NewRelic::Agent.stubs(:respond_to?).with(:logger).returns(false)
|
11
|
+
|
12
|
+
assert DependencyDetection.detect!
|
13
|
+
|
14
|
+
Object.class_eval { remove_const('Delayed') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -63,6 +63,20 @@ class NewRelic::TransactionAnalysis::SegmentSummaryTest < Test::Unit::TestCase
|
|
63
63
|
assert_equal 0.5, @ss.total_time_percentage
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_nesting_total_time
|
67
|
+
segment = mock('segment')
|
68
|
+
segment.expects(:metric_name).twice.returns('Controller/foo')
|
69
|
+
segment.expects(:duration).returns(0.1)
|
70
|
+
segment.expects(:exclusive_duration).returns(0)
|
71
|
+
@ss << segment
|
72
|
+
segment.expects(:exclusive_duration).returns(0.1)
|
73
|
+
@ss.current_nest_count += 1
|
74
|
+
@ss << segment
|
75
|
+
assert_equal 0.1, @ss.total_time
|
76
|
+
assert_equal 0.1, @ss.exclusive_time
|
77
|
+
assert_equal 2, @ss.call_count
|
78
|
+
end
|
79
|
+
|
66
80
|
def test_ui_name_default
|
67
81
|
@ss.metric_name = 'Remainder'
|
68
82
|
assert_equal 'Remainder', @ss.ui_name
|
@@ -28,7 +28,7 @@ class NewRelic::TransactionAnalysisTest < Test::Unit::TestCase
|
|
28
28
|
other_segment.expects(:metric_name).twice.returns('Controller/foo')
|
29
29
|
other_segment.expects(:duration).returns(0.1)
|
30
30
|
other_segment.expects(:exclusive_duration).returns(0.1)
|
31
|
-
self.expects(:
|
31
|
+
self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment)
|
32
32
|
self.expects(:root_segment).twice.returns(root_segment)
|
33
33
|
self.expects(:duration).returns(0.1)
|
34
34
|
data = breakdown_data
|
@@ -56,7 +56,7 @@ class NewRelic::TransactionAnalysisTest < Test::Unit::TestCase
|
|
56
56
|
yet_another.expects(:metric_name).twice.returns('Controller/bar')
|
57
57
|
yet_another.expects(:duration).returns(0.2)
|
58
58
|
yet_another.expects(:exclusive_duration).returns(0.2)
|
59
|
-
self.expects(:
|
59
|
+
self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment, yet_another)
|
60
60
|
self.expects(:root_segment).times(3).returns(root_segment)
|
61
61
|
self.expects(:duration).returns(0.1)
|
62
62
|
data = breakdown_data(1)
|
@@ -76,7 +76,7 @@ class NewRelic::TransactionAnalysisTest < Test::Unit::TestCase
|
|
76
76
|
other_segment.expects(:metric_name).twice.returns('Controller/foo')
|
77
77
|
other_segment.expects(:duration).returns(0.1)
|
78
78
|
other_segment.expects(:exclusive_duration).returns(0.1)
|
79
|
-
self.expects(:
|
79
|
+
self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment)
|
80
80
|
self.expects(:root_segment).twice.returns(root_segment)
|
81
81
|
self.expects(:duration).returns(0.2)
|
82
82
|
data = breakdown_data
|
@@ -313,6 +313,17 @@ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
|
|
313
313
|
assert_equal(2, count)
|
314
314
|
end
|
315
315
|
|
316
|
+
def test_each_segment_with_nest_tracking
|
317
|
+
s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
|
318
|
+
|
319
|
+
summary = mock('summary')
|
320
|
+
summary.expects(:current_nest_count).twice.returns(0).then.returns(1)
|
321
|
+
summary.expects(:current_nest_count=).twice
|
322
|
+
s.each_segment_with_nest_tracking do |x|
|
323
|
+
summary
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
316
327
|
def test_find_segment_default
|
317
328
|
s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
|
318
329
|
id_to_find = s.segment_id
|
data/test/test_helper.rb
CHANGED
@@ -101,7 +101,7 @@ end
|
|
101
101
|
|
102
102
|
|
103
103
|
def compare_metrics(expected, actual)
|
104
|
-
actual.
|
104
|
+
actual.delete_if {|a| a.include?('GC/cumulative') } # in case we are in REE
|
105
105
|
assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}")
|
106
106
|
end
|
107
107
|
|
@@ -1,19 +1,5 @@
|
|
1
|
-
Copyright (c) 2010-2011
|
1
|
+
Copyright (c) 2010-2011 New Relic, Inc. All rights reserved.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
3
|
+
This code is, and has always been, copyright New Relic and licensed
|
4
|
+
under our license terms that can be found in master license file
|
5
|
+
located here: ../../../../LICENSE
|
metadata
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 62196441
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
9
|
+
- 1
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 3.1.1.beta1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Bill Kayser
|
16
|
+
- Jon Guymon
|
14
17
|
- Justin George
|
18
|
+
- Darin Swanson
|
15
19
|
autorequire:
|
16
20
|
bindir: bin
|
17
21
|
cert_chain: []
|
18
22
|
|
19
|
-
date: 2011-06
|
23
|
+
date: 2011-07-06 00:00:00 -07:00
|
20
24
|
default_executable:
|
21
25
|
dependencies:
|
22
26
|
- !ruby/object:Gem::Dependency
|
@@ -148,6 +152,7 @@ files:
|
|
148
152
|
- lib/new_relic/control.rb
|
149
153
|
- lib/new_relic/control/class_methods.rb
|
150
154
|
- lib/new_relic/control/configuration.rb
|
155
|
+
- lib/new_relic/control/frameworks.rb
|
151
156
|
- lib/new_relic/control/frameworks/external.rb
|
152
157
|
- lib/new_relic/control/frameworks/merb.rb
|
153
158
|
- lib/new_relic/control/frameworks/rails.rb
|
@@ -161,7 +166,6 @@ files:
|
|
161
166
|
- lib/new_relic/control/server_methods.rb
|
162
167
|
- lib/new_relic/data_serialization.rb
|
163
168
|
- lib/new_relic/delayed_job_injection.rb
|
164
|
-
- lib/new_relic/histogram.rb
|
165
169
|
- lib/new_relic/local_environment.rb
|
166
170
|
- lib/new_relic/merbtasks.rb
|
167
171
|
- lib/new_relic/metric_data.rb
|
@@ -170,10 +174,6 @@ files:
|
|
170
174
|
- lib/new_relic/noticed_error.rb
|
171
175
|
- lib/new_relic/rack/browser_monitoring.rb
|
172
176
|
- lib/new_relic/rack/developer_mode.rb
|
173
|
-
- lib/new_relic/rack/metric_app.rb
|
174
|
-
- lib/new_relic/rack/mongrel_rpm.ru
|
175
|
-
- lib/new_relic/rack/newrelic.yml
|
176
|
-
- lib/new_relic/rack_app.rb
|
177
177
|
- lib/new_relic/recipes.rb
|
178
178
|
- lib/new_relic/stats.rb
|
179
179
|
- lib/new_relic/timer_lib.rb
|
@@ -232,12 +232,15 @@ files:
|
|
232
232
|
- test/new_relic/agent/transaction_sample_builder_test.rb
|
233
233
|
- test/new_relic/agent/transaction_sampler_test.rb
|
234
234
|
- test/new_relic/agent/worker_loop_test.rb
|
235
|
+
- test/new_relic/agent_test.rb
|
235
236
|
- test/new_relic/collection_helper_test.rb
|
236
237
|
- test/new_relic/command/deployments_test.rb
|
237
238
|
- test/new_relic/control/class_methods_test.rb
|
239
|
+
- test/new_relic/control/configuration_test.rb
|
238
240
|
- test/new_relic/control/logging_methods_test.rb
|
239
241
|
- test/new_relic/control_test.rb
|
240
242
|
- test/new_relic/data_serialization_test.rb
|
243
|
+
- test/new_relic/delayed_job_injection_test.rb
|
241
244
|
- test/new_relic/local_environment_test.rb
|
242
245
|
- test/new_relic/metric_data_test.rb
|
243
246
|
- test/new_relic/metric_spec_test.rb
|
@@ -288,11 +291,8 @@ files:
|
|
288
291
|
- ui/views/newrelic/show_source.rhtml
|
289
292
|
- ui/views/newrelic/threads.rhtml
|
290
293
|
- vendor/gems/dependency_detection-0.0.1.build/LICENSE
|
291
|
-
- vendor/gems/dependency_detection-0.0.1.build/README
|
292
294
|
- vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb
|
293
295
|
- vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb
|
294
|
-
- vendor/gems/metric_parser-0.1.0.pre1/LICENSE
|
295
|
-
- vendor/gems/metric_parser-0.1.0.pre1/README
|
296
296
|
- vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb
|
297
297
|
- vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb
|
298
298
|
- vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb
|
data/lib/new_relic/histogram.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
# Histogram is used for organizing response times
|
2
|
-
# into an 'Exponential Histogram'. Feature based in part on DHH proposal:
|
3
|
-
# http://37signals.com/svn/posts/1836-the-problem-with-averages
|
4
|
-
#
|
5
|
-
# Histogram builds a set of buckets of geometrically growing size, with the assumption that most
|
6
|
-
# apps have long-tail response times, and therefore you need the most granularity at the lowest
|
7
|
-
# r/t level.
|
8
|
-
module NewRelic
|
9
|
-
class Histogram
|
10
|
-
|
11
|
-
# Used to stub out API methods when the agent is not enabled
|
12
|
-
module Shim
|
13
|
-
def process(response_time); end
|
14
|
-
end
|
15
|
-
# Stores statistics for response times falling in a particular range.
|
16
|
-
# A bucket has a min and max response time. A response time event
|
17
|
-
# falls in a bucket if min <= r/t < max. A bucket also
|
18
|
-
# has an associated metric for reporting data to New Relic. The
|
19
|
-
# bucket range is encoded in the metic name
|
20
|
-
class Bucket
|
21
|
-
|
22
|
-
attr_reader :min, :max, :stats
|
23
|
-
|
24
|
-
def initialize(min, max = nil)
|
25
|
-
@min = min
|
26
|
-
@max = max
|
27
|
-
end
|
28
|
-
|
29
|
-
def stats
|
30
|
-
NewRelic::Agent.get_stats("Response Times/#{min_millis}/#{max_millis}")
|
31
|
-
end
|
32
|
-
|
33
|
-
# This has return value like <=> but does something more
|
34
|
-
# than simply compare. If the value falls within range for
|
35
|
-
# the bucket, increment count and return 0; otherwise return
|
36
|
-
# a value < 0 if the value belongs in a bucket with a lower range
|
37
|
-
# you can guess what it returns if the value belongs in a bucket
|
38
|
-
# with a higher range. (Hint: it's not 0, and it's not less than zero.)
|
39
|
-
def process(value)
|
40
|
-
if value < min
|
41
|
-
return -1
|
42
|
-
|
43
|
-
# max == nil means unlimited max (last bucket)
|
44
|
-
elsif max && value >= max
|
45
|
-
return 1
|
46
|
-
|
47
|
-
else
|
48
|
-
stats.record_data_point(value)
|
49
|
-
return 0
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def min_millis
|
54
|
-
(min * 1000).round
|
55
|
-
end
|
56
|
-
|
57
|
-
def max_millis
|
58
|
-
max.nil? ? nil : (max * 1000).round
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_s
|
62
|
-
"#{min_millis} - #{max_millis}: #{stats.call_count}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
attr_reader :buckets
|
67
|
-
|
68
|
-
# Histogram uses apdex T / 10 as its minimum bucket size, and grows from there.
|
69
|
-
# 30 data points should be adequate resolution.
|
70
|
-
def initialize(first_bucket_max = 0.010, bucket_count = 30, multiplier = 1.3)
|
71
|
-
@buckets = []
|
72
|
-
|
73
|
-
min = 0
|
74
|
-
max = first_bucket_max
|
75
|
-
|
76
|
-
(bucket_count - 1).times do
|
77
|
-
@buckets << Bucket.new(min, max)
|
78
|
-
min = max
|
79
|
-
max *= multiplier
|
80
|
-
end
|
81
|
-
@buckets << Bucket.new(max)
|
82
|
-
end
|
83
|
-
|
84
|
-
def process(response_time)
|
85
|
-
buckets.each do |bucket|
|
86
|
-
found = bucket.process(response_time)
|
87
|
-
return if found == 0
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
module NewRelic
|
3
|
-
module Rack
|
4
|
-
class MetricApp
|
5
|
-
def initialize(options)
|
6
|
-
if options[:install]
|
7
|
-
src = File.join(File.dirname(__FILE__), "newrelic.yml")
|
8
|
-
require 'new_relic/command'
|
9
|
-
begin
|
10
|
-
NewRelic::Command::Install.new(:quiet => true, :src_file => src).run
|
11
|
-
NewRelic::Agent.logger.info "A newrelic.yml template was copied to #{File.expand_path('.')}."
|
12
|
-
NewRelic::Agent.logger.info "Please add a license key to the file and restart #{$0}"
|
13
|
-
exit 0
|
14
|
-
rescue NewRelic::Command::CommandFailure => e
|
15
|
-
NewRelic::Agent.logger.error e.message
|
16
|
-
exit 1
|
17
|
-
end
|
18
|
-
end
|
19
|
-
options[:app_name] ||= 'EPM Monitor'
|
20
|
-
options[:disable_samplers] = true
|
21
|
-
NewRelic::Agent.manual_start options
|
22
|
-
NewRelic::Agent.logger.warn "This rack app is deprecated - it will be removed in the next version of the Ruby Agent"
|
23
|
-
unless NewRelic::Control.instance.license_key
|
24
|
-
raise "Please add a valid license key to newrelic.yml."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
def call(env)
|
28
|
-
request = ::Rack::Request.new env
|
29
|
-
params = request.params
|
30
|
-
if !(params['uri'] || params['metric'])
|
31
|
-
[400, { 'Content-Type' => 'text/plain' }, "Missing 'uri' or 'metric' parameter: #{params.inspect}" ]
|
32
|
-
elsif !params['value']
|
33
|
-
[400, { 'Content-Type' => 'text/plain' }, "Missing 'value' parameter: #{params.inspect}" ]
|
34
|
-
else
|
35
|
-
NewRelic::Agent.record_transaction( params['value'].to_f, params )
|
36
|
-
::Rack::Response.new(params.collect { |k, v| "#{k}=#{v} " }.join).finish
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
class Status
|
41
|
-
def call(env)
|
42
|
-
request = ::Rack::Request.new env
|
43
|
-
data_url = "http://#{env['HTTP_HOST']}/metrics/path?value=nnn"
|
44
|
-
body = StringIO.new
|
45
|
-
body.puts "<html><body>"
|
46
|
-
body.puts "<h1>New Relic Actively Monitoring #{NewRelic::Control.instance.app_names.join(' and ')}</h1>"
|
47
|
-
body.puts "<p>To submit a metric value, use <a href='#{data_url}'>#{data_url}</a></p>"
|
48
|
-
body.puts "<h2>Request Details</h2>"
|
49
|
-
body.puts "<dl>"
|
50
|
-
body.puts "<dt>ip<dd>#{request.ip}"
|
51
|
-
body.puts "<dt>host<dd>#{request.host}"
|
52
|
-
body.puts "<dt>path<dd>#{request.url}"
|
53
|
-
body.puts "<dt>query<dd>#{request.query_string}"
|
54
|
-
body.puts "<dt>params<dd>#{request.params.inspect}"
|
55
|
-
body.puts "</dl>"
|
56
|
-
body.puts "<h2>Complete ENV</h2>"
|
57
|
-
body.puts "<ul>"
|
58
|
-
body.puts env.to_a.map{|k,v| "<li>#{k} = #{v}</li>" }.join("\n")
|
59
|
-
body.puts "</ul></body></html>"
|
60
|
-
response = ::Rack::Response.new body.string
|
61
|
-
response.finish
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|