newrelic_rpm 2.8.11 → 2.9.2
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 +267 -0
- data/LICENSE +1 -1
- data/Manifest +142 -0
- data/README.md +138 -0
- data/Rakefile +10 -28
- data/bin/mongrel_rpm +33 -0
- data/cert/cacert.pem +34 -0
- data/init.rb +38 -0
- data/lib/new_relic/agent/agent.rb +160 -347
- data/lib/new_relic/agent/collection_helper.rb +13 -24
- data/lib/new_relic/agent/error_collector.rb +29 -15
- data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +63 -76
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +90 -48
- data/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb +72 -47
- data/lib/new_relic/agent/instrumentation/error_instrumentation.rb +14 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +10 -1
- data/lib/new_relic/agent/instrumentation/merb/dispatcher.rb +5 -7
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +3 -1
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +7 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +34 -7
- data/lib/new_relic/agent/instrumentation/rails/dispatcher.rb +20 -12
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +5 -4
- data/lib/new_relic/agent/method_tracer.rb +159 -135
- data/lib/new_relic/agent/patch_const_missing.rb +46 -26
- data/lib/new_relic/agent/sampler.rb +12 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +44 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +126 -0
- data/lib/new_relic/agent/samplers/mongrel_sampler.rb +22 -0
- data/lib/new_relic/agent/shim_agent.rb +11 -0
- data/lib/new_relic/agent/stats_engine.rb +85 -46
- data/lib/new_relic/agent/transaction_sampler.rb +63 -38
- data/lib/new_relic/agent/worker_loop.rb +8 -18
- data/lib/new_relic/agent.rb +200 -25
- data/lib/new_relic/commands/deployments.rb +9 -9
- data/lib/new_relic/control/merb.rb +22 -0
- data/lib/new_relic/control/rails.rb +141 -0
- data/lib/new_relic/{config → control}/ruby.rb +13 -2
- data/lib/new_relic/control.rb +424 -0
- data/lib/new_relic/local_environment.rb +201 -79
- data/lib/new_relic/metric_data.rb +7 -0
- data/lib/new_relic/metric_parser/action_mailer.rb +9 -0
- data/lib/new_relic/metric_parser/active_merchant.rb +26 -0
- data/lib/new_relic/metric_parser/active_record.rb +11 -0
- data/lib/new_relic/metric_parser/controller.rb +51 -0
- data/lib/new_relic/metric_parser/controller_cpu.rb +38 -0
- data/lib/new_relic/metric_parser/database.rb +23 -0
- data/lib/new_relic/metric_parser/errors.rb +6 -0
- data/lib/new_relic/metric_parser/mem_cache.rb +12 -0
- data/lib/new_relic/metric_parser/view.rb +61 -0
- data/lib/new_relic/metric_parser/web_service.rb +9 -0
- data/lib/new_relic/metric_parser.rb +107 -0
- data/lib/new_relic/metric_spec.rb +5 -0
- data/lib/new_relic/noticed_error.rb +5 -1
- data/lib/new_relic/rack/metric_app.rb +57 -0
- data/lib/new_relic/rack/newrelic.ru +25 -0
- data/lib/new_relic/rack/newrelic.yml +25 -0
- data/lib/new_relic/rack.rb +5 -0
- data/lib/new_relic/recipes.rb +10 -3
- data/lib/new_relic/stats.rb +130 -144
- data/lib/new_relic/transaction_analysis.rb +7 -8
- data/lib/new_relic/transaction_sample.rb +86 -10
- data/lib/new_relic/version.rb +41 -160
- data/lib/new_relic_api.rb +7 -6
- data/lib/newrelic_rpm.rb +30 -17
- data/lib/tasks/{agent_tests.rake → tests.rake} +1 -1
- data/newrelic.yml +115 -62
- data/newrelic_rpm.gemspec +36 -0
- data/test/active_record_fixtures.rb +55 -0
- data/test/config/newrelic.yml +21 -3
- data/test/config/{test_config.rb → test_control.rb} +14 -10
- data/test/new_relic/agent/active_record_instrumentation_test.rb +189 -0
- data/test/new_relic/agent/agent_test.rb +104 -0
- data/test/new_relic/agent/agent_test_controller.rb +18 -1
- data/test/new_relic/agent/classloader_patch_test.rb +56 -0
- data/test/new_relic/agent/{tc_collection_helper.rb → collection_helper_test.rb} +28 -23
- data/test/new_relic/agent/controller_test.rb +107 -0
- data/test/new_relic/agent/dispatcher_instrumentation_test.rb +70 -0
- data/test/new_relic/agent/error_collector_test.rb +155 -0
- data/test/new_relic/agent/{tc_method_tracer.rb → method_tracer_test.rb} +6 -12
- data/test/new_relic/agent/metric_data_test.rb +56 -0
- data/test/new_relic/agent/stats_engine_test.rb +266 -0
- data/test/new_relic/agent/{tc_transaction_sample_builder.rb → transaction_sample_builder_test.rb} +6 -5
- data/test/new_relic/agent/{tc_transaction_sample.rb → transaction_sample_test.rb} +9 -13
- data/test/new_relic/agent/transaction_sampler_test.rb +317 -0
- data/test/new_relic/agent/{tc_worker_loop.rb → worker_loop_test.rb} +1 -1
- data/test/new_relic/control_test.rb +97 -0
- data/test/new_relic/{tc_deployments_api.rb → deployments_api_test.rb} +8 -4
- data/test/new_relic/environment_test.rb +75 -0
- data/test/new_relic/metric_parser_test.rb +142 -0
- data/test/new_relic/{tc_metric_spec.rb → metric_spec_test.rb} +28 -1
- data/test/new_relic/samplers_test.rb +71 -0
- data/test/new_relic/{tc_shim_agent.rb → shim_agent_test.rb} +1 -1
- data/test/new_relic/stats_test.rb +291 -0
- data/test/new_relic/version_number_test.rb +46 -0
- data/test/test_helper.rb +7 -30
- data/test/ui/newrelic_controller_test.rb +14 -0
- data/test/ui/{tc_newrelic_helper.rb → newrelic_helper_test.rb} +16 -7
- data/ui/controllers/newrelic_controller.rb +17 -3
- data/ui/helpers/newrelic_helper.rb +44 -15
- data/ui/views/layouts/newrelic_default.rhtml +7 -8
- data/ui/views/newrelic/_sample.rhtml +5 -2
- data/ui/views/newrelic/_segment.rhtml +1 -1
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
- data/ui/views/newrelic/_segment_row.rhtml +4 -4
- data/ui/views/newrelic/_show_sample_detail.rhtml +3 -1
- data/ui/views/newrelic/_show_sample_sql.rhtml +2 -1
- data/ui/views/newrelic/explain_sql.rhtml +2 -5
- data/ui/views/newrelic/images/file_icon.png +0 -0
- data/ui/views/newrelic/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/index.rhtml +21 -13
- data/ui/views/newrelic/javascript/prototype-scriptaculous.js +7288 -0
- data/ui/views/newrelic/show_sample.rhtml +18 -3
- data/ui/views/newrelic/stylesheets/style.css +39 -0
- data/ui/views/newrelic/threads.rhtml +52 -0
- metadata +192 -70
- data/README +0 -136
- data/lib/new_relic/agent/instrumentation/rails/rails.rb +0 -6
- data/lib/new_relic/agent/samplers/cpu.rb +0 -29
- data/lib/new_relic/agent/samplers/memory.rb +0 -53
- data/lib/new_relic/agent/samplers/mongrel.rb +0 -26
- data/lib/new_relic/agent/synchronize.rb +0 -40
- data/lib/new_relic/config/merb.rb +0 -35
- data/lib/new_relic/config/rails.rb +0 -114
- data/lib/new_relic/config.rb +0 -279
- data/lib/new_relic/shim_agent.rb +0 -96
- data/test/new_relic/agent/model_fixture.rb +0 -15
- data/test/new_relic/agent/tc_active_record.rb +0 -90
- data/test/new_relic/agent/tc_agent.rb +0 -148
- data/test/new_relic/agent/tc_controller.rb +0 -77
- data/test/new_relic/agent/tc_dispatcher_instrumentation.rb +0 -52
- data/test/new_relic/agent/tc_error_collector.rb +0 -127
- data/test/new_relic/agent/tc_stats_engine.rb +0 -218
- data/test/new_relic/agent/tc_synchronize.rb +0 -37
- data/test/new_relic/agent/tc_transaction_sampler.rb +0 -302
- data/test/new_relic/tc_config.rb +0 -36
- data/test/new_relic/tc_environment.rb +0 -94
- data/test/new_relic/tc_stats.rb +0 -141
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
##require 'new_relic/agent/testable_agent'
|
3
|
-
|
4
|
-
class TestSync
|
5
|
-
include NewRelic::Agent::Synchronize
|
6
|
-
end
|
7
|
-
|
8
|
-
class AgentSynchronizeTests < Test::Unit::TestCase
|
9
|
-
|
10
|
-
|
11
|
-
def test_sync
|
12
|
-
t = TestSync.new
|
13
|
-
|
14
|
-
worked = false
|
15
|
-
t.synchronize_sync do
|
16
|
-
worked = true
|
17
|
-
end
|
18
|
-
|
19
|
-
assert worked
|
20
|
-
|
21
|
-
worked = false
|
22
|
-
|
23
|
-
t.synchronize_mutex do
|
24
|
-
worked = true
|
25
|
-
end
|
26
|
-
|
27
|
-
assert worked
|
28
|
-
|
29
|
-
worked = false
|
30
|
-
|
31
|
-
t.synchronize_thread do
|
32
|
-
worked = true
|
33
|
-
end
|
34
|
-
|
35
|
-
assert worked
|
36
|
-
end
|
37
|
-
end
|
@@ -1,302 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
-
|
3
|
-
::RPM_DEVELOPER = true unless defined? ::RPM_DEVELOPER
|
4
|
-
|
5
|
-
NewRelic::Agent::TransactionSampler.send :public, :builder
|
6
|
-
|
7
|
-
class NewRelic::Agent::TransationSamplerTests < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
Thread::current[:record_sql] = nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_multiple_samples
|
14
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
15
|
-
|
16
|
-
run_sample_trace
|
17
|
-
run_sample_trace
|
18
|
-
run_sample_trace
|
19
|
-
run_sample_trace
|
20
|
-
|
21
|
-
samples = @sampler.get_samples
|
22
|
-
assert_equal 4, samples.length
|
23
|
-
assert_equal "a", samples.first.root_segment.called_segments[0].metric_name
|
24
|
-
assert_equal "a", samples.last.root_segment.called_segments[0].metric_name
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def test_harvest_slowest
|
29
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
30
|
-
|
31
|
-
run_sample_trace
|
32
|
-
run_sample_trace
|
33
|
-
run_sample_trace { sleep 0.5 }
|
34
|
-
run_sample_trace
|
35
|
-
run_sample_trace
|
36
|
-
|
37
|
-
slowest = @sampler.harvest_slowest_sample(nil)
|
38
|
-
assert slowest.duration >= 0.5
|
39
|
-
|
40
|
-
run_sample_trace { sleep 0.2 }
|
41
|
-
not_as_slow = @sampler.harvest_slowest_sample(slowest)
|
42
|
-
assert not_as_slow == slowest
|
43
|
-
|
44
|
-
run_sample_trace { sleep 0.6 }
|
45
|
-
new_slowest = @sampler.harvest_slowest_sample(slowest)
|
46
|
-
assert new_slowest != slowest
|
47
|
-
assert new_slowest.duration >= 0.6
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def test_preare_to_send
|
52
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
53
|
-
|
54
|
-
run_sample_trace { sleep 0.2 }
|
55
|
-
sample = @sampler.harvest_slowest_sample(nil)
|
56
|
-
|
57
|
-
ready_to_send = sample.prepare_to_send
|
58
|
-
assert sample.duration == ready_to_send.duration
|
59
|
-
|
60
|
-
assert ready_to_send.start_time.is_a?(Time)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_multithread
|
64
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
65
|
-
threads = []
|
66
|
-
|
67
|
-
20.times do
|
68
|
-
t = Thread.new(@sampler) do |the_sampler|
|
69
|
-
@sampler = the_sampler
|
70
|
-
100.times do
|
71
|
-
run_sample_trace { sleep 0.01 }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
threads << t
|
76
|
-
end
|
77
|
-
threads.each {|t| t.join }
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_sample_with_parallel_paths
|
81
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
82
|
-
|
83
|
-
assert_equal 0, @sampler.scope_depth
|
84
|
-
|
85
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
86
|
-
@sampler.notice_transaction "/path", nil, {}
|
87
|
-
@sampler.notice_push_scope "a"
|
88
|
-
|
89
|
-
assert_equal 1, @sampler.scope_depth
|
90
|
-
|
91
|
-
@sampler.notice_pop_scope "a"
|
92
|
-
@sampler.notice_scope_empty
|
93
|
-
|
94
|
-
assert_equal 0, @sampler.scope_depth
|
95
|
-
|
96
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
97
|
-
@sampler.notice_transaction "/path", nil, {}
|
98
|
-
@sampler.notice_push_scope "a"
|
99
|
-
@sampler.notice_pop_scope "a"
|
100
|
-
@sampler.notice_scope_empty
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_double_scope_stack_empty
|
104
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
105
|
-
|
106
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
107
|
-
@sampler.notice_transaction "/path", nil, {}
|
108
|
-
@sampler.notice_push_scope "a"
|
109
|
-
@sampler.notice_pop_scope "a"
|
110
|
-
@sampler.notice_scope_empty
|
111
|
-
@sampler.notice_scope_empty
|
112
|
-
@sampler.notice_scope_empty
|
113
|
-
@sampler.notice_scope_empty
|
114
|
-
|
115
|
-
assert_not_nil @sampler.harvest_slowest_sample(nil)
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
def test_record_sql_off
|
120
|
-
sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
121
|
-
|
122
|
-
sampler.notice_first_scope_push Time.now.to_f
|
123
|
-
|
124
|
-
Thread::current[:record_sql] = false
|
125
|
-
|
126
|
-
sampler.notice_sql("test", nil, 0)
|
127
|
-
|
128
|
-
segment = sampler.builder.current_segment
|
129
|
-
|
130
|
-
assert_nil segment[:sql]
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_stack_trace__sql
|
134
|
-
sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
135
|
-
|
136
|
-
sampler.stack_trace_threshold = 0
|
137
|
-
|
138
|
-
sampler.notice_first_scope_push Time.now.to_f
|
139
|
-
|
140
|
-
sampler.notice_sql("test", nil, 1)
|
141
|
-
|
142
|
-
segment = sampler.builder.current_segment
|
143
|
-
|
144
|
-
assert segment[:sql]
|
145
|
-
assert segment[:backtrace]
|
146
|
-
end
|
147
|
-
def test_stack_trace__scope
|
148
|
-
sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
149
|
-
|
150
|
-
sampler.stack_trace_threshold = 0
|
151
|
-
t = Time.now
|
152
|
-
sampler.notice_first_scope_push t.to_f
|
153
|
-
sampler.notice_push_scope 'Bill', (t+1.second).to_f
|
154
|
-
|
155
|
-
segment = sampler.builder.current_segment
|
156
|
-
assert segment[:backtrace]
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_nil_stacktrace
|
160
|
-
sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
161
|
-
|
162
|
-
sampler.stack_trace_threshold = 2
|
163
|
-
|
164
|
-
sampler.notice_first_scope_push Time.now.to_f
|
165
|
-
|
166
|
-
sampler.notice_sql("test", nil, 1)
|
167
|
-
|
168
|
-
segment = sampler.builder.current_segment
|
169
|
-
|
170
|
-
assert segment[:sql]
|
171
|
-
assert_nil segment[:backtrace]
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_big_sql
|
175
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
176
|
-
|
177
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
178
|
-
|
179
|
-
sql = "SADJKHASDHASD KAJSDH ASKDH ASKDHASDK JASHD KASJDH ASKDJHSAKDJHAS DKJHSADKJSAH DKJASHD SAKJDH SAKDJHS"
|
180
|
-
|
181
|
-
len = 0
|
182
|
-
while len <= NewRelic::Agent::TransactionSampler::MAX_SQL_LENGTH
|
183
|
-
@sampler.notice_sql(sql, nil, 0)
|
184
|
-
len += sql.length
|
185
|
-
end
|
186
|
-
|
187
|
-
segment = @sampler.builder.current_segment
|
188
|
-
|
189
|
-
sql = segment[:sql]
|
190
|
-
|
191
|
-
assert sql.length <= NewRelic::Agent::TransactionSampler::MAX_SQL_LENGTH
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
def test_segment_obfuscated
|
196
|
-
@sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
197
|
-
|
198
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
199
|
-
|
200
|
-
orig_sql = "SELECT * from Jim where id=66"
|
201
|
-
|
202
|
-
@sampler.notice_sql(orig_sql, nil, 0)
|
203
|
-
|
204
|
-
segment = @sampler.builder.current_segment
|
205
|
-
|
206
|
-
assert_equal orig_sql, segment[:sql]
|
207
|
-
assert_equal "SELECT * from Jim where id=?", segment.obfuscated_sql
|
208
|
-
end
|
209
|
-
|
210
|
-
|
211
|
-
def test_param_capture
|
212
|
-
[true, false].each do |capture|
|
213
|
-
t = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
214
|
-
|
215
|
-
NewRelic::Agent::TransactionSampler.capture_params = capture
|
216
|
-
|
217
|
-
t.notice_first_scope_push Time.now.to_f
|
218
|
-
t.notice_transaction('/path', nil, {:param => 'hi'})
|
219
|
-
t.notice_scope_empty
|
220
|
-
|
221
|
-
tt = t.harvest_slowest_sample
|
222
|
-
|
223
|
-
assert_equal (capture) ? 1 : 0, tt.params[:request_params].length
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
|
228
|
-
def test_sql_normalization
|
229
|
-
t = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
|
230
|
-
|
231
|
-
# basic statement
|
232
|
-
assert_equal "INSERT INTO X values(?,?, ? , ?)",
|
233
|
-
t.default_sql_obfuscator("INSERT INTO X values('test',0, 1 , 2)")
|
234
|
-
|
235
|
-
# escaped literals
|
236
|
-
assert_equal "INSERT INTO X values(?, ?,?, ? , ?)",
|
237
|
-
t.default_sql_obfuscator("INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son')")
|
238
|
-
|
239
|
-
# multiple string literals
|
240
|
-
assert_equal "INSERT INTO X values(?,?,?, ? , ?)",
|
241
|
-
t.default_sql_obfuscator("INSERT INTO X values('jim''s ssn','x',0, 1 , 2)")
|
242
|
-
|
243
|
-
# empty string literal
|
244
|
-
# NOTE: the empty string literal resolves to empty string, which for our purposes is acceptable
|
245
|
-
assert_equal "INSERT INTO X values(?,?,?, ? , ?)",
|
246
|
-
t.default_sql_obfuscator("INSERT INTO X values('','x',0, 1 , 2)")
|
247
|
-
|
248
|
-
# try a select statement
|
249
|
-
assert_equal "select * from table where name=? and ssn=?",
|
250
|
-
t.default_sql_obfuscator("select * from table where name='jim gochee' and ssn=0012211223")
|
251
|
-
|
252
|
-
# number literals embedded in sql - oh well
|
253
|
-
assert_equal "select * from table_? where name=? and ssn=?",
|
254
|
-
t.default_sql_obfuscator("select * from table_007 where name='jim gochee' and ssn=0012211223")
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_sql_obfuscation_filters
|
258
|
-
orig = NewRelic::Agent.agent.obfuscator
|
259
|
-
|
260
|
-
NewRelic::Agent.set_sql_obfuscator(:replace) do |sql|
|
261
|
-
sql = "1" + sql
|
262
|
-
end
|
263
|
-
|
264
|
-
sql = "SELECT * FROM TABLE 123 'jim'"
|
265
|
-
|
266
|
-
assert_equal "1" + sql, NewRelic::Agent.instance.obfuscator.call(sql)
|
267
|
-
|
268
|
-
NewRelic::Agent.set_sql_obfuscator(:before) do |sql|
|
269
|
-
sql = "2" + sql
|
270
|
-
end
|
271
|
-
|
272
|
-
assert_equal "12" + sql, NewRelic::Agent.instance.obfuscator.call(sql)
|
273
|
-
|
274
|
-
NewRelic::Agent.set_sql_obfuscator(:after) do |sql|
|
275
|
-
sql = sql + "3"
|
276
|
-
end
|
277
|
-
|
278
|
-
assert_equal "12" + sql + "3", NewRelic::Agent.instance.obfuscator.call(sql)
|
279
|
-
|
280
|
-
NewRelic::Agent.agent.set_sql_obfuscator(:replace, &orig)
|
281
|
-
end
|
282
|
-
|
283
|
-
|
284
|
-
private
|
285
|
-
def run_sample_trace(&proc)
|
286
|
-
@sampler.notice_first_scope_push Time.now.to_f
|
287
|
-
@sampler.notice_transaction '/path', nil, {}
|
288
|
-
@sampler.notice_push_scope "a"
|
289
|
-
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", nil, 0)
|
290
|
-
@sampler.notice_push_scope "ab"
|
291
|
-
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", nil, 0)
|
292
|
-
proc.call if proc
|
293
|
-
@sampler.notice_pop_scope "ab"
|
294
|
-
@sampler.notice_push_scope "lew"
|
295
|
-
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", nil, 0)
|
296
|
-
@sampler.notice_pop_scope "lew"
|
297
|
-
@sampler.notice_pop_scope "a"
|
298
|
-
@sampler.notice_scope_empty
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
302
|
-
|
data/test/new_relic/tc_config.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
|
2
|
-
|
3
|
-
|
4
|
-
module NewRelic
|
5
|
-
class Config
|
6
|
-
public :log_file_name
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class NewRelic::ConfigTests < Test::Unit::TestCase
|
11
|
-
|
12
|
-
def test_rails_config
|
13
|
-
c = NewRelic::Config.instance
|
14
|
-
assert_equal :rails, c.app
|
15
|
-
assert_equal false, c['enabled']
|
16
|
-
c.local_env
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_config_yaml_erb
|
20
|
-
c = NewRelic::Config.instance
|
21
|
-
assert_equal 'heyheyhey', c['erb_value']
|
22
|
-
assert_equal '', c['message']
|
23
|
-
assert_equal '', c['license_key']
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_log_file_name
|
27
|
-
c = NewRelic::Config.instance
|
28
|
-
|
29
|
-
assert_equal "newrelic_agent.3000.log", c.log_file_name("3000")
|
30
|
-
assert_equal "newrelic_agent.passenger_redmine-0.7.log", c.log_file_name("passenger:redmine-0.7")
|
31
|
-
assert_equal "newrelic_agent._tmp_test_1.log", c.log_file_name("/tmp/test/1")
|
32
|
-
assert_equal "newrelic_agent.c__foo_bar_long_gone__yes_.log", c.log_file_name("c:/foo/bar long gone?/yes!")
|
33
|
-
assert_equal "newrelic_agent..._tmp_pipes.log", c.log_file_name("..\\tmp\\pipes")
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
2
|
-
require "test/unit"
|
3
|
-
require "mocha"
|
4
|
-
##require 'new_relic/local_environment'
|
5
|
-
class EnvironmentTest < ActiveSupport::TestCase
|
6
|
-
|
7
|
-
def teardown
|
8
|
-
# To remove mock server instances from ObjectSpace
|
9
|
-
ObjectSpace.garbage_collect
|
10
|
-
super
|
11
|
-
end
|
12
|
-
class MockOptions
|
13
|
-
def fetch (*args)
|
14
|
-
1000
|
15
|
-
end
|
16
|
-
end
|
17
|
-
MOCK_OPTIONS = MockOptions.new
|
18
|
-
|
19
|
-
def test_environment
|
20
|
-
e = NewRelic::LocalEnvironment.new
|
21
|
-
assert_equal :unknown, e.environment
|
22
|
-
assert_nil e.identifier
|
23
|
-
end
|
24
|
-
def test_webrick
|
25
|
-
Object.const_set :OPTIONS, { :port => 3000 }
|
26
|
-
e = NewRelic::LocalEnvironment.new
|
27
|
-
assert_equal :webrick, e.environment
|
28
|
-
assert_equal 3000, e.identifier
|
29
|
-
Object.class_eval { remove_const :OPTIONS }
|
30
|
-
end
|
31
|
-
def test_no_webrick
|
32
|
-
Object.const_set :OPTIONS, 'foo'
|
33
|
-
e = NewRelic::LocalEnvironment.new
|
34
|
-
assert_equal :unknown, e.environment
|
35
|
-
assert_nil e.identifier
|
36
|
-
Object.class_eval { remove_const :OPTIONS }
|
37
|
-
end
|
38
|
-
def test_mongrel
|
39
|
-
|
40
|
-
class << self
|
41
|
-
module ::Mongrel
|
42
|
-
class HttpServer
|
43
|
-
def port; 3000; end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
Mongrel::HttpServer.new
|
48
|
-
e = NewRelic::LocalEnvironment.new
|
49
|
-
assert_equal :mongrel, e.environment
|
50
|
-
assert_equal 3000, e.identifier
|
51
|
-
Mongrel::HttpServer.class_eval {undef_method :port}
|
52
|
-
end
|
53
|
-
def test_thin
|
54
|
-
class << self
|
55
|
-
module ::Thin
|
56
|
-
class Server
|
57
|
-
def backend; self; end
|
58
|
-
def socket; "/socket/file.000"; end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
mock_thin = Thin::Server.new
|
63
|
-
e = NewRelic::LocalEnvironment.new
|
64
|
-
assert_equal :thin, e.environment
|
65
|
-
assert_equal '/socket/file.000', e.identifier
|
66
|
-
mock_thin
|
67
|
-
end
|
68
|
-
def test_litespeed
|
69
|
-
e = NewRelic::LocalEnvironment.new
|
70
|
-
assert_equal :unknown, e.environment
|
71
|
-
assert_nil e.identifier
|
72
|
-
end
|
73
|
-
def test_passenger
|
74
|
-
class << self
|
75
|
-
module ::Passenger
|
76
|
-
const_set "AbstractServer", 0
|
77
|
-
end
|
78
|
-
end
|
79
|
-
e = NewRelic::LocalEnvironment.new
|
80
|
-
assert_equal :passenger, e.environment
|
81
|
-
assert_equal 'passenger', e.identifier
|
82
|
-
|
83
|
-
NewRelic::Config.instance.instance_eval do
|
84
|
-
@settings['app_name'] = 'myapp'
|
85
|
-
end
|
86
|
-
|
87
|
-
e = NewRelic::LocalEnvironment.new
|
88
|
-
assert_equal :passenger, e.environment
|
89
|
-
assert_equal 'passenger:myapp', e.identifier
|
90
|
-
|
91
|
-
::Passenger.class_eval { remove_const :AbstractServer }
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|