factorylabs-newrelic_rpm 2.10.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/CHANGELOG +354 -0
  2. data/LICENSE +37 -0
  3. data/README-2.10.2.2 +10 -0
  4. data/README.md +138 -0
  5. data/bin/mongrel_rpm +33 -0
  6. data/bin/newrelic_cmd +4 -0
  7. data/cert/cacert.pem +34 -0
  8. data/install.rb +45 -0
  9. data/lib/new_relic/agent.rb +315 -0
  10. data/lib/new_relic/agent/agent.rb +647 -0
  11. data/lib/new_relic/agent/busy_calculator.rb +86 -0
  12. data/lib/new_relic/agent/chained_call.rb +13 -0
  13. data/lib/new_relic/agent/collection_helper.rb +66 -0
  14. data/lib/new_relic/agent/error_collector.rb +117 -0
  15. data/lib/new_relic/agent/instrumentation/active_merchant.rb +18 -0
  16. data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +91 -0
  17. data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -0
  18. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +389 -0
  19. data/lib/new_relic/agent/instrumentation/data_mapper.rb +90 -0
  20. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +12 -0
  21. data/lib/new_relic/agent/instrumentation/memcache.rb +24 -0
  22. data/lib/new_relic/agent/instrumentation/merb/controller.rb +26 -0
  23. data/lib/new_relic/agent/instrumentation/merb/errors.rb +8 -0
  24. data/lib/new_relic/agent/instrumentation/metric_frame.rb +199 -0
  25. data/lib/new_relic/agent/instrumentation/net.rb +21 -0
  26. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +20 -0
  27. data/lib/new_relic/agent/instrumentation/rack.rb +109 -0
  28. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +59 -0
  29. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +27 -0
  30. data/lib/new_relic/agent/instrumentation/rails/errors.rb +24 -0
  31. data/lib/new_relic/agent/instrumentation/sinatra.rb +39 -0
  32. data/lib/new_relic/agent/method_tracer.rb +348 -0
  33. data/lib/new_relic/agent/patch_const_missing.rb +125 -0
  34. data/lib/new_relic/agent/sampler.rb +46 -0
  35. data/lib/new_relic/agent/samplers/cpu_sampler.rb +50 -0
  36. data/lib/new_relic/agent/samplers/memory_sampler.rb +141 -0
  37. data/lib/new_relic/agent/samplers/mongrel_sampler.rb +23 -0
  38. data/lib/new_relic/agent/samplers/object_sampler.rb +24 -0
  39. data/lib/new_relic/agent/shim_agent.rb +21 -0
  40. data/lib/new_relic/agent/stats_engine.rb +22 -0
  41. data/lib/new_relic/agent/stats_engine/metric_stats.rb +116 -0
  42. data/lib/new_relic/agent/stats_engine/samplers.rb +74 -0
  43. data/lib/new_relic/agent/stats_engine/transactions.rb +154 -0
  44. data/lib/new_relic/agent/transaction_sampler.rb +315 -0
  45. data/lib/new_relic/agent/worker_loop.rb +118 -0
  46. data/lib/new_relic/commands/deployments.rb +145 -0
  47. data/lib/new_relic/commands/new_relic_commands.rb +30 -0
  48. data/lib/new_relic/control.rb +484 -0
  49. data/lib/new_relic/control/external.rb +13 -0
  50. data/lib/new_relic/control/merb.rb +24 -0
  51. data/lib/new_relic/control/rails.rb +151 -0
  52. data/lib/new_relic/control/ruby.rb +36 -0
  53. data/lib/new_relic/control/sinatra.rb +14 -0
  54. data/lib/new_relic/histogram.rb +89 -0
  55. data/lib/new_relic/local_environment.rb +299 -0
  56. data/lib/new_relic/merbtasks.rb +6 -0
  57. data/lib/new_relic/metric_data.rb +42 -0
  58. data/lib/new_relic/metric_parser.rb +124 -0
  59. data/lib/new_relic/metric_parser/action_mailer.rb +9 -0
  60. data/lib/new_relic/metric_parser/active_merchant.rb +26 -0
  61. data/lib/new_relic/metric_parser/active_record.rb +25 -0
  62. data/lib/new_relic/metric_parser/controller.rb +54 -0
  63. data/lib/new_relic/metric_parser/controller_cpu.rb +38 -0
  64. data/lib/new_relic/metric_parser/errors.rb +6 -0
  65. data/lib/new_relic/metric_parser/external.rb +50 -0
  66. data/lib/new_relic/metric_parser/mem_cache.rb +12 -0
  67. data/lib/new_relic/metric_parser/other_transaction.rb +15 -0
  68. data/lib/new_relic/metric_parser/view.rb +61 -0
  69. data/lib/new_relic/metric_parser/web_frontend.rb +14 -0
  70. data/lib/new_relic/metric_parser/web_service.rb +9 -0
  71. data/lib/new_relic/metric_spec.rb +67 -0
  72. data/lib/new_relic/metrics.rb +7 -0
  73. data/lib/new_relic/noticed_error.rb +23 -0
  74. data/lib/new_relic/rack/metric_app.rb +56 -0
  75. data/lib/new_relic/rack/mongrel_rpm.ru +25 -0
  76. data/lib/new_relic/rack/newrelic.yml +26 -0
  77. data/lib/new_relic/rack_app.rb +5 -0
  78. data/lib/new_relic/recipes.rb +82 -0
  79. data/lib/new_relic/stats.rb +362 -0
  80. data/lib/new_relic/transaction_analysis.rb +121 -0
  81. data/lib/new_relic/transaction_sample.rb +671 -0
  82. data/lib/new_relic/version.rb +54 -0
  83. data/lib/new_relic_api.rb +276 -0
  84. data/lib/newrelic_rpm.rb +45 -0
  85. data/lib/tasks/all.rb +4 -0
  86. data/lib/tasks/install.rake +7 -0
  87. data/lib/tasks/tests.rake +15 -0
  88. data/newrelic.yml +227 -0
  89. data/newrelic_rpm.gemspec +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 +38 -0
  94. data/test/new_relic/agent/active_record_instrumentation_test.rb +268 -0
  95. data/test/new_relic/agent/agent_controller_test.rb +254 -0
  96. data/test/new_relic/agent/agent_test_controller.rb +78 -0
  97. data/test/new_relic/agent/busy_calculator_test.rb +79 -0
  98. data/test/new_relic/agent/classloader_patch_test.rb +56 -0
  99. data/test/new_relic/agent/collection_helper_test.rb +125 -0
  100. data/test/new_relic/agent/error_collector_test.rb +173 -0
  101. data/test/new_relic/agent/method_tracer_test.rb +340 -0
  102. data/test/new_relic/agent/metric_data_test.rb +56 -0
  103. data/test/new_relic/agent/mock_ar_connection.rb +40 -0
  104. data/test/new_relic/agent/mock_scope_listener.rb +23 -0
  105. data/test/new_relic/agent/net_instrumentation_test.rb +63 -0
  106. data/test/new_relic/agent/rpm_agent_test.rb +125 -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 +88 -0
  109. data/test/new_relic/agent/stats_engine/stats_engine_test.rb +184 -0
  110. data/test/new_relic/agent/task_instrumentation_test.rb +177 -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 +186 -0
  114. data/test/new_relic/agent/transaction_sampler_test.rb +404 -0
  115. data/test/new_relic/agent/worker_loop_test.rb +103 -0
  116. data/test/new_relic/control_test.rb +110 -0
  117. data/test/new_relic/delayed_job_test.rb +108 -0
  118. data/test/new_relic/deployments_api_test.rb +68 -0
  119. data/test/new_relic/environment_test.rb +75 -0
  120. data/test/new_relic/metric_parser_test.rb +172 -0
  121. data/test/new_relic/metric_spec_test.rb +177 -0
  122. data/test/new_relic/shim_agent_test.rb +9 -0
  123. data/test/new_relic/stats_test.rb +291 -0
  124. data/test/new_relic/version_number_test.rb +76 -0
  125. data/test/test_helper.rb +53 -0
  126. data/test/ui/newrelic_controller_test.rb +14 -0
  127. data/test/ui/newrelic_helper_test.rb +53 -0
  128. data/ui/controllers/newrelic_controller.rb +220 -0
  129. data/ui/helpers/google_pie_chart.rb +49 -0
  130. data/ui/helpers/newrelic_helper.rb +320 -0
  131. data/ui/views/layouts/newrelic_default.rhtml +47 -0
  132. data/ui/views/newrelic/_explain_plans.rhtml +27 -0
  133. data/ui/views/newrelic/_sample.rhtml +19 -0
  134. data/ui/views/newrelic/_segment.rhtml +28 -0
  135. data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
  136. data/ui/views/newrelic/_segment_row.rhtml +14 -0
  137. data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
  138. data/ui/views/newrelic/_show_sample_sql.rhtml +20 -0
  139. data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
  140. data/ui/views/newrelic/_sql_row.rhtml +11 -0
  141. data/ui/views/newrelic/_stack_trace.rhtml +30 -0
  142. data/ui/views/newrelic/_table.rhtml +12 -0
  143. data/ui/views/newrelic/explain_sql.rhtml +42 -0
  144. data/ui/views/newrelic/images/arrow-close.png +0 -0
  145. data/ui/views/newrelic/images/arrow-open.png +0 -0
  146. data/ui/views/newrelic/images/blue_bar.gif +0 -0
  147. data/ui/views/newrelic/images/file_icon.png +0 -0
  148. data/ui/views/newrelic/images/gray_bar.gif +0 -0
  149. data/ui/views/newrelic/images/new-relic-rpm-desktop.gif +0 -0
  150. data/ui/views/newrelic/images/new_relic_rpm_desktop.gif +0 -0
  151. data/ui/views/newrelic/images/textmate.png +0 -0
  152. data/ui/views/newrelic/index.rhtml +57 -0
  153. data/ui/views/newrelic/javascript/prototype-scriptaculous.js +7288 -0
  154. data/ui/views/newrelic/javascript/transaction_sample.js +107 -0
  155. data/ui/views/newrelic/sample_not_found.rhtml +2 -0
  156. data/ui/views/newrelic/show_sample.rhtml +80 -0
  157. data/ui/views/newrelic/show_source.rhtml +3 -0
  158. data/ui/views/newrelic/stylesheets/style.css +484 -0
  159. data/ui/views/newrelic/threads.rhtml +52 -0
  160. metadata +238 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby
2
+ module NewRelic
3
+ module VERSION #:nodoc:
4
+ MAJOR = 2
5
+ MINOR = 10
6
+ TINY = 2
7
+ EXPERIMENTAL = 2
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,276 @@
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
+ class AccountView < BaseResource
242
+ self.prefix = ACCOUNT_RESOURCE_PATH
243
+
244
+ def query_params(extra_params = {}) #:nodoc:
245
+ {:account_id => account_id}.merge(extra_params)
246
+ end
247
+
248
+ def user
249
+ @attributes['user']
250
+ end
251
+ end
252
+
253
+ class AccountUsage < BaseResource
254
+ end
255
+ end
256
+
257
+ # This model is used to mark production deployments in RPM
258
+ # Only create is supported.
259
+ # ==Examples
260
+ # # Creating a new deployment
261
+ # NewRelicApi::Deployment.create
262
+ #
263
+ class Deployment < BaseResource
264
+ end
265
+
266
+ class Subscription < BaseResource
267
+ def query_params(extra_params = {}) #:nodoc:
268
+ {:account_id => account_id}.merge(extra_params)
269
+ end
270
+ end
271
+
272
+ class User < BaseResource
273
+ end
274
+
275
+ end
276
+
@@ -0,0 +1,45 @@
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
+ begin
18
+ require 'rpm_contrib'
19
+ rescue LoadError
20
+ # Contrib gem not being used.
21
+ end
22
+
23
+ def log!(message)
24
+ STDERR.puts "[NewRelic] #{message}"
25
+ end
26
+
27
+ # After verison 2.0 of Rails we can access the configuration directly.
28
+ # We need it to add dev mode routes after initialization finished.
29
+ if defined? Rails.configuration
30
+ Rails.configuration.after_initialize do
31
+ NewRelic::Control.instance.init_plugin :config => Rails.configuration
32
+ end
33
+ elsif defined? Merb
34
+ module NewRelic
35
+ class MerbBootLoader < Merb::BootLoader
36
+ after Merb::BootLoader::ChooseAdapter
37
+
38
+ def self.run
39
+ NewRelic::Control.instance.init_plugin
40
+ end
41
+ end
42
+ end
43
+ else
44
+ NewRelic::Control.instance.init_plugin
45
+ 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,15 @@
1
+ # run unit tests for the NewRelic Agent
2
+
3
+ if defined? Rake::TestTask
4
+ namespace :test do
5
+ AGENT_HOME = File.expand_path(File.join(File.dirname(__FILE__), "..",".."))
6
+ Rake::TestTask.new(:newrelic) do |t|
7
+ t.libs << "#{AGENT_HOME}/test"
8
+ t.libs << "#{AGENT_HOME}/lib"
9
+ t.pattern = "#{AGENT_HOME}/test/**/*_test.rb"
10
+ t.verbose = true
11
+ end
12
+ Rake::Task['test:newrelic'].comment = "Run the unit tests for the Agent"
13
+ task :default => :newrelic
14
+ end
15
+ end
@@ -0,0 +1,227 @@
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. If you comment this out, it defaults to the
33
+ # capitalized RAILS_ENV (i.e., Production, Staging, etc)
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. (formerly called 'enabled')
40
+ monitor_mode: true
41
+
42
+ # Developer mode should be off in every environment but
43
+ # development as it has very high overhead in memory.
44
+ developer_mode: false
45
+
46
+ # The newrelic agent generates its own log file to keep its logging
47
+ # information separate from that of your application. Specify its
48
+ # log level here.
49
+ log_level: info
50
+
51
+ # The newrelic agent communicates with the RPM service via http by
52
+ # default. If you want to communicate via https to increase
53
+ # security, then turn on SSL by setting this value to true. Note,
54
+ # this will result in increased CPU overhead to perform the
55
+ # encryption involved in SSL communication, but this work is done
56
+ # asynchronously to the threads that process your application code,
57
+ # so it should not impact response times.
58
+ ssl: false
59
+
60
+ # EXPERIMENTAL: enable verification of the SSL certificate sent by
61
+ # the server. This setting has no effect unless SSL is enabled
62
+ # above. This may block your application. Only enable it if the data
63
+ # you send us needs end-to-end verified certificates.
64
+ #
65
+ # This means we cannot cache the DNS lookup, so each request to the
66
+ # RPM service will perform a lookup. It also means that we cannot
67
+ # use a non-blocking lookup, so in a worst case, if you have DNS
68
+ # problems, your app may block indefinitely.
69
+ # verify_certificate: true
70
+
71
+ # Set your application's Apdex threshold value with the 'apdex_t'
72
+ # setting, in seconds. The apdex_t value determines the buckets used
73
+ # to compute your overall Apdex score.
74
+ # Requests that take less than apdex_t seconds to process will be
75
+ # classified as Satisfying transactions; more than apdex_t seconds
76
+ # as Tolerating transactions; and more than four times the apdex_t
77
+ # value as Frustrating transactions.
78
+ # For more about the Apdex standard, see
79
+ # http://support.newrelic.com/faqs/general/apdex
80
+
81
+ apdex_t: 0.5
82
+
83
+ # Proxy settings for connecting to the RPM server.
84
+ #
85
+ # If a proxy is used, the host setting is required. Other settings
86
+ # are optional. Default port is 8080.
87
+ #
88
+ # proxy_host: hostname
89
+ # proxy_port: 8080
90
+ # proxy_user:
91
+ # proxy_pass:
92
+
93
+
94
+ # Tells transaction tracer and error collector (when enabled)
95
+ # whether or not to capture HTTP params. When true, frameworks can
96
+ # exclude HTTP parameters from being captured.
97
+ # Rails: the RoR filter_parameter_logging excludes parameters
98
+ # Java: create a config setting called "ignored_params" and set it to
99
+ # a comma separated list of HTTP parameter names.
100
+ # ex: ignored_params: credit_card, ssn, password
101
+ capture_params: false
102
+
103
+
104
+ # Transaction tracer captures deep information about slow
105
+ # transactions and sends this to the RPM service once a
106
+ # minute. Included in the transaction is the exact call sequence of
107
+ # the transactions including any SQL statements issued.
108
+ transaction_tracer:
109
+
110
+ # Transaction tracer is enabled by default. Set this to false to
111
+ # turn it off. This feature is only available at the Silver and
112
+ # above product levels.
113
+ enabled: true
114
+
115
+ # Threshold in seconds for when to collect a transaction
116
+ # trace. When the response time of a controller action exceeds
117
+ # this threshold, a transaction trace will be recorded and sent to
118
+ # RPM. Valid values are any float value, or (default) "apdex_f",
119
+ # which will use the threshold for an dissatisfying Apdex
120
+ # controller action - four times the Apdex T value.
121
+ transaction_threshold: apdex_f
122
+
123
+ # When transaction tracer is on, SQL statements can optionally be
124
+ # recorded. The recorder has three modes, "off" which sends no
125
+ # SQL, "raw" which sends the SQL statement in its original form,
126
+ # and "obfuscated", which strips out numeric and string literals
127
+ record_sql: obfuscated
128
+
129
+ # Threshold in seconds for when to collect stack trace for a SQL
130
+ # call. In other words, when SQL statements exceed this threshold,
131
+ # then capture and send to RPM the current stack trace. This is
132
+ # helpful for pinpointing where long SQL calls originate from
133
+ stack_trace_threshold: 0.500
134
+
135
+ # Determines whether the agent will capture query plans for slow
136
+ # SQL queries. Only supported in mysql and postgres. Should be
137
+ # set to false when using other adapters.
138
+ # explain_enabled: true
139
+
140
+ # Threshold for query execution time below which query plans will not
141
+ # not be captured. Relevant only when `explain_enabled` is true.
142
+ # explain_threshold: 0.5
143
+
144
+ # Error collector captures information about uncaught exceptions and
145
+ # sends them to RPM for viewing
146
+ error_collector:
147
+
148
+ # Error collector is enabled by default. Set this to false to turn
149
+ # it off. This feature is only available at the Silver and above
150
+ # product levels
151
+ enabled: true
152
+
153
+ # Rails Only - tells error collector whether or not to capture a
154
+ # source snippet around the place of the error when errors are View
155
+ # related.
156
+ capture_source: true
157
+
158
+ # To stop specific errors from reporting to RPM, set this property
159
+ # to comma separated values
160
+ #
161
+ #ignore_errors: ActionController::RoutingError, ...
162
+
163
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers
164
+ # won't run. Useful when you are using the agent to monitor an
165
+ # external resource
166
+ # disable_samplers: true
167
+
168
+ # If you aren't interested in visibility in these areas, you can disable
169
+ # the instrumentation to reduce overhead.
170
+ #
171
+ # disable_view_instrumentation: true
172
+ # disable_activerecord_instrumentation: true
173
+ # disable_memcache_instrumentation: true
174
+
175
+ # Certain types of instrumentation such as GC stats will not work if
176
+ # you are running multi-threaded. Please let us know.
177
+ # multi_threaded = false
178
+
179
+ # Application Environments
180
+ # ------------------------------------------
181
+ # Environment specific settings are in this section.
182
+ # For Rails applications, RAILS_ENV is used to determine the environment
183
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
184
+ # the environment
185
+
186
+ # NOTE if your application has other named environments, you should
187
+ # provide newrelic conifguration settings for these enviromnents here.
188
+
189
+ development:
190
+ <<: *default_settings
191
+ # Turn off communication to RPM service in development mode (also
192
+ # 'enabled').
193
+ # NOTE: for initial evaluation purposes, you may want to temporarily
194
+ # turn the agent on in development mode.
195
+ monitor_mode: false
196
+
197
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
198
+ # present performance information on the last 100 transactions you have
199
+ # executed since starting the mongrel.
200
+ # NOTE: There is substantial overhead when running in developer mode.
201
+ # Do not use for production or load testing.
202
+ developer_mode: true
203
+
204
+ # Enable textmate links
205
+ # textmate: true
206
+
207
+ test:
208
+ <<: *default_settings
209
+ # It almost never makes sense to turn on the agent when running
210
+ # unit, functional or integration tests or the like.
211
+ monitor_mode: false
212
+
213
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
214
+ # testing shows an average performance impact of < 5 ms per
215
+ # transaction, you you can leave this on all the time without
216
+ # incurring any user-visible performance degredation.
217
+ production:
218
+ <<: *default_settings
219
+ monitor_mode: true
220
+
221
+ # Many applications have a staging environment which behaves
222
+ # identically to production. Support for that environment is provided
223
+ # here. By default, the staging environment has the agent turned on.
224
+ staging:
225
+ <<: *default_settings
226
+ monitor_mode: true
227
+ app_name: My Application (Staging)