newrelic_rpm 2.9.9 → 2.10.3
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 +117 -49
- data/bin/mongrel_rpm +2 -2
- data/install.rb +42 -33
- data/lib/new_relic/agent.rb +149 -39
- data/lib/new_relic/agent/agent.rb +139 -122
- data/lib/new_relic/agent/busy_calculator.rb +91 -0
- data/lib/new_relic/agent/collection_helper.rb +11 -2
- data/lib/new_relic/agent/error_collector.rb +33 -27
- data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +30 -26
- data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +316 -105
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +22 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +18 -12
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +2 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +258 -0
- data/lib/new_relic/agent/instrumentation/net.rb +7 -11
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +109 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +6 -5
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sinatra.rb +46 -0
- data/lib/new_relic/agent/method_tracer.rb +305 -150
- data/lib/new_relic/agent/sampler.rb +34 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +11 -1
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +37 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +22 -10
- data/lib/new_relic/agent/samplers/object_sampler.rb +24 -0
- data/lib/new_relic/agent/shim_agent.rb +10 -0
- data/lib/new_relic/agent/stats_engine.rb +16 -278
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +118 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +81 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +149 -0
- data/lib/new_relic/agent/transaction_sampler.rb +73 -67
- data/lib/new_relic/agent/worker_loop.rb +69 -68
- data/lib/new_relic/commands/deployments.rb +4 -6
- data/lib/new_relic/control.rb +121 -60
- data/lib/new_relic/control/external.rb +13 -0
- data/lib/new_relic/control/merb.rb +2 -0
- data/lib/new_relic/control/rails.rb +16 -6
- data/lib/new_relic/control/ruby.rb +8 -5
- data/lib/new_relic/control/sinatra.rb +18 -0
- data/lib/new_relic/delayed_job_injection.rb +25 -0
- data/lib/new_relic/histogram.rb +89 -0
- data/lib/new_relic/local_environment.rb +64 -30
- data/lib/new_relic/metric_data.rb +15 -6
- data/lib/new_relic/metric_parser.rb +14 -1
- data/lib/new_relic/metric_parser/active_record.rb +14 -0
- data/lib/new_relic/metric_parser/controller.rb +5 -2
- data/lib/new_relic/metric_parser/external.rb +50 -0
- data/lib/new_relic/metric_parser/other_transaction.rb +15 -0
- data/lib/new_relic/metric_parser/web_frontend.rb +14 -0
- data/lib/new_relic/metric_spec.rb +39 -20
- data/lib/new_relic/metrics.rb +9 -7
- data/lib/new_relic/noticed_error.rb +6 -8
- data/lib/new_relic/rack/metric_app.rb +5 -4
- data/lib/new_relic/rack/{newrelic.ru → mongrel_rpm.ru} +4 -4
- data/lib/new_relic/rack/newrelic.yml +1 -0
- data/lib/new_relic/{rack.rb → rack_app.rb} +0 -0
- data/lib/new_relic/recipes.rb +1 -1
- data/lib/new_relic/stats.rb +40 -26
- data/lib/new_relic/transaction_analysis.rb +5 -2
- data/lib/new_relic/transaction_sample.rb +134 -55
- data/lib/new_relic/version.rb +27 -20
- data/lib/new_relic_api.rb +67 -47
- data/lib/newrelic_rpm.rb +5 -5
- data/lib/tasks/tests.rake +2 -0
- data/newrelic.yml +69 -29
- data/test/active_record_fixtures.rb +2 -2
- data/test/config/newrelic.yml +4 -7
- data/test/config/test_control.rb +1 -2
- data/test/new_relic/agent/active_record_instrumentation_test.rb +115 -31
- data/test/new_relic/agent/agent_controller_test.rb +274 -0
- data/test/new_relic/agent/agent_test_controller.rb +42 -6
- data/test/new_relic/agent/busy_calculator_test.rb +79 -0
- data/test/new_relic/agent/collection_helper_test.rb +10 -3
- data/test/new_relic/agent/error_collector_test.rb +35 -17
- data/test/new_relic/agent/method_tracer_test.rb +60 -20
- data/test/new_relic/agent/metric_data_test.rb +2 -2
- data/test/new_relic/agent/metric_frame_test.rb +51 -0
- data/test/new_relic/agent/net_instrumentation_test.rb +77 -0
- data/test/new_relic/agent/{agent_test.rb → rpm_agent_test.rb} +26 -5
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +79 -0
- data/test/new_relic/{samplers_test.rb → agent/stats_engine/samplers_test.rb} +23 -22
- data/test/new_relic/agent/{stats_engine_test.rb → stats_engine/stats_engine_test.rb} +19 -101
- data/test/new_relic/agent/task_instrumentation_test.rb +176 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +2 -2
- data/test/new_relic/agent/transaction_sample_test.rb +53 -38
- data/test/new_relic/agent/transaction_sampler_test.rb +101 -33
- data/test/new_relic/agent/worker_loop_test.rb +16 -14
- data/test/new_relic/control_test.rb +26 -13
- data/test/new_relic/metric_parser_test.rb +31 -1
- data/test/new_relic/metric_spec_test.rb +2 -2
- data/test/new_relic/stats_test.rb +0 -8
- data/test/new_relic/version_number_test.rb +31 -1
- data/test/test_helper.rb +37 -1
- data/ui/controllers/newrelic_controller.rb +19 -11
- data/ui/helpers/google_pie_chart.rb +5 -11
- data/ui/helpers/newrelic_helper.rb +40 -35
- data/ui/views/layouts/newrelic_default.rhtml +7 -7
- data/ui/views/newrelic/_sample.rhtml +5 -1
- data/ui/views/newrelic/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/images/textmate.png +0 -0
- data/ui/views/newrelic/index.rhtml +13 -1
- data/ui/views/newrelic/show_sample.rhtml +5 -2
- data/ui/views/newrelic/stylesheets/style.css +54 -3
- metadata +65 -145
- data/Manifest +0 -143
- data/Rakefile +0 -22
- data/init.rb +0 -38
- data/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb +0 -127
- data/lib/new_relic/agent/instrumentation/error_instrumentation.rb +0 -14
- data/lib/new_relic/agent/instrumentation/merb/dispatcher.rb +0 -13
- data/lib/new_relic/agent/instrumentation/rails/dispatcher.rb +0 -38
- data/lib/new_relic/agent/patch_const_missing.rb +0 -125
- data/lib/new_relic/agent/samplers/mongrel_sampler.rb +0 -22
- data/lib/new_relic/metric_parser/database.rb +0 -23
- data/newrelic_rpm.gemspec +0 -35
- data/test/new_relic/agent/classloader_patch_test.rb +0 -56
- data/test/new_relic/agent/controller_test.rb +0 -107
- data/test/new_relic/agent/dispatcher_instrumentation_test.rb +0 -70
data/CHANGELOG
CHANGED
@@ -1,15 +1,83 @@
|
|
1
|
+
v2.10.3
|
2
|
+
* optimization to reduce overhead: move background samplers into foreground thread
|
3
|
+
* change default config file to ignore RoutingErrors
|
4
|
+
* moved the background task instrumentation into a separate tab in the RPM UI
|
5
|
+
* allow override of the RPM application name via NEWRELIC_APP_NAME environment variable
|
6
|
+
* revised Delayed::Job instrumentation so no manual_start is required
|
7
|
+
* send buffered data on shutdown
|
8
|
+
* expanded support for queue length and queue time
|
9
|
+
* remove calls to starts_with to fix Sinatra and non-rails deployments
|
10
|
+
* fix problem with apdex scores recording too low in some circumstances
|
11
|
+
* switch to jeweler for gem building
|
12
|
+
* minor fixes, test improvements, doc and rakefile improvements
|
13
|
+
* fix incompatibility with Hoptoad where Hoptoad was not getting errors handled by New Relic
|
14
|
+
* many other optimizations, bug fixes and documentation improvements
|
15
|
+
|
16
|
+
v2.10.2.
|
17
|
+
* beta release of 2.10
|
18
|
+
* fix bugs with Sinatra app instrumentation
|
19
|
+
* minor doc updates
|
20
|
+
|
21
|
+
v2.10.1.
|
22
|
+
* alpha release of 2.10
|
23
|
+
* rack support, including metal; ignores 404s; requires a module inclusion (see docs)
|
24
|
+
* sinatra support, displays actions named by the URI pattern matched
|
25
|
+
* add API method to abort transaction recording for in-flight transactions
|
26
|
+
* remove account management calls from newrelic_api.rb
|
27
|
+
* truncating extremely large transaction traces for efficiency
|
28
|
+
* fix error reporting in recipes; add newrelic_rails_env option to recipes to
|
29
|
+
override the rails env used to pull the app_name out of newrelic.yml
|
30
|
+
* added TorqueBox recognition (thanks Bob McWhirter)
|
31
|
+
* renamed config settings: enabled => monitor_mode; developer => developer_mode;
|
32
|
+
old names will still work in newrelic.yml
|
33
|
+
* instrumentation for DelayedJob (thanks Travis Tilley)
|
34
|
+
* added config switches to turn off certain instrumentation when you aren't
|
35
|
+
interested in the metrics, to save on overhead--see newrelic.yml for details.
|
36
|
+
* add profiling support to dev mode; very experimental!
|
37
|
+
* add 'multi_threaded' config option to indicate when the app is running
|
38
|
+
multi-threaded, so we can disable some instrumentation
|
39
|
+
* fix test failures in JRuby, REE
|
40
|
+
* improve Net::HTTP instrumentation so its more efficient and distinguishes calls
|
41
|
+
between web and non-web transactions.
|
42
|
+
* database instrumentation notices all database commands in addition to the core commands
|
43
|
+
* add support for textmate to dev mode
|
44
|
+
* added add_transaction_tracer method to support instrumenting methods as
|
45
|
+
if they were web transactions; this will facilitate better visibility of background
|
46
|
+
tasks and eventually things like rack, metal and Sinatra
|
47
|
+
* adjusted apdex scores to reflect time spent in the mongrel queue
|
48
|
+
* fixed incompatibility with JRuby on startup
|
49
|
+
* implmented CPU measure for JRuby which reflects the cpu burn for
|
50
|
+
all controller actions (does not include background tasks)
|
51
|
+
* fixed scope issue with GC instrumentation, subtracting time from caller
|
52
|
+
* added # of GC calls to GC instrumentation
|
53
|
+
* renamed the dispatcher metric
|
54
|
+
* refactored stats_engine code for readability
|
55
|
+
* optimization: reduce wakeup times for harvest thread
|
56
|
+
|
57
|
+
v2.10.0.
|
58
|
+
* alpha release of 2.10
|
59
|
+
* support unicorn
|
60
|
+
* instrumentation of GC for REE and MRE with GC patch
|
61
|
+
* support agent restarting when changes are made to the account
|
62
|
+
* removed #newrelic_notice_error from Object class, replaced by NewRelic::Agent#notic_error
|
63
|
+
* collect histogram statistics
|
64
|
+
* add custom parameters to newrelic_notice_error call to display
|
65
|
+
extra info for errors
|
66
|
+
* add method disable_all_tracing(&block) to execute a block without
|
67
|
+
capturing metrics
|
68
|
+
* newrelic_ignore now blocks all instrumentation collection for
|
69
|
+
the specified actions
|
70
|
+
* added doc to method_tracer API and removed second arg
|
71
|
+
requirement for add_method_tracer call
|
72
|
+
* instrumentation for Net::HTTP
|
73
|
+
* remove method_tracer shim to avoid timing problems in monitoring daemons
|
74
|
+
* for non-rails daemons, look at APP_ROOT and NRCONFIG env vars for custom locations
|
75
|
+
|
1
76
|
v2.9.9.
|
2
77
|
* Disable at_exit handler for Unicorn which sometimes caused the
|
3
78
|
agent to stop reporting immediately.
|
4
79
|
|
5
80
|
v2.9.8.
|
6
|
-
* Fix bug in Net instrumentation when a block is passed to request calls.
|
7
|
-
|
8
|
-
v2.9.7.
|
9
|
-
* Fix External instrumentation so it does not capture Net
|
10
|
-
calls outside of web transactions.
|
11
|
-
|
12
|
-
v2.9.6.
|
13
81
|
* add instrumentation for Net::HTTP calls, to show up as "External"
|
14
82
|
* added support for validating agents in the cloud.
|
15
83
|
* recognize Unicorn dispatcher
|
@@ -26,8 +94,8 @@ v2.9.4.
|
|
26
94
|
|
27
95
|
v2.9.3.
|
28
96
|
* fix startup failure in Windows due to memory sampler
|
29
|
-
* add JRuby environment information
|
30
|
-
|
97
|
+
* add JRuby environment information
|
98
|
+
|
31
99
|
v2.9.2.
|
32
100
|
* change default apdex_t to 0.5 seconds
|
33
101
|
* fix bug in deployments introduced by multi_homed setting
|
@@ -113,7 +181,7 @@ v2.8.10.
|
|
113
181
|
processing
|
114
182
|
* minor tweak to environment gathering for gem mode
|
115
183
|
|
116
|
-
v2.8.9
|
184
|
+
v2.8.9.
|
117
185
|
* fix problem finding the newrelic controller in dev mode
|
118
186
|
* fix incompatibility with older versions of optparse
|
119
187
|
* fix potential jvm problem with jruby
|
@@ -121,24 +189,24 @@ v2.8.9
|
|
121
189
|
* change error message about window sampler in windows not supported to a
|
122
190
|
warning message
|
123
191
|
|
124
|
-
v2.8.8
|
192
|
+
v2.8.8.
|
125
193
|
* fix error with jruby on windows
|
126
194
|
* fix problem where webrick was being incorrectly detected causing some
|
127
195
|
problems with mongrel application assignments--had to disable webrick
|
128
196
|
for now
|
129
197
|
|
130
|
-
v2.8.7
|
198
|
+
v2.8.7.
|
131
199
|
* fix for ssl connection hanging problems
|
132
200
|
* fix problem recognizing mongrel in rails 2.3.2
|
133
201
|
* fastcgi support in rails 2.3.2
|
134
202
|
* put back webrick support
|
135
203
|
|
136
|
-
v2.8.6
|
204
|
+
v2.8.6.
|
137
205
|
* fix for capture_params when using file uploads in controller actions
|
138
206
|
* use pure ruby NS lookup for collector host to eliminate possibly
|
139
207
|
blocking applications
|
140
208
|
|
141
|
-
v2.8.5
|
209
|
+
v2.8.5.
|
142
210
|
* fix reference to CommandError which was breaking some cap scripts
|
143
211
|
* fix incompatibility with Rails 2.0 in the server API
|
144
212
|
* fix problem with litespeed with Lite accounts
|
@@ -147,23 +215,23 @@ v2.8.5
|
|
147
215
|
AbstractController to address incompatibility with MailController
|
148
216
|
* fix problem in devmode displaying sql with embedded urls
|
149
217
|
|
150
|
-
v2.8.4
|
218
|
+
v2.8.4.
|
151
219
|
* fix bug in capistrano recipe causing cap commands to fail with error
|
152
220
|
about not finding Version class
|
153
221
|
|
154
|
-
v2.8.3
|
222
|
+
v2.8.3.
|
155
223
|
* refactor unit tests so they will run in a generic rails environment
|
156
224
|
* require classes in advance to avoid autoloading. this is to address
|
157
225
|
incompatibilities with desert as well as more flexibility in gem
|
158
226
|
initialization
|
159
227
|
* fixed newrelic_helper.rb 1.9 incompatibility
|
160
228
|
|
161
|
-
v2.8.2
|
229
|
+
v2.8.2.
|
162
230
|
* fix Ruby 1.9 syntax compatibility errors
|
163
231
|
* update the class loading sanity check, will notify server of errors
|
164
232
|
* fix agent output on script and rake task execution
|
165
233
|
|
166
|
-
v2.8.1
|
234
|
+
v2.8.1.
|
167
235
|
* Convert the deployment information upload script to an executable and
|
168
236
|
put in the bin directory. When installed as a gem this command is
|
169
237
|
symlinked to /usr/bin. Usage: newrelic_cmd deployments --help
|
@@ -171,7 +239,7 @@ v2.8.1
|
|
171
239
|
* Fix deployments api so it will work from a gem
|
172
240
|
* Fix thin incompatibility in developer mode
|
173
241
|
|
174
|
-
v2.8.0
|
242
|
+
v2.8.0.
|
175
243
|
* add beta of api in new_relic_api.rb
|
176
244
|
* instrumented dynamic finders in ActiveRecord
|
177
245
|
* preliminary support for capturing deployment information via capistrano
|
@@ -185,21 +253,21 @@ v2.8.0
|
|
185
253
|
transient network problem
|
186
254
|
* fix IgnoreSilentlyException message
|
187
255
|
|
188
|
-
v2.7.4
|
256
|
+
v2.7.4.
|
189
257
|
* fix error when trying to serialize some kinds of Enumerable objects
|
190
258
|
* added extra debug logging
|
191
259
|
* added app_name to app mapping
|
192
260
|
|
193
|
-
v2.7.3
|
261
|
+
v2.7.3.
|
194
262
|
* fix compatibility issue with 1.8.5 causing error with Dir.glob
|
195
263
|
|
196
|
-
v2.7.2
|
264
|
+
v2.7.2.
|
197
265
|
* fix problem with passenger edge not being a detected environment
|
198
266
|
|
199
|
-
v2.7.1
|
267
|
+
v2.7.1.
|
200
268
|
* fix problem with skipped dispatcher instrumentation
|
201
269
|
|
202
|
-
v2.7.0
|
270
|
+
v2.7.0.
|
203
271
|
* Repackage to support both plugin and Gem installation
|
204
272
|
* Support passenger/litespeed/jruby application naming
|
205
273
|
* Update method for calculating dispatcher queue time
|
@@ -210,62 +278,62 @@ v2.7.0
|
|
210
278
|
* Performance tuning
|
211
279
|
* bugfixes
|
212
280
|
|
213
|
-
v2.5.3
|
281
|
+
v2.5.3.
|
214
282
|
* fix error in transaction tracing causing traces not to show up
|
215
283
|
|
216
|
-
v2.5.2
|
284
|
+
v2.5.2.
|
217
285
|
* fixes for postgres explain plan support
|
218
286
|
|
219
|
-
v2.5.1
|
287
|
+
v2.5.1.
|
220
288
|
* bugfixes
|
221
289
|
|
222
|
-
v2.5.0
|
290
|
+
v2.5.0.
|
223
291
|
* add agent support for rpm 1.1 features
|
224
292
|
* Fix regression error with thin support
|
225
293
|
|
226
|
-
v2.4.3
|
294
|
+
v2.4.3.
|
227
295
|
* added 'newrelic_ignore' controller class method with :except and :only options for finer grained control
|
228
296
|
over the blocking of instrumentation in controllers.
|
229
297
|
* bugfixes
|
230
298
|
|
231
|
-
v2.4.2
|
299
|
+
v2.4.2.
|
232
300
|
* error reporting in early access
|
233
301
|
|
234
|
-
v2.4.1
|
302
|
+
v2.4.1.
|
235
303
|
* bugfix: initializing developer mode
|
236
304
|
|
237
|
-
v2.4.0
|
305
|
+
v2.4.0.
|
238
306
|
* Beta support for LiteSpeed and Passenger
|
239
307
|
|
240
|
-
v2.3.7
|
308
|
+
v2.3.7.
|
241
309
|
* bugfixes
|
242
310
|
|
243
|
-
v2.3.6
|
311
|
+
v2.3.6.
|
244
312
|
* bugfixes
|
245
313
|
|
246
|
-
v2.3.5
|
314
|
+
v2.3.5.
|
247
315
|
* bugfixes: pie chart data, rails 1.1 compability
|
248
316
|
|
249
|
-
v2.3.4
|
317
|
+
v2.3.4.
|
250
318
|
* bugfix
|
251
319
|
|
252
|
-
v2.3.3
|
320
|
+
v2.3.3.
|
253
321
|
* bugfix for non-mysql databases
|
254
322
|
|
255
|
-
v2.3.2
|
323
|
+
v2.3.2.
|
256
324
|
* bugfixes
|
257
325
|
* Add enhancement for Transaction Traces early access feature
|
258
326
|
|
259
|
-
v2.3.1
|
327
|
+
v2.3.1.
|
260
328
|
* bugfixes
|
261
329
|
|
262
|
-
v2.3.0
|
330
|
+
v2.3.0.
|
263
331
|
+ Add support for Transaction Traces early access feature
|
264
332
|
|
265
|
-
v2.2.2
|
333
|
+
v2.2.2.
|
266
334
|
* bugfixes
|
267
335
|
|
268
|
-
v2.2.1
|
336
|
+
v2.2.1.
|
269
337
|
+ Add rails 2.1 support for Developer Mode
|
270
338
|
+ Changes to memory sampler: Add support for JRuby and fix Solaris support.
|
271
339
|
* Stop catching exceptions and start catching StandardError; other exception cleanup
|
@@ -273,25 +341,25 @@ v2.2.1
|
|
273
341
|
* Improved support for thin domain sockets
|
274
342
|
* Support JRuby environments
|
275
343
|
|
276
|
-
v2.1.6
|
344
|
+
v2.1.6.
|
277
345
|
* bugfixes
|
278
346
|
|
279
|
-
v2.1.5
|
347
|
+
v2.1.5.
|
280
348
|
* bugfixes
|
281
349
|
|
282
|
-
v2.1.4
|
350
|
+
v2.1.4.
|
283
351
|
* bugfixes
|
284
352
|
|
285
|
-
v2.1.3
|
353
|
+
v2.1.3.
|
286
354
|
* bugfixes
|
287
355
|
|
288
|
-
v2.1.2
|
356
|
+
v2.1.2.
|
289
357
|
* bugfixes
|
290
358
|
|
291
|
-
v2.1.1
|
359
|
+
v2.1.1.
|
292
360
|
* bugfixes
|
293
361
|
|
294
|
-
v2.1.0
|
362
|
+
v2.1.0.
|
295
363
|
* release for private beta
|
296
364
|
|
297
365
|
|
data/bin/mongrel_rpm
CHANGED
@@ -22,12 +22,12 @@ end
|
|
22
22
|
|
23
23
|
options[:app_name] = appname if appname
|
24
24
|
|
25
|
-
ru_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "new_relic", "rack", "
|
25
|
+
ru_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "new_relic", "rack", "mongrel_rpm.ru"))
|
26
26
|
rackup_code = File.read ru_file
|
27
27
|
builder = Rack::Builder.new { eval rackup_code, binding, ru_file }
|
28
28
|
|
29
29
|
options = { :Host => '127.0.0.1', :Port => port }
|
30
30
|
Rack::Handler::Mongrel.run(builder.to_app, options) do | server |
|
31
|
-
|
31
|
+
NewRelic::Control.instance.log! "Started Mongrel listening for '#{NewRelic::Control.instance.app_names.join(" and ")}' data at #{server.host}:#{server.port}"
|
32
32
|
end
|
33
33
|
|
data/install.rb
CHANGED
@@ -1,37 +1,46 @@
|
|
1
|
-
require '
|
1
|
+
require 'fileutils'
|
2
2
|
require 'erb'
|
3
3
|
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
else
|
12
|
-
dest_dir = File.join(ENV["HOME"],".newrelic") rescue nil
|
13
|
-
FileUtils.mkdir(dest_dir) if dest_dir
|
14
|
-
end
|
15
|
-
|
16
|
-
src_config_file = File.join(File.dirname(__FILE__),"newrelic.yml")
|
17
|
-
dest_config_file = File.join(dest_dir, "newrelic.yml") if dest_dir
|
18
|
-
|
19
|
-
if !dest_dir
|
20
|
-
STDERR.puts "Could not find a config or ~/.newrelic directory to locate the default newrelic.yml file"
|
21
|
-
elsif File::exists? dest_config_file
|
22
|
-
STDERR.puts "\nA config file already exists at #{dest_config_file}.\n"
|
23
|
-
else
|
24
|
-
generated_for_user = ""
|
25
|
-
license_key = "PASTE_YOUR_KEY_HERE"
|
26
|
-
yaml = ERB.new(File.read(src_config_file)).result(binding)
|
27
|
-
File.open( dest_config_file, 'w' ) do |out|
|
28
|
-
out.puts yaml
|
4
|
+
def install_newrelic_config_file(license_key="PASTE_YOUR_LICENSE_KEY_HERE")
|
5
|
+
# Install a newrelic.yml file into the local config directory.
|
6
|
+
if File.directory? "config"
|
7
|
+
dest_dir = "config"
|
8
|
+
else
|
9
|
+
dest_dir = File.join(ENV["HOME"],".newrelic") rescue nil
|
10
|
+
FileUtils.mkdir(dest_dir) if dest_dir
|
29
11
|
end
|
30
12
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
13
|
+
src_config_file = File.join(File.dirname(__FILE__),"newrelic.yml")
|
14
|
+
dest_config_file = File.join(dest_dir, "newrelic.yml") if dest_dir
|
15
|
+
|
16
|
+
if !dest_dir
|
17
|
+
STDERR.puts "Could not find a config or ~/.newrelic directory to locate the default newrelic.yml file"
|
18
|
+
elsif File::exists? dest_config_file
|
19
|
+
STDERR.puts "\nA config file already exists at #{dest_config_file}.\n"
|
20
|
+
else
|
21
|
+
generated_for_user = ""
|
22
|
+
yaml = ERB.new(File.read(src_config_file)).result(binding)
|
23
|
+
File.open( dest_config_file, 'w' ) do |out|
|
24
|
+
out.puts yaml
|
25
|
+
end
|
26
|
+
|
27
|
+
puts <<-EOF
|
28
|
+
|
29
|
+
Installed a default configuration file in #{dest_dir}.
|
30
|
+
|
31
|
+
To monitor your application in production mode, sign up for an account
|
32
|
+
at www.newrelic.com, and replace the newrelic.yml file with the one
|
33
|
+
you receive upon registration.
|
34
|
+
|
35
|
+
Please review the README.md file for more information.
|
36
|
+
|
37
|
+
E-mail support@newrelic.com with any problems or questions.
|
38
|
+
|
39
|
+
EOF
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if __FILE__ == $0 || $0 =~ /script\/plugin/
|
45
|
+
install_newrelic_config_file
|
46
|
+
end
|
data/lib/new_relic/agent.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
# = New Relic Agent
|
2
2
|
#
|
3
|
-
# New Relic RPM is a performance monitoring application for Ruby
|
4
|
-
# in production. For more information on RPM
|
3
|
+
# New Relic RPM is a performance monitoring application for Ruby
|
4
|
+
# applications running in production. For more information on RPM
|
5
|
+
# please visit http://www.newrelic.com.
|
5
6
|
#
|
6
|
-
# The New Relic Agent can be installed in
|
7
|
-
# metrics, traces, and errors for display in a
|
8
|
-
#
|
7
|
+
# The New Relic Agent can be installed in Rails applications to gather
|
8
|
+
# runtime performance metrics, traces, and errors for display in a
|
9
|
+
# Developer Mode UI (mapped to /newrelic in your application server)
|
10
|
+
# or for monitoring and analysis at http://rpm.newrelic.com with just
|
11
|
+
# about any Ruby application.
|
9
12
|
#
|
10
|
-
# For detailed information on configuring or customizing the RPM Agent
|
11
|
-
# {support and documentation site}[http://support.newrelic.com].
|
13
|
+
# For detailed information on configuring or customizing the RPM Agent
|
14
|
+
# please visit our {support and documentation site}[http://support.newrelic.com].
|
12
15
|
#
|
13
16
|
# == Starting the Agent as a Gem
|
14
17
|
#
|
@@ -20,36 +23,71 @@
|
|
20
23
|
# dependency 'newrelic_rpm'
|
21
24
|
# in the Merb config/init.rb
|
22
25
|
#
|
23
|
-
# For
|
24
|
-
#
|
26
|
+
# For Sinatra, just require the +newrelic_rpm+ gem and it will
|
27
|
+
# automatically detect Sinatra and instrument all the handlers.
|
28
|
+
#
|
29
|
+
# For other frameworks, or to manage the agent manually,
|
30
|
+
# invoke NewRelic::Agent#manual_start directly.
|
25
31
|
#
|
26
32
|
# == Configuring the Agent
|
27
33
|
#
|
28
|
-
# All agent configuration is done in the
|
29
|
-
# default read from the +config+ directory of the
|
30
|
-
#
|
34
|
+
# All agent configuration is done in the <tt>newrelic.yml</tt> file. This
|
35
|
+
# file is by default read from the +config+ directory of the
|
36
|
+
# application root and is subsequently searched for in the application
|
37
|
+
# root directory, and then in a <tt>~/.newrelic</tt> directory
|
38
|
+
#
|
39
|
+
# == Using with Rack/Metal
|
31
40
|
#
|
32
|
-
#
|
41
|
+
# To instrument middlewares, refer to the docs in
|
42
|
+
# NewRelic::Agent::Instrumentation::Rack.
|
33
43
|
#
|
34
|
-
#
|
44
|
+
# == Agent API
|
45
|
+
#
|
46
|
+
# For details on the Agent API, refer to NewRelic::Agent.
|
47
|
+
#
|
35
48
|
#
|
36
49
|
# :main: lib/new_relic/agent.rb
|
37
50
|
module NewRelic
|
38
|
-
|
39
|
-
#
|
40
|
-
#
|
51
|
+
# == Agent APIs
|
52
|
+
# This module contains the public API methods for the Agent.
|
53
|
+
#
|
54
|
+
# For adding custom instrumentation to method invocations, refer to
|
55
|
+
# the docs in the class NewRelic::Agent::MethodTracer.
|
56
|
+
#
|
57
|
+
# For information on how to customize the controller
|
58
|
+
# instrumentation, or to instrument something other than Rails so
|
59
|
+
# that high level dispatcher actions or background tasks show up as
|
60
|
+
# first class operations in RPM, refer to
|
61
|
+
# NewRelic::Agent::Instrumentation::ControllerInstrumentation and
|
62
|
+
# NewRelic::Agent::Instrumentation::ControllerInstrumentation::ClassMethods.
|
63
|
+
#
|
64
|
+
# Methods in this module as well as documented methods in
|
65
|
+
# NewRelic::Agent::MethodTracer and
|
66
|
+
# NewRelic::Agent::Instrumentation::ControllerInstrumentation are
|
67
|
+
# available to applications. When the agent is not enabled the
|
68
|
+
# method implementations are stubbed into no-ops to reduce overhead.
|
69
|
+
#
|
70
|
+
# Methods and classes in other parts of the agent are not guaranteed
|
71
|
+
# to be available between releases.
|
72
|
+
#
|
73
|
+
# Refer to the online docs at support.newrelic.com to see how to
|
74
|
+
# access the data collected by custom instrumentation, or e-mail
|
75
|
+
# support at New Relic for help.
|
41
76
|
module Agent
|
42
77
|
extend self
|
43
78
|
|
44
79
|
require 'new_relic/version'
|
45
80
|
require 'new_relic/local_environment'
|
46
81
|
require 'new_relic/stats'
|
82
|
+
require 'new_relic/delayed_job_injection'
|
83
|
+
require 'new_relic/metrics'
|
47
84
|
require 'new_relic/metric_spec'
|
48
85
|
require 'new_relic/metric_data'
|
49
86
|
require 'new_relic/metric_parser'
|
50
87
|
require 'new_relic/transaction_analysis'
|
51
88
|
require 'new_relic/transaction_sample'
|
52
89
|
require 'new_relic/noticed_error'
|
90
|
+
require 'new_relic/histogram'
|
53
91
|
|
54
92
|
require 'new_relic/agent/chained_call'
|
55
93
|
require 'new_relic/agent/agent'
|
@@ -60,13 +98,14 @@ module NewRelic
|
|
60
98
|
require 'new_relic/agent/collection_helper'
|
61
99
|
require 'new_relic/agent/transaction_sampler'
|
62
100
|
require 'new_relic/agent/error_collector'
|
101
|
+
require 'new_relic/agent/busy_calculator'
|
63
102
|
require 'new_relic/agent/sampler'
|
64
103
|
|
65
104
|
require 'new_relic/agent/samplers/cpu_sampler'
|
66
105
|
require 'new_relic/agent/samplers/memory_sampler'
|
67
|
-
require 'new_relic/agent/samplers/
|
106
|
+
require 'new_relic/agent/samplers/object_sampler'
|
107
|
+
require 'new_relic/agent/samplers/delayed_job_lock_sampler'
|
68
108
|
require 'set'
|
69
|
-
require 'sync'
|
70
109
|
require 'thread'
|
71
110
|
require 'resolv'
|
72
111
|
require 'timeout'
|
@@ -76,6 +115,9 @@ module NewRelic
|
|
76
115
|
|
77
116
|
# An exception that forces an agent to stop reporting until its mongrel is restarted.
|
78
117
|
class ForceDisconnectException < StandardError; end
|
118
|
+
|
119
|
+
# An exception that forces an agent to restart.
|
120
|
+
class ForceRestartException < StandardError; end
|
79
121
|
|
80
122
|
# Used to blow out of a periodic task without logging a an error, such as for routine
|
81
123
|
# failures.
|
@@ -90,19 +132,19 @@ module NewRelic
|
|
90
132
|
|
91
133
|
class BackgroundLoadingError < StandardError; end
|
92
134
|
|
93
|
-
|
135
|
+
@agent = nil
|
94
136
|
|
95
|
-
# The singleton Agent instance.
|
96
|
-
def agent
|
97
|
-
raise "Plugin not initialized!" if
|
98
|
-
|
137
|
+
# The singleton Agent instance. Used internally.
|
138
|
+
def agent #:nodoc:
|
139
|
+
raise "Plugin not initialized!" if @agent.nil?
|
140
|
+
@agent
|
99
141
|
end
|
100
142
|
|
101
|
-
def agent= new_instance
|
102
|
-
|
143
|
+
def agent= new_instance #:nodoc:
|
144
|
+
@agent = new_instance
|
103
145
|
end
|
104
146
|
|
105
|
-
alias instance agent
|
147
|
+
alias instance agent #:nodoc:
|
106
148
|
|
107
149
|
# Get or create a statistics gatherer that will aggregate numerical data
|
108
150
|
# under a metric name.
|
@@ -113,12 +155,10 @@ module NewRelic
|
|
113
155
|
# Return a NewRelic::Stats that accepts data
|
114
156
|
# via calls to add_data_point(value).
|
115
157
|
def get_stats(metric_name, use_scope=false)
|
116
|
-
|
158
|
+
@agent.stats_engine.get_stats(metric_name, use_scope)
|
117
159
|
end
|
118
160
|
|
119
|
-
|
120
|
-
@@agent.stats_engine.get_stats_no_scope(metric_name)
|
121
|
-
end
|
161
|
+
alias get_stats_no_scope get_stats
|
122
162
|
|
123
163
|
# Call this to manually start the Agent in situations where the Agent does
|
124
164
|
# not auto-start.
|
@@ -140,6 +180,21 @@ module NewRelic
|
|
140
180
|
options.merge! :agent_enabled => true
|
141
181
|
NewRelic::Control.instance.init_plugin options
|
142
182
|
end
|
183
|
+
|
184
|
+
# Shutdown the agent. Call this before exiting. Sends any queued data
|
185
|
+
# and kills the background thread.
|
186
|
+
def shutdown
|
187
|
+
@agent.shutdown
|
188
|
+
end
|
189
|
+
|
190
|
+
# Add instrumentation files to the agent. The argument should be a glob
|
191
|
+
# matching ruby scripts which will be executed at the time instrumentation
|
192
|
+
# is loaded. Since instrumentation is not loaded when the agent is not
|
193
|
+
# running it's better to use this method to register instrumentation than
|
194
|
+
# just loading the files directly, although that probably also works.
|
195
|
+
def add_instrumentation file_pattern
|
196
|
+
NewRelic::Control.instance.add_instrumentation file_pattern
|
197
|
+
end
|
143
198
|
|
144
199
|
# This method sets the block sent to this method as a sql obfuscator.
|
145
200
|
# The block will be called with a single String SQL statement to obfuscate.
|
@@ -178,7 +233,7 @@ module NewRelic
|
|
178
233
|
end
|
179
234
|
|
180
235
|
# This method disables the recording of transaction traces in the given
|
181
|
-
# block.
|
236
|
+
# block. See also #disable_all_tracing
|
182
237
|
def disable_transaction_tracing
|
183
238
|
state = agent.set_record_tt(false)
|
184
239
|
begin
|
@@ -188,21 +243,76 @@ module NewRelic
|
|
188
243
|
end
|
189
244
|
end
|
190
245
|
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
246
|
+
# Cancel the collection of the current transaction in progress, if any.
|
247
|
+
# Only affects the transaction started on this thread once it has started
|
248
|
+
# and before it has completed.
|
249
|
+
def abort_transaction!
|
250
|
+
# The class may not be loaded if the agent is disabled
|
251
|
+
if defined? NewRelic::Agent::Instrumentation::MetricFrame
|
252
|
+
NewRelic::Agent::Instrumentation::MetricFrame.abort_transaction!
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# Yield to the block without collecting any metrics or traces in any of the
|
257
|
+
# subsequent calls. If executed recursively, will keep track of the first
|
258
|
+
# entry point and turn on tracing again after leaving that block.
|
259
|
+
# This uses the thread local +newrelic_untrace+
|
260
|
+
def disable_all_tracing
|
261
|
+
agent.push_trace_execution_flag(false)
|
262
|
+
yield
|
263
|
+
ensure
|
264
|
+
agent.pop_trace_execution_flag
|
265
|
+
end
|
266
|
+
|
267
|
+
# Check to see if we are capturing metrics currently on this thread.
|
268
|
+
def is_execution_traced?
|
269
|
+
Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
|
270
|
+
end
|
271
|
+
|
272
|
+
# Set a filter to be applied to errors that RPM will track.
|
273
|
+
# The block should evalute to the exception to track (which could be different from
|
274
|
+
# the original exception) or nil to ignore this exception.
|
275
|
+
#
|
276
|
+
# The block is yielded to with the exception to filter.
|
277
|
+
#
|
278
|
+
# Do not call return.
|
194
279
|
#
|
195
280
|
def ignore_error_filter(&block)
|
196
281
|
agent.error_collector.ignore_error_filter(&block)
|
197
282
|
end
|
198
283
|
|
199
|
-
#
|
284
|
+
# Record the given error in RPM. It will be passed through the #ignore_error_filter
|
285
|
+
# if there is one.
|
286
|
+
#
|
287
|
+
# * <tt>exception</tt> is the exception which will be recorded
|
288
|
+
# * <tt>extra_params</tt> is a hash of name value pairs to appear alongside
|
289
|
+
# the exception in RPM.
|
290
|
+
#
|
291
|
+
def notice_error(exception, extra_params = nil)
|
292
|
+
NewRelic::Agent::Instrumentation::MetricFrame.notice_error(exception, extra_params)
|
293
|
+
end
|
294
|
+
|
295
|
+
# Add parameters to the current transaction trace on the call stack.
|
200
296
|
#
|
201
297
|
def add_custom_parameters(params)
|
202
|
-
|
298
|
+
NewRelic::Agent::Instrumentation::MetricFrame.add_custom_parameters(params)
|
203
299
|
end
|
204
300
|
|
205
301
|
alias add_request_parameters add_custom_parameters
|
206
|
-
|
302
|
+
|
303
|
+
# Yield to a block that is run with a database metric name context. This means
|
304
|
+
# the Database instrumentation will use this for the metric name if it does not
|
305
|
+
# otherwise know about a model. This is re-entrant.
|
306
|
+
#
|
307
|
+
# * <tt>model</tt> is the DB model class
|
308
|
+
# * <tt>method</tt> is the name of the finder method or other method to identify the operation with.
|
309
|
+
#
|
310
|
+
def with_database_metric_name(model, method, &block)
|
311
|
+
if frame = NewRelic::Agent::Instrumentation::MetricFrame.current
|
312
|
+
frame.with_database_metric_name(model, method, &block)
|
313
|
+
else
|
314
|
+
yield
|
315
|
+
end
|
316
|
+
end
|
207
317
|
end
|
208
|
-
end
|
318
|
+
end
|