genki-newrelic_rpm 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/CHANGELOG +316 -0
  2. data/LICENSE +37 -0
  3. data/Manifest +156 -0
  4. data/README.md +138 -0
  5. data/Rakefile +22 -0
  6. data/bin/mongrel_rpm +33 -0
  7. data/bin/newrelic_cmd +4 -0
  8. data/cert/cacert.pem +34 -0
  9. data/genki-newrelic_rpm.gemspec +32 -0
  10. data/init.rb +38 -0
  11. data/install.rb +37 -0
  12. data/lib/new_relic/agent.rb +280 -0
  13. data/lib/new_relic/agent/agent.rb +627 -0
  14. data/lib/new_relic/agent/chained_call.rb +13 -0
  15. data/lib/new_relic/agent/collection_helper.rb +61 -0
  16. data/lib/new_relic/agent/error_collector.rb +125 -0
  17. data/lib/new_relic/agent/instrumentation/active_merchant.rb +18 -0
  18. data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +83 -0
  19. data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -0
  20. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +368 -0
  21. data/lib/new_relic/agent/instrumentation/data_mapper.rb +90 -0
  22. data/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb +132 -0
  23. data/lib/new_relic/agent/instrumentation/memcache.rb +21 -0
  24. data/lib/new_relic/agent/instrumentation/merb/controller.rb +26 -0
  25. data/lib/new_relic/agent/instrumentation/merb/dispatcher.rb +13 -0
  26. data/lib/new_relic/agent/instrumentation/merb/errors.rb +8 -0
  27. data/lib/new_relic/agent/instrumentation/net.rb +12 -0
  28. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +20 -0
  29. data/lib/new_relic/agent/instrumentation/rack.rb +77 -0
  30. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +59 -0
  31. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +27 -0
  32. data/lib/new_relic/agent/instrumentation/rails/dispatcher.rb +38 -0
  33. data/lib/new_relic/agent/instrumentation/rails/errors.rb +27 -0
  34. data/lib/new_relic/agent/instrumentation/sinatra.rb +39 -0
  35. data/lib/new_relic/agent/method_tracer.rb +277 -0
  36. data/lib/new_relic/agent/patch_const_missing.rb +125 -0
  37. data/lib/new_relic/agent/sampler.rb +12 -0
  38. data/lib/new_relic/agent/samplers/cpu_sampler.rb +49 -0
  39. data/lib/new_relic/agent/samplers/memory_sampler.rb +137 -0
  40. data/lib/new_relic/agent/samplers/mongrel_sampler.rb +22 -0
  41. data/lib/new_relic/agent/shim_agent.rb +21 -0
  42. data/lib/new_relic/agent/stats_engine.rb +24 -0
  43. data/lib/new_relic/agent/stats_engine/metric_stats.rb +111 -0
  44. data/lib/new_relic/agent/stats_engine/samplers.rb +71 -0
  45. data/lib/new_relic/agent/stats_engine/transactions.rb +155 -0
  46. data/lib/new_relic/agent/transaction_sampler.rb +319 -0
  47. data/lib/new_relic/agent/worker_loop.rb +118 -0
  48. data/lib/new_relic/commands/deployments.rb +145 -0
  49. data/lib/new_relic/commands/new_relic_commands.rb +30 -0
  50. data/lib/new_relic/control.rb +436 -0
  51. data/lib/new_relic/control/external.rb +13 -0
  52. data/lib/new_relic/control/merb.rb +22 -0
  53. data/lib/new_relic/control/rails.rb +143 -0
  54. data/lib/new_relic/control/ruby.rb +34 -0
  55. data/lib/new_relic/control/sinatra.rb +14 -0
  56. data/lib/new_relic/histogram.rb +89 -0
  57. data/lib/new_relic/local_environment.rb +285 -0
  58. data/lib/new_relic/merbtasks.rb +6 -0
  59. data/lib/new_relic/metric_data.rb +44 -0
  60. data/lib/new_relic/metric_parser.rb +120 -0
  61. data/lib/new_relic/metric_parser/action_mailer.rb +9 -0
  62. data/lib/new_relic/metric_parser/active_merchant.rb +26 -0
  63. data/lib/new_relic/metric_parser/active_record.rb +25 -0
  64. data/lib/new_relic/metric_parser/controller.rb +54 -0
  65. data/lib/new_relic/metric_parser/controller_cpu.rb +38 -0
  66. data/lib/new_relic/metric_parser/errors.rb +6 -0
  67. data/lib/new_relic/metric_parser/external.rb +50 -0
  68. data/lib/new_relic/metric_parser/mem_cache.rb +12 -0
  69. data/lib/new_relic/metric_parser/view.rb +61 -0
  70. data/lib/new_relic/metric_parser/web_frontend.rb +14 -0
  71. data/lib/new_relic/metric_parser/web_service.rb +9 -0
  72. data/lib/new_relic/metric_spec.rb +52 -0
  73. data/lib/new_relic/metrics.rb +7 -0
  74. data/lib/new_relic/noticed_error.rb +25 -0
  75. data/lib/new_relic/rack/metric_app.rb +56 -0
  76. data/lib/new_relic/rack/newrelic.ru +25 -0
  77. data/lib/new_relic/rack/newrelic.yml +25 -0
  78. data/lib/new_relic/rack_app.rb +5 -0
  79. data/lib/new_relic/recipes.rb +82 -0
  80. data/lib/new_relic/stats.rb +360 -0
  81. data/lib/new_relic/transaction_analysis.rb +121 -0
  82. data/lib/new_relic/transaction_sample.rb +583 -0
  83. data/lib/new_relic/version.rb +54 -0
  84. data/lib/new_relic_api.rb +315 -0
  85. data/lib/newrelic_rpm.rb +40 -0
  86. data/lib/tasks/all.rb +4 -0
  87. data/lib/tasks/install.rake +7 -0
  88. data/lib/tasks/tests.rake +13 -0
  89. data/newrelic.yml +214 -0
  90. data/recipes/newrelic.rb +6 -0
  91. data/test/active_record_fixtures.rb +55 -0
  92. data/test/config/newrelic.yml +46 -0
  93. data/test/config/test_control.rb +39 -0
  94. data/test/new_relic/agent/active_record_instrumentation_test.rb +234 -0
  95. data/test/new_relic/agent/agent_controller_test.rb +107 -0
  96. data/test/new_relic/agent/agent_test.rb +117 -0
  97. data/test/new_relic/agent/agent_test_controller.rb +44 -0
  98. data/test/new_relic/agent/classloader_patch_test.rb +56 -0
  99. data/test/new_relic/agent/collection_helper_test.rb +118 -0
  100. data/test/new_relic/agent/dispatcher_instrumentation_test.rb +76 -0
  101. data/test/new_relic/agent/error_collector_test.rb +155 -0
  102. data/test/new_relic/agent/method_tracer_test.rb +335 -0
  103. data/test/new_relic/agent/metric_data_test.rb +56 -0
  104. data/test/new_relic/agent/mock_ar_connection.rb +40 -0
  105. data/test/new_relic/agent/mock_scope_listener.rb +23 -0
  106. data/test/new_relic/agent/net_instrumentation_test.rb +51 -0
  107. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +79 -0
  108. data/test/new_relic/agent/stats_engine/samplers_test.rb +78 -0
  109. data/test/new_relic/agent/stats_engine/stats_engine_test.rb +177 -0
  110. data/test/new_relic/agent/task_instrumentation_test.rb +67 -0
  111. data/test/new_relic/agent/testable_agent.rb +13 -0
  112. data/test/new_relic/agent/transaction_sample_builder_test.rb +195 -0
  113. data/test/new_relic/agent/transaction_sample_test.rb +146 -0
  114. data/test/new_relic/agent/transaction_sampler_test.rb +387 -0
  115. data/test/new_relic/agent/worker_loop_test.rb +103 -0
  116. data/test/new_relic/control_test.rb +94 -0
  117. data/test/new_relic/deployments_api_test.rb +68 -0
  118. data/test/new_relic/environment_test.rb +75 -0
  119. data/test/new_relic/metric_parser_test.rb +172 -0
  120. data/test/new_relic/metric_spec_test.rb +177 -0
  121. data/test/new_relic/shim_agent_test.rb +9 -0
  122. data/test/new_relic/stats_test.rb +291 -0
  123. data/test/new_relic/version_number_test.rb +74 -0
  124. data/test/test_helper.rb +38 -0
  125. data/test/ui/newrelic_controller_test.rb +14 -0
  126. data/test/ui/newrelic_helper_test.rb +53 -0
  127. data/ui/controllers/newrelic_controller.rb +214 -0
  128. data/ui/helpers/google_pie_chart.rb +55 -0
  129. data/ui/helpers/newrelic_helper.rb +314 -0
  130. data/ui/views/layouts/newrelic_default.rhtml +47 -0
  131. data/ui/views/newrelic/_explain_plans.rhtml +27 -0
  132. data/ui/views/newrelic/_sample.rhtml +15 -0
  133. data/ui/views/newrelic/_segment.rhtml +28 -0
  134. data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
  135. data/ui/views/newrelic/_segment_row.rhtml +14 -0
  136. data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
  137. data/ui/views/newrelic/_show_sample_sql.rhtml +20 -0
  138. data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
  139. data/ui/views/newrelic/_sql_row.rhtml +11 -0
  140. data/ui/views/newrelic/_stack_trace.rhtml +30 -0
  141. data/ui/views/newrelic/_table.rhtml +12 -0
  142. data/ui/views/newrelic/explain_sql.rhtml +42 -0
  143. data/ui/views/newrelic/images/arrow-close.png +0 -0
  144. data/ui/views/newrelic/images/arrow-open.png +0 -0
  145. data/ui/views/newrelic/images/blue_bar.gif +0 -0
  146. data/ui/views/newrelic/images/file_icon.png +0 -0
  147. data/ui/views/newrelic/images/gray_bar.gif +0 -0
  148. data/ui/views/newrelic/images/new_relic_rpm_desktop.gif +0 -0
  149. data/ui/views/newrelic/images/textmate.png +0 -0
  150. data/ui/views/newrelic/index.rhtml +45 -0
  151. data/ui/views/newrelic/javascript/prototype-scriptaculous.js +7288 -0
  152. data/ui/views/newrelic/javascript/transaction_sample.js +107 -0
  153. data/ui/views/newrelic/sample_not_found.rhtml +2 -0
  154. data/ui/views/newrelic/show_sample.rhtml +77 -0
  155. data/ui/views/newrelic/show_source.rhtml +3 -0
  156. data/ui/views/newrelic/stylesheets/style.css +433 -0
  157. data/ui/views/newrelic/threads.rhtml +52 -0
  158. metadata +327 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby
2
+ module NewRelic
3
+ module VERSION #:nodoc:
4
+ MAJOR = 2
5
+ MINOR = 10
6
+ TINY = 1
7
+ EXPERIMENTAL = 3
8
+ STRING = [MAJOR, MINOR, TINY, EXPERIMENTAL].compact.join('.')
9
+ end
10
+
11
+ # Helper class for managing version comparisons
12
+ class VersionNumber
13
+ attr_reader :parts
14
+ include Comparable
15
+ def initialize(version_string)
16
+ version_string ||= '1.0.0'
17
+ @parts = version_string.split('.').map{|n| n.to_i }
18
+ end
19
+ def major_version; @parts[0]; end
20
+ def minor_version; @parts[1]; end
21
+ def tiny_version; @parts[2]; end
22
+
23
+ def <=>(other)
24
+ other = self.class.new(other) if other.is_a? String
25
+ self.class.compare(self.parts, other.parts)
26
+ end
27
+
28
+ def to_s
29
+ @parts.join(".")
30
+ end
31
+
32
+ def hash
33
+ @parts.hash
34
+ end
35
+
36
+ def eql? other
37
+ (self <=> other) == 0
38
+ end
39
+
40
+ private
41
+ def self.compare(parts1, parts2)
42
+ a, b = parts1.first, parts2.first
43
+ case
44
+ when a.nil? && b.nil? then 0
45
+ when a.nil? then -1
46
+ when b.nil? then 1
47
+ when a == b
48
+ compare(parts1[1..-1], parts2[1..-1])
49
+ else
50
+ a <=> b
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,315 @@
1
+ # == REST API Helpers
2
+ #
3
+ # Ruby lib for working with the New Relic API's XML interface. Requires Rails 2.0 or later to be loaded.
4
+ #
5
+ # Can also be used as a script using script/runner
6
+ #
7
+ # Authentication is handled using your agent license key or HTTP Basic Authentication. To authenticate
8
+ # using your license key your newrelic.yml configuration file must be in your application config directory
9
+ # and contain your license key. The New Relic account associated with the license key must allow api access.
10
+ # Log into RPM, click Account at the top of the page and check the "Make my account data accessible" checkbox.
11
+ #
12
+ # Basic authentication uses your site credentials to authenticate.
13
+ #
14
+ # # To authenticate using basic authentication, make this call with your username and password:
15
+ # NewRelicApi.authenticate('user@example.com', 'test')
16
+ #
17
+ # This API does not have any agent dependencies. It can be used independent of the agent by copying it into your application.
18
+ #
19
+ # == Examples
20
+ #
21
+ # # Fetching the list of applications for an account
22
+ # NewRelicApi::Account.find(:first).applications
23
+ #
24
+ # # Fetching the health values for all account applications
25
+ # NewRelicApi::Account.application_health
26
+ #
27
+ # # Fetching the health values for an application
28
+ # NewRelicApi::Account.find(:first).applications.first.threshold_values
29
+ #
30
+ # # Finding an application by name
31
+ # NewRelicApi::Account.find(:first).applications(:params => {:conditions => {:name => 'My App'}})
32
+ #
33
+
34
+ module NewRelicApi
35
+
36
+ # This mixin defines ActiveRecord style associations (like has_many) for ActiveResource objects.
37
+ # ActiveResource objects using this mixin must define the method 'query_params'.
38
+ module ActiveResourceAssociations #:nodoc:
39
+ class << self
40
+ protected
41
+ def included(base)
42
+ class << base
43
+ # a special activeresource implementation of has_many
44
+ def has_many(*associations)
45
+ associations.to_a.each do |association|
46
+ define_method association do |*args|
47
+ val = attributes[association.to_s] # if we've already fetched the relationship in the initial fetch, return it
48
+ return val if val
49
+
50
+ options = args.extract_options!
51
+ type = args.first || :all
52
+
53
+ begin
54
+ # look for the class definition within the current class
55
+ clazz = ( self.class.name + '::' + association.to_s.camelize.singularize).constantize
56
+ rescue
57
+ # look for the class definition in the NRAPI module
58
+ clazz = ( 'NewRelicApi::' + association.to_s.camelize.singularize).constantize
59
+ end
60
+ params = (options[:params] || {}).update(self.query_params)
61
+ options[:params] = params
62
+ clazz.find(type, options)
63
+
64
+ #clazz.find(type, :params => options.update(self.query_params))
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ class << self
74
+ attr_accessor :email, :password, :license_key, :ssl, :host, :port
75
+
76
+ # Sets up basic authentication credentials for all the resources. This is not necessary if you are
77
+ # using agent license key authentication.
78
+ def authenticate(email, password)
79
+ @password = password
80
+ @email = email
81
+ end
82
+
83
+ # Resets the base path of all resources. This should be called when overridding the newrelic.yml settings
84
+ # using the ssl, host or port accessors.
85
+ def reset!
86
+ @classes.each {|klass| klass.reset!} if @classes
87
+ NewRelicApi::Account.site_url
88
+ end
89
+
90
+
91
+ def track_resource(klass) #:nodoc:
92
+ (@classes ||= []) << klass
93
+ end
94
+ end
95
+
96
+ class BaseResource < ActiveResource::Base #:nodoc:
97
+ include ActiveResourceAssociations
98
+
99
+ class << self
100
+ def inherited(klass) #:nodoc:
101
+ NewRelicApi.track_resource(klass)
102
+ end
103
+
104
+ def headers
105
+ h = {'x-license-key' => NewRelicApi.license_key || NewRelic::Control.instance['license_key']}
106
+ h['Authorization'] = 'Basic ' + ["#{NewRelicApi.email}:#{NewRelicApi.password}"].pack('m').delete("\r\n") if NewRelicApi.email
107
+ h
108
+ end
109
+
110
+ def site_url
111
+ host = NewRelicApi.host || NewRelic::Control.instance.api_server.name
112
+ port = NewRelicApi.port || NewRelic::Control.instance.api_server.port
113
+ "#{port == 443 ? 'https' : 'http'}://#{host}:#{port}"
114
+ end
115
+
116
+ def reset!
117
+ self.site = self.site_url
118
+ end
119
+
120
+ protected
121
+
122
+ def fix_fields(*fields)
123
+ fields.to_a.each do |field|
124
+ define_method field do
125
+ yield super
126
+ end
127
+ end
128
+ end
129
+
130
+ def fix_integer_fields(*fields)
131
+ fix_fields(*fields) { |sup| sup.to_i }
132
+ end
133
+
134
+ def fix_float_fields(*fields)
135
+ fix_fields(*fields) { |sup| sup.to_f }
136
+ end
137
+
138
+ end
139
+ self.site = self.site_url
140
+ end
141
+ ACCOUNT_RESOURCE_PATH = '/accounts/:account_id/' #:nodoc:
142
+ ACCOUNT_AGENT_RESOURCE_PATH = ACCOUNT_RESOURCE_PATH + 'agents/:agent_id/' #:nodoc:
143
+ ACCOUNT_APPLICATION_RESOURCE_PATH = ACCOUNT_RESOURCE_PATH + 'applications/:application_id/' #:nodoc:
144
+
145
+ module AccountResource #:nodoc:
146
+ def account_id
147
+ prefix_options[:account_id]
148
+ end
149
+ def account_query_params(extra_params = {})
150
+ {:account_id => account_id}.merge(extra_params)
151
+ end
152
+
153
+ def query_params#:nodoc:
154
+ account_query_params
155
+ end
156
+ end
157
+
158
+ module AgentResource #:nodoc:
159
+ include ActiveResourceAssociations
160
+ end
161
+
162
+ # An application has many:
163
+ # +agents+:: the agent instances associated with this app
164
+ # +threshold_values+:: the health indicators for this application.
165
+ class Application < BaseResource
166
+ include AccountResource
167
+ include AgentResource
168
+
169
+ has_many :agents, :threshold_values
170
+
171
+ self.prefix = ACCOUNT_RESOURCE_PATH
172
+
173
+ def query_params#:nodoc:
174
+ account_query_params(:application_id => id)
175
+ end
176
+
177
+ class Agent < BaseResource
178
+ include AccountResource
179
+ include AgentResource
180
+
181
+ self.prefix = ACCOUNT_APPLICATION_RESOURCE_PATH
182
+
183
+ def query_params#:nodoc:
184
+ super.merge(:application_id => cluster_agent_id)
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+ # A threshold value represents a single health indicator for an application such as CPU, memory or response time.
191
+ #
192
+ # ==Fields
193
+ # +name+:: The name of the threshold setting associated with this threshold value.
194
+ # +threshold_value+:: A value of 0, 1, 2 or 3 representing gray (not reporting), green, yellow and red
195
+ # +metric_value+:: The metric value associated with this threshold
196
+ class ThresholdValue < BaseResource
197
+ self.prefix = ACCOUNT_APPLICATION_RESOURCE_PATH
198
+ # attr_reader :name, :begin_time, :metric_value, :threshold_value
199
+
200
+ fix_integer_fields :threshold_value
201
+ fix_float_fields :metric_value
202
+
203
+ # Returns the color value for this threshold (Gray, Green, Yellow or Red).
204
+ def color_value
205
+ case threshold_value
206
+ when 3: 'Red'
207
+ when 2: 'Yellow'
208
+ when 1: 'Green'
209
+ else 'Gray'
210
+ end
211
+ end
212
+
213
+ def to_s #:nodoc:
214
+ "#{name}: #{color_value} (#{formatted_metric_value})"
215
+ end
216
+ end
217
+
218
+ # An account contains your basic account information.
219
+ #
220
+ # Accounts have many
221
+ # +applications+:: the applications contained within the account
222
+ #
223
+ # Find Accounts
224
+ #
225
+ # NewRelicApi::Account.find(:all) # find all accounts for the current user.
226
+ # NewRelicApi::Account.find(44) # find individual account by ID
227
+ #
228
+ class Account < BaseResource
229
+ has_many :applications
230
+ has_many :account_views
231
+
232
+ def query_params #:nodoc:
233
+ {:account_id => id}
234
+ end
235
+
236
+ # Returns an account including all of its applications and the threshold values for each application.
237
+ def self.application_health(type = :first)
238
+ find(type, :params => {:include => :application_health})
239
+ end
240
+
241
+ # Add a user to an account.
242
+ # +user_params+:: User parameters as a hash consisting of the following:
243
+ # email, first_name, password, password_confirmation
244
+ # If a user record already exists for this email, the name
245
+ # and password fields are ignored.
246
+ # +is_admin+:: Set administrative privileges for this user.
247
+ def add_user(user_params, is_admin = false)
248
+ account_id = self.id
249
+ account_view = NewRelicApi::Account::AccountView.create(:account_id => account_id, :user => user_params, :is_admin => is_admin)
250
+ account_views << account_view if account_view.valid?
251
+ account_view
252
+ end
253
+
254
+ # Change the subscription for an account
255
+ # +product_id+:: ID or name of product (e.g. Lite) (required).
256
+ # +number_of_hosts+:: Number of hosts. This is required for fixed host products.
257
+ # For utility based products, this is set to the maximum
258
+ # number of hosts allowed to connect.
259
+ def change_subscription(sub_params)
260
+ NewRelicApi::Subscription.create(sub_params.merge(:account_id => self.id))
261
+ end
262
+
263
+ # Remove a user's access from an account.
264
+ # +email+:: User's email address.
265
+ def remove_user(email)
266
+ view = NewRelicApi::Account::AccountView.find(:one, :params => {:account_id => self.id, :email => email})
267
+ view.destroy if view
268
+ end
269
+
270
+ # Change the primary admin for an account. The administrator must be a
271
+ # user that is already associated with the account
272
+ # +email+:: Email address of the new administrator
273
+ def change_primary_admin(email)
274
+ put(:update_primary_admin, :email => email)
275
+ end
276
+
277
+ class AccountView < BaseResource
278
+ self.prefix = ACCOUNT_RESOURCE_PATH
279
+
280
+ def query_params(extra_params = {}) #:nodoc:
281
+ {:account_id => account_id}.merge(extra_params)
282
+ end
283
+
284
+ def user
285
+ @attributes['user']
286
+ end
287
+ end
288
+ end
289
+
290
+ # This model is used to mark production deployments in RPM
291
+ # Only create is supported.
292
+ # ==Examples
293
+ # # Creating a new deployment
294
+ # NewRelicApi::Deployment.create
295
+ #
296
+ class Deployment < BaseResource
297
+ end
298
+
299
+ # This model is used to modify subscriptions for existing accounts in RPM.
300
+ # To update a subscription, create a new instance with the following properties:
301
+ # +account_id+:: Account ID in RPM (required).
302
+ # +product_id+:: ID or name of product (e.g. Lite) (required).
303
+ # +number_of_hosts+:: Number of hosts. This is required for and applicable to
304
+ # only host based products.
305
+ class Subscription < BaseResource
306
+ def query_params(extra_params = {}) #:nodoc:
307
+ {:account_id => account_id}.merge(extra_params)
308
+ end
309
+ end
310
+
311
+ class User < BaseResource
312
+ end
313
+
314
+ end
315
+
@@ -0,0 +1,40 @@
1
+ # == New Relic Initialization
2
+ #
3
+ # When installed as a gem, you can activate the New Relic agent one of the following ways:
4
+ #
5
+ # For Rails, add:
6
+ # config.gem 'newrelic_rpm'
7
+ # to your initialization sequence.
8
+ #
9
+ # For merb, do
10
+ # dependency 'newrelic_rpm'
11
+ # in the Merb config/init.rb
12
+ #
13
+ # For other frameworks, or to manage the agent manually, invoke NewRelic::Agent#manual_start
14
+ # directly.
15
+ #
16
+ require 'new_relic/control'
17
+
18
+ def log!(message)
19
+ STDERR.puts "[NewRelic] #{message}"
20
+ end
21
+
22
+ # After verison 2.0 of Rails we can access the configuration directly.
23
+ # We need it to add dev mode routes after initialization finished.
24
+ if defined? Rails.configuration
25
+ Rails.configuration.after_initialize do
26
+ NewRelic::Control.instance.init_plugin :config => Rails.configuration
27
+ end
28
+ elsif defined? Merb
29
+ module NewRelic
30
+ class MerbBootLoader < Merb::BootLoader
31
+ after Merb::BootLoader::ChooseAdapter
32
+
33
+ def self.run
34
+ NewRelic::Control.instance.init_plugin
35
+ end
36
+ end
37
+ end
38
+ else
39
+ NewRelic::Control.instance.init_plugin
40
+ end
@@ -0,0 +1,4 @@
1
+ # This is required to load in task definitions from merb
2
+ Dir.glob(File.join(File.dirname(__FILE__),'*.rake')) do |file|
3
+ load file
4
+ end
@@ -0,0 +1,7 @@
1
+ # run unit tests for the NewRelic Agent
2
+ namespace :newrelic do
3
+ desc "install a default config/newrelic.yml file"
4
+ task :install do
5
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # run unit tests for the NewRelic Agent
2
+ if defined? Rake::TestTask
3
+ namespace :test do
4
+ AGENT_HOME = File.expand_path(File.join(File.dirname(__FILE__), "..",".."))
5
+ Rake::TestTask.new(:newrelic) do |t|
6
+ t.libs << "#{AGENT_HOME}/test"
7
+ t.libs << "#{AGENT_HOME}/lib"
8
+ t.pattern = "#{AGENT_HOME}/test/**/*_test.rb"
9
+ t.verbose = true
10
+ end
11
+ Rake::Task['test:newrelic'].comment = "Run the unit tests for the Agent"
12
+ end
13
+ end
@@ -0,0 +1,214 @@
1
+ #
2
+ # This file configures the NewRelic RPM Agent, NewRelic RPM monitors
3
+ # Rails applications with deep visibility and low overhead. For more
4
+ # information, visit www.newrelic.com.
5
+ #
6
+ # <%= generated_for_user %>
7
+ #
8
+ # here are the settings that are common to all environments
9
+ common: &default_settings
10
+ # ============================== LICENSE KEY ===============================
11
+
12
+ # You must specify the licence key associated with your New Relic
13
+ # account. This key binds your Agent's data to your account in the
14
+ # New Relic RPM service.
15
+ license_key: '<%= license_key %>'
16
+
17
+ # Agent Enabled (Rails Only)
18
+ # Use this setting to force the agent to run or not run.
19
+ # Default is 'auto' which means the agent will install and run only
20
+ # if a valid dispatcher such as Mongrel is running. This prevents
21
+ # it from running with Rake or the console. Set to false to
22
+ # completely turn the agent off regardless of the other settings.
23
+ # Valid values are true, false and auto.
24
+ # agent_enabled: auto
25
+
26
+ # Application Name
27
+ # Set this to be the name of your application as you'd like it show
28
+ # up in RPM. RPM will then auto-map instances of your application
29
+ # into a RPM "application" on your home dashboard page. If you want
30
+ # to map this instance into multiple apps, like "AJAX Requests" and
31
+ # "All UI" then specify a semicolon separated list of up to three
32
+ # distinct names. This setting does not prevent you from manually
33
+ # defining applications.
34
+ app_name: My Application
35
+
36
+ # When "true", the agent collects performance data about your
37
+ # application and reports this data to the NewRelic RPM service at
38
+ # newrelic.com. This global switch is normally overridden for each
39
+ # environment below.
40
+ enabled: true
41
+
42
+ # The newrelic agent generates its own log file to keep its logging
43
+ # information separate from that of your application. Specify its
44
+ # log level here.
45
+ log_level: info
46
+
47
+ # The newrelic agent communicates with the RPM service via http by
48
+ # default. If you want to communicate via https to increase
49
+ # security, then turn on SSL by setting this value to true. Note,
50
+ # this will result in increased CPU overhead to perform the
51
+ # encryption involved in SSL communication, but this work is done
52
+ # asynchronously to the threads that process your application code,
53
+ # so it should not impact response times.
54
+ ssl: false
55
+
56
+ # EXPERIMENTAL: enable verification of the SSL certificate sent by
57
+ # the server. This setting has no effect unless SSL is enabled
58
+ # above. This may block your application. Only enable it if the data
59
+ # you send us needs end-to-end verified certificates.
60
+ #
61
+ # This means we cannot cache the DNS lookup, so each request to the
62
+ # RPM service will perform a lookup. It also means that we cannot
63
+ # use a non-blocking lookup, so in a worst case, if you have DNS
64
+ # problems, your app may block indefinitely.
65
+ # verify_certificate: true
66
+
67
+ # Set your application's Apdex threshold value with the 'apdex_t'
68
+ # setting, in seconds. The apdex_t value determines the buckets used
69
+ # to compute your overall Apdex score.
70
+ # Requests that take less than apdex_t seconds to process will be
71
+ # classified as Satisfying transactions; more than apdex_t seconds
72
+ # as Tolerating transactions; and more than four times the apdex_t
73
+ # value as Frustrating transactions.
74
+ # For more about the Apdex standard, see
75
+ # http://support.newrelic.com/faqs/general/apdex
76
+
77
+ apdex_t: 0.5
78
+
79
+ # Proxy settings for connecting to the RPM server.
80
+ #
81
+ # If a proxy is used, the host setting is required. Other settings
82
+ # are optional. Default port is 8080.
83
+ #
84
+ # proxy_host: hostname
85
+ # proxy_port: 8080
86
+ # proxy_user:
87
+ # proxy_pass:
88
+
89
+
90
+ # Tells transaction tracer and error collector (when enabled)
91
+ # whether or not to capture HTTP params. When true, frameworks can
92
+ # exclude HTTP parameters from being captured.
93
+ # Rails: the RoR filter_parameter_logging excludes parameters
94
+ # Java: create a config setting called "ignored_params" and set it to
95
+ # a comma separated list of HTTP parameter names.
96
+ # ex: ignored_params: credit_card, ssn, password
97
+ capture_params: false
98
+
99
+
100
+ # Transaction tracer captures deep information about slow
101
+ # transactions and sends this to the RPM service once a
102
+ # minute. Included in the transaction is the exact call sequence of
103
+ # the transactions including any SQL statements issued.
104
+ transaction_tracer:
105
+
106
+ # Transaction tracer is enabled by default. Set this to false to
107
+ # turn it off. This feature is only available at the Silver and
108
+ # above product levels.
109
+ enabled: true
110
+
111
+ # Threshold in seconds for when to collect a transaction
112
+ # trace. When the response time of a controller action exceeds
113
+ # this threshold, a transaction trace will be recorded and sent to
114
+ # RPM. Valid values are any float value, or (default) "apdex_f",
115
+ # which will use the threshold for an dissatisfying Apdex
116
+ # controller action - four times the Apdex T value.
117
+ transaction_threshold: apdex_f
118
+
119
+ # When transaction tracer is on, SQL statements can optionally be
120
+ # recorded. The recorder has three modes, "off" which sends no
121
+ # SQL, "raw" which sends the SQL statement in its original form,
122
+ # and "obfuscated", which strips out numeric and string literals
123
+ record_sql: obfuscated
124
+
125
+ # Threshold in seconds for when to collect stack trace for a SQL
126
+ # call. In other words, when SQL statements exceed this threshold,
127
+ # then capture and send to RPM the current stack trace. This is
128
+ # helpful for pinpointing where long SQL calls originate from
129
+ stack_trace_threshold: 0.500
130
+
131
+ # Determines whether the agent will capture query plans for slow
132
+ # SQL queries. Only supported in mysql and postgres. Should be
133
+ # set to false when using other adapters.
134
+ # explain_enabled: true
135
+
136
+ # Threshold for query execution time below which query plans will not
137
+ # not be captured. Relevant only when `explain_enabled` is true.
138
+ # explain_threshold: 0.5
139
+
140
+ # Error collector captures information about uncaught exceptions and
141
+ # sends them to RPM for viewing
142
+ error_collector:
143
+
144
+ # Error collector is enabled by default. Set this to false to turn
145
+ # it off. This feature is only available at the Silver and above
146
+ # product levels
147
+ enabled: true
148
+
149
+ # Rails Only - tells error collector whether or not to capture a
150
+ # source snippet around the place of the error when errors are View
151
+ # related.
152
+ capture_source: true
153
+
154
+ # To stop specific errors from reporting to RPM, set this property
155
+ # to comma separated values
156
+ #
157
+ #ignore_errors: ActionController::RoutingError, ...
158
+
159
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers
160
+ # won't run. Useful when you are using the agent to monitor an
161
+ # external resource
162
+ # disable_samplers: true
163
+
164
+ # disable_view_instrumentation: true
165
+ # disable_ar_instrumentation: true
166
+ # disable_scope_tracking: true
167
+
168
+ # Application Environments
169
+ # ------------------------------------------
170
+ # Environment specific settings are in this section.
171
+ # For Rails applications, RAILS_ENV is used to determine the environment
172
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
173
+ # the environment
174
+
175
+ # NOTE if your application has other named environments, you should
176
+ # provide newrelic conifguration settings for these enviromnents here.
177
+
178
+ development:
179
+ <<: *default_settings
180
+ # Turn off communication to RPM service in development mode.
181
+ # NOTE: for initial evaluation purposes, you may want to temporarily
182
+ # turn the agent on in development mode.
183
+ enabled: false
184
+
185
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
186
+ # present performance information on the last 100 transactions you have
187
+ # executed since starting the mongrel. to view this data, go to
188
+ # http://localhost:3000/newrelic
189
+ developer: true
190
+
191
+ # Enable textmate links
192
+ # textmate: true
193
+
194
+ test:
195
+ <<: *default_settings
196
+ # It almost never makes sense to turn on the agent when running
197
+ # unit, functional or integration tests or the like.
198
+ enabled: false
199
+
200
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
201
+ # testing shows an average performance impact of < 5 ms per
202
+ # transaction, you you can leave this on all the time without
203
+ # incurring any user-visible performance degredation.
204
+ production:
205
+ <<: *default_settings
206
+ enabled: true
207
+
208
+ # Many applications have a staging environment which behaves
209
+ # identically to production. Support for that environment is provided
210
+ # here. By default, the staging environment has the agent turned on.
211
+ staging:
212
+ <<: *default_settings
213
+ enabled: true
214
+ app_name: My Application (Staging)