newrelic_rpm 3.5.0.1 → 3.5.1.alpha

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 CHANGED
@@ -4,31 +4,32 @@
4
4
  ### Next Up ###
5
5
  ## v3.5.1 ##
6
6
 
7
- ### current version ###
8
- ## v3.5.0.1 ##
7
+ * Enabling Memory Profiling on Lion and Moutain Lion
8
+
9
+ The agent's list of supported platforms for memory profiling wasn't correctly checking
10
+ for more recent versions of OS X.
9
11
 
10
- * (Fix) Due to a serious resource leak we have ended support for versions of Phusion Passenger
11
- older than 2.1.1. Users of older versions are encouraged upgrade to a more recent version.
12
12
 
13
+ ### current version ###
13
14
  ## v3.5.0 ##
14
15
 
15
16
  * (Fix) RUM Stops Working After 3.4.2.1 Agent Upgrade
16
17
 
17
- v3.4.2.1 introduced a bug that caused the browser monitor auto instrumentation
18
+ v3.4.2.1 introduced a bug that caused the browser monitor auto instrument
18
19
  (for RUM) default to be false. The correct value of true is now used
19
20
 
20
- * When the Ruby Agent detects Unicorn as the dispatcher it creates an INFO level log message
21
- with additional information
21
+ * When the Ruby Agent detects Unicorn is the dispatcher create an INFO level log message
22
22
 
23
23
  To help customers using Unicorn, if the agent detects it (Unicorn) is being used as the
24
24
  dispatcher an INFO level log message it created that includes a link to New Relic
25
25
  online doc that has additional steps that may be required to get performance data reporting.
26
26
 
27
- * (Fix) In version 3.4.2 of the Ruby Agent the server side value for Apdex T was disgregarded
27
+ * (Fix) In version 3.4.2 of the Ruby Agent the server side config value for Apdex T was
28
+ disgregarded
28
29
 
29
- With version 3.4.2 of the agent, the value set in the newrelic.yml file took precedence over the
30
- value set in the New Relic UI. As of version 3.5.0 only the value for Apdex T set in the
31
- New Relic UI will be used. Any setting in the yaml file will be ignored.
30
+ When server side config was being used with version 3.4.2 of the agent it ignored the Apdex T
31
+ value that was in the New Relic UI. The server side value for Apdex T now always takes
32
+ precedence.
32
33
 
33
34
  * Improved Error Detection/Reporting capabilities for Rails 3 apps
34
35
 
@@ -39,26 +40,18 @@
39
40
 
40
41
  * The Ruby Agent now logs certain information it receives from the New Relic servers
41
42
 
42
- After connecting to the New Relic servers the agent logs the New Relic URL
43
- of the app it is reporting to.
43
+ When the agent connects to the New Relic servers it receives various bits of information
44
+ back. Different amounts of this information will appear in the agent log, depending on
45
+ the current log level setting.
44
46
 
45
47
  * GC profiling overhead for Ruby 1.9 reduced
46
48
 
47
- For Ruby 1.9 the amount of time spent in GC profiling has been reduced.
48
-
49
- * Know issue with Ruby 1.8.7-p334, sqlite3-ruby 1.3.0 or older, and resque 1.23.0
50
-
51
- The Ruby Agent will not work in conjunction with Ruby 1.8.7-p334, sqlite3-ruby 1.3.3
52
- or earlier, and resque 1.23.0. Your app will likely stop functioning. This is a known problem
53
- with Ruby versions up to 1.8.7-p334. Upgrading to the last release of Ruby 1.8.7
54
- is recommended. This issue has been present in every version of the agent we've tested
55
- going back for a year.
56
-
49
+ For Ruby 1.9 the amount of time spent in GC profiling has been reduce.
57
50
 
58
51
  ### previous versions ###
59
52
  ## v3.4.2.1 ##
60
53
 
61
- * Fix issue when app_name is nil
54
+ * Fix issue when app_name is nil
62
55
 
63
56
  If the app_name setting ends up being nil an exception got generated and the application
64
57
  wouldn't run. This would notably occur when running a Heroku app locally without the
@@ -82,6 +75,7 @@
82
75
  The code that reads the configuration information and confirgures the agent
83
76
  got substantially reorganized, consolidated, simplified, and made more robust.
84
77
 
78
+
85
79
  ## v3.4.1 ##
86
80
  #### Bug Fixes ####
87
81
  * Fix edge case in RUM auto instrumentation where X-UA-Compatible meta tag is
@@ -406,7 +400,7 @@ v2.10.1.
406
400
  * add 'multi_threaded' config option to indicate when the app is running
407
401
  multi-threaded, so we can disable some instrumentation
408
402
  * fix test failures in JRuby, REE
409
- * improve Net::HTTP instrumentation so its more efficient and distinguishes calls
403
+ * improve Net::HTTP instrumentation so it's more efficient and distinguishes calls
410
404
  between web and non-web transactions.
411
405
  * database instrumentation notices all database commands in addition to the core commands
412
406
  * add support for textmate to dev mode
data/config.dot ADDED
@@ -0,0 +1,290 @@
1
+ digraph AgentEnabled {
2
+ node[color=green]
3
+ "[agent_enabled]"
4
+ "[developer_mode]"
5
+ "[monitor_mode]"
6
+ "[slow_sql.explain_threshold]"
7
+ "[slow_sql.stack_trace_threshold]"
8
+ "[slow_sql.explain_enabled]"
9
+ "[slow_sql.enabled]"
10
+ "[slow_sql.record_sql]"
11
+ "[transaction_tracer.limit_segments]"
12
+ "[transaction_tracer.stack_trace_threshold]"
13
+ "[transaction_tracer.explain_threshold]"
14
+ "[transaction_tracer.explain_enabled]"
15
+ "[transaction_tracer.transaction_threshold]"
16
+ "[transaction_tracer.record_sql]"
17
+ "[transaction_tracer.random_sample]"
18
+ "[transaction_tracer.enabled]"
19
+ "[error_collector.capture_source]"
20
+ "[error_collector.enabled]"
21
+ "[error_collector.ignore_errors]"
22
+ "[browser_monitoring.auto_instrument]"
23
+ "[license_key]"
24
+ "[ssl]"
25
+ "[verify_certificate]"
26
+ "[api_host]"
27
+ "[api_port]"
28
+ "[proxy_host]"
29
+ "[proxy_port]"
30
+ "[proxy_user]"
31
+ "[proxy_pass]"
32
+ "[host]"
33
+ "[port]"
34
+ "[timeout]"
35
+ "[log_level]"
36
+ "[apdex_t]"
37
+ "[capture_params]"
38
+ "[app_name]"
39
+ "[multi_homed]"
40
+ "[disable_samplers]"
41
+ "[log_file_name]"
42
+ "[log_file_path]"
43
+ "[dispatcher]"
44
+ "[force_send]"
45
+ "[disable_mobile_headers]"
46
+ "[textmate]"
47
+ "[post_size_limit]"
48
+ "[sync_startup]"
49
+ "[send_data_on_exit]"
50
+ "[high_security]"
51
+ "[validate_seed]"
52
+ "[validate_token]"
53
+ "[disable_backtrace_cleanup]"
54
+ "[disable_activerecord_instrumentation]"
55
+ "[disable_dj]"
56
+ "[capture_memcache_keys]"
57
+ "[disable_memcache_instrumentation]"
58
+ "[disable_view_instrumentation]"
59
+ "[disable_resque]"
60
+
61
+ node[shape=box,color=orange]
62
+ "Control#init_plugin"
63
+ "Control#api_server"
64
+ "Control#proxy_server"
65
+ "Control#server_from_host"
66
+ "Control#http_connection"
67
+ "Control#set_log_level!"
68
+ "Control#log_path"
69
+ "Control#log_to_stdout?"
70
+ "Control#convert_to_ip_address"
71
+ "Control#server"
72
+ "Control#setup_log"
73
+ "Control#should_log?"
74
+ "Control#log!"
75
+
76
+ node[color=green]
77
+ "Config#app_names"
78
+
79
+ node[color=black]
80
+ "Agent#initialize"
81
+ "Agent#after_fork"
82
+ "Agent#disabled?"
83
+ "Agent#shutdown"
84
+ "Agent#using_forking_dispatcher?"
85
+ "Agent#has_license_key?"
86
+ "Agent#correct_license_length"
87
+ "Agent#apdex_f"
88
+ "Agent#check_config_and_start_agent"
89
+ "Agent#install_exit_handler"
90
+ "Agent#log_app_names"
91
+ "Agent#connect_settings"
92
+ "Agent#log_seed_token"
93
+ "Agent#log_error"
94
+ "Agent#monitoring?"
95
+ "Agent#check_trasaction_sampler_status"
96
+ "Agent#check_sql_sampler_status"
97
+ "Agent#config_transaction_tracer"
98
+ "Agent#set_sql_recording!"
99
+ "Agent#already_started?"
100
+ "Agent#log_connection"
101
+ "Agent#manual_start"
102
+
103
+ "MethodTracer#remove_method_tracer"
104
+
105
+ "ErrorCollector#initialize"
106
+ "ErrorCollector#request_params_from_opts"
107
+
108
+ "ControllerInstrumentation#perform_action_with_newrelic_trace"
109
+
110
+ "NewRelicService#initialize"
111
+ "NewRelicService#check_post_size"
112
+ "NewRelicService#connect"
113
+ "NewRelicService#send_request"
114
+
115
+ "SqlSampler#configure!"
116
+
117
+ "TransactionSampler#configure!"
118
+ "TransactionSampler#notice_push_scope"
119
+ "TransactionSampler#capture_segment_trace"
120
+ "TransactionSampler#store_segment_for_developer_mode"
121
+
122
+ "NoticedError#initialize"
123
+
124
+ "BeaconConfiguration#license_bytes"
125
+
126
+ "ActiveRecord#depends_on"
127
+ "DelayedJobInstrumentation#depends_on"
128
+ "Memcache#memcache_key_snippet"
129
+ "Memcache#depends_on"
130
+ "Rails::ActionController#depends_on"
131
+ "Rails3::ActionController#depends_on"
132
+ "Resque#depends_on"
133
+
134
+ "DelayedJobSampler#initialize"
135
+ "DelayedJobInjection#depends_on"
136
+
137
+ "MetricFrame.update_apdex"
138
+
139
+ "TranactionInfo#force_persist_sample?"
140
+ "TranactionInfo#include_guid?"
141
+
142
+ "TransactionSampleBuilder#initialize"
143
+ "TransactionSampleBuilder#set_transaction_info"
144
+
145
+ "Rails#install_browser_monitoring"
146
+ "Rails#log!"
147
+ "Rails3#log!"
148
+
149
+ "CollectionHelper#strip_nr_from_backtrace"
150
+
151
+ "Deployments#initialize"
152
+
153
+ #######
154
+
155
+ "Control#init_plugin" -> "[agent_enabled]"
156
+ "Control#init_plugin" -> "Control#setup_log"
157
+ "Control#init_plugin" -> "[disable_samplers]"
158
+ "Control#should_log?" -> "[agent_enabled]"
159
+ "Control#api_server" -> "[api_host]"
160
+ "Control#api_server" -> "[api_port]"
161
+ "Control#proxy_server" -> "[proxy_host]"
162
+ "Control#proxy_server" -> "[proxy_port]"
163
+ "Control#proxy_server" -> "[proxy_user]"
164
+ "Control#proxy_server" -> "[proxy_pass]"
165
+ "Control#server_from_host" -> "[host]"
166
+ "Control#server_from_host" -> "[port]"
167
+ "Control#server_from_host" -> "Control#convert_to_ip_address"
168
+ "Control#http_connection" -> "[ssl]"
169
+ "Control#http_connection" -> "[verify_certificate]"
170
+ "Control#http_connection" -> "Control#proxy_server"
171
+ "Control#set_log_level!" -> "[log_level]"
172
+ "Control#log_path" -> "[log_file_path]"
173
+ "Control#log_path" -> "Control#log_to_stdout?"
174
+ "Control#log_to_stdout?" -> "[log_file_path]"
175
+ "Control#convert_to_ip_address" -> "[ssl]"
176
+ "Control#convert_to_ip_address" -> "[verify_certificate]"
177
+ "Control#server" -> "Control#server_from_host"
178
+ "Control#setup_log" -> "Control#set_log_level!"
179
+ "Control#setup_log" -> "Control#log_path"
180
+ "Control#setup_log" -> "Control#log_to_stdout?"
181
+ "Control#setup_log" -> "[log_file_name]"
182
+ "Control#log!" -> "Control#should_log?"
183
+ "Control#log!" -> "Control#log_path"
184
+
185
+ "Agent#initialize" -> "[monitor_mode]"
186
+ "Agent#after_fork" -> "[agent_enabled]"
187
+ "Agent#after_fork" -> "[monitor_mode]"
188
+ "Agent#disabled?" -> "[agent_enabled]"
189
+ "Agent#shutdown" -> "[force_send]"
190
+ "Agent#shutdown" -> "[dispatcher]"
191
+ "Agent#using_forking_dispatcher?" -> "[dispatcher]"
192
+ "Agent#has_license_key?" -> "[license_key]"
193
+ "Agent#correct_license_length" -> "[license_key]"
194
+ "Agent#apdex_f" -> "[apdex_t]"
195
+ "Agent#check_config_and_start_agent" -> "[sync_startup]"
196
+ "Agent#install_exit_handler" -> "[send_data_on_exit]"
197
+ "Agent#log_app_names" -> "Config#app_names"
198
+ "Agent#connect_settings" -> "Config#app_names"
199
+ "Agent#log_seed_token" -> "[validate_seed]"
200
+ "Agent#log_seed_token" -> "[validate_token]"
201
+ "Agent#validate_settings" -> "[validate_seed]"
202
+ "Agent#validate_settings" -> "[validate_token]"
203
+ "Agent#log_error" -> "Control#server"
204
+ "Agent#monitoring?" -> "[monitor_mode]"
205
+ "Agent#check_trasaction_sampler_status" -> "[developer_mode]"
206
+ "Agent#check_sql_sampler_status" -> "[slow_sql.enabled]"
207
+ "Agent#check_sql_sampler_status" -> "[slow_sql.record_sql]"
208
+ "Agent#check_sql_sampler_status" -> "[transaction_tracer.enabled]"
209
+ "Agent#config_transaction_tracer" -> "[transaction_tracer.enabled]"
210
+ "Agent#config_transaction_tracer" -> "[transaction_tracer.random_sample]"
211
+ "Agent#config_transaction_tracer" -> "[transaction_tracer.transaction_threshold]"
212
+ "Agent#set_sql_recording!" -> "[transaction_tracer.record_sql]"
213
+ "Agent#already_started?" -> "Control#log!"
214
+ "Agent#log_connection" -> "Control#log!"
215
+ "Agent#manual_start" -> "Control#init_plugin"
216
+
217
+ "MethodTracer#remove_method_tracer" -> "[agent_enabled]"
218
+
219
+ "Rails#init_config" -> "[agent_enabled]"
220
+ "Rails#init_config" -> "[developer_mode]"
221
+
222
+ "ErrorCollector#initialize" -> "[error_collector.enabled]"
223
+ "ErrorCollector#initialize" -> "[error_collector.capture_source]"
224
+ "ErrorCollector#initialize" -> "[error_collector.ignore_errors]"
225
+ "ErrorCollector#request_params_from_opts" -> "[capture_params]"
226
+
227
+ "ControllerInstrumentation#perform_action_with_newrelic_trace" -> "[disable_mobile_headers]"
228
+
229
+ "NewRelicService#initialize" -> "[timeout]"
230
+ "NewRelicService#initialize" -> "[license_key]"
231
+ "NewRelicService#initialize" -> "Control#server"
232
+ "NewRelicService#check_post_size" -> "[post_size_limit]"
233
+ "NewRelicService#connect" -> "Control#server_from_host"
234
+ "NewRelicService#send_request" -> "Control#http_connection"
235
+
236
+ "SqlSampler#configure!" -> "[slow_sql.explain_threshold]"
237
+ "SqlSampler#configure!" -> "[slow_sql.explain_enabled]"
238
+ "SqlSampler#configure!" -> "[slow_sql.stack_trace_threshold]"
239
+ "SqlSampler#configure!" -> "[slow_sql.enabled]"
240
+
241
+ "TransactionSampler#configure!" -> "[transaction_tracer.limit_segments]"
242
+ "TransactionSampler#configure!" -> "[transaction_tracer.stack_trace_threshold]"
243
+ "TransactionSampler#configure!" -> "[transaction_tracer.explain_threshold]"
244
+ "TransactionSampler#configure!" -> "[transaction_tracer.explain_enabled]"
245
+ "TransactionSampler#configure!" -> "[transaction_tracer.transaction_threshold]"
246
+ "TransactionSampler#configure!" -> "[developer_mode]"
247
+ "TransactionSampler#notice_push_scope" -> "[developer_mode]"
248
+ "TransactionSampler#capture_segment_trace" -> "[developer_mode]"
249
+ "TransactionSampler#store_segment_for_developer_mode" -> "[developer_mode]"
250
+
251
+ "NoticedError#initialize" -> "[high_security]"
252
+
253
+ "BeaconConfiguration#license_bytes" -> "[license_key]"
254
+
255
+ "ActiveRecord#depends_on" -> "[disable_activerecord_instrumentation]"
256
+
257
+ "DelayedJobInstrumentation#depends_on" -> "[disable_dj]"
258
+
259
+ "Memcache#memcache_key_snippet" -> "[capture_memcache_keys]"
260
+ "Memcache#depends_on" -> "[disable_memcache_instrumentation]"
261
+
262
+ "Rails::ActionController#depends_on" -> "[disable_view_instrumentation]"
263
+ "Rails3::ActionController#depends_on" -> "[disable_view_instrumentation]"
264
+ "Resque#depends_on" -> "[disable_resque]"
265
+
266
+ "DelayedJobSampler#initialize" -> "[disable_dj]"
267
+ "DelayedJobInjection#depends_on" -> "[disable_dj]"
268
+ "DelayedJobInjection#executes" -> "Control#init_plugin"
269
+
270
+ "MetricFrame.update_apdex" -> "[apdex_t]"
271
+
272
+ "TranactionInfo#force_persist_sample?" -> "[apdex_t]"
273
+ "TranactionInfo#include_guid?" -> "[apdex_t]"
274
+
275
+ "TransactionSampleBuilder#initialize" -> "[transaction_tracer.limit_segments]"
276
+ "TransactionSampleBuilder#set_transaction_info" -> "[capture_params]"
277
+
278
+ "Rails#install_browser_monitoring" -> "[browser_monitoring.auto_instrument]"
279
+ "Rails#log!" -> "Control#should_log?"
280
+ "Rails3#log!" -> "Control#should_log?"
281
+
282
+ "CollectionHelper#strip_nr_from_backtrace" -> "[disable_backtrace_cleanup]"
283
+
284
+ "Deployments#initialize" -> "Config#app_names"
285
+ "Deployments#run" -> "Control#http_connection"
286
+ "Deployments#run" -> "[license_key]"
287
+ "Deployments#run" -> "Control#api_server"
288
+
289
+ "Config#app_names" -> "[app_name]"
290
+ }
@@ -77,6 +77,7 @@ module NewRelic
77
77
  require 'new_relic/agent'
78
78
  require 'new_relic/agent/chained_call'
79
79
  require 'new_relic/agent/browser_monitoring'
80
+ require 'new_relic/agent/cross_process_monitoring'
80
81
  require 'new_relic/agent/agent'
81
82
  require 'new_relic/agent/shim_agent'
82
83
  require 'new_relic/agent/method_tracer'
@@ -305,7 +306,8 @@ module NewRelic
305
306
 
306
307
  # Check to see if we are capturing metrics currently on this thread.
307
308
  def is_execution_traced?
308
- Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
309
+ untraced = Thread.current[:newrelic_untraced]
310
+ untraced.nil? || untraced.last != false
309
311
  end
310
312
 
311
313
  # helper method to check the thread local to determine whether the
@@ -85,8 +85,17 @@ module NewRelic
85
85
  # handles things like static setup of the header for inclusion
86
86
  # into pages
87
87
  attr_reader :beacon_configuration
88
+ attr_reader :cross_process_id
88
89
  attr_accessor :service
89
90
 
91
+ def cross_process_encoding_bytes
92
+ if @cross_process_encoding_key && @cross_process_encoding_bytes.nil?
93
+ @cross_process_encoding_bytes = []
94
+ @cross_process_encoding_key.each_byte {|byte| @cross_process_encoding_bytes << byte}
95
+ end
96
+ @cross_process_encoding_bytes
97
+ end
98
+
90
99
  # Returns the length of the unsent errors array, if it exists,
91
100
  # otherwise nil
92
101
  def unsent_errors_size
@@ -300,7 +309,7 @@ module NewRelic
300
309
  end
301
310
 
302
311
  # Herein lies the corpse of the former 'start' method. May
303
- # it's unmatched flog score rest in pieces.
312
+ # its unmatched flog score rest in pieces.
304
313
  module Start
305
314
  # Check whether we have already started, which is an error condition
306
315
  def already_started?
@@ -754,6 +763,9 @@ module NewRelic
754
763
  Agent.config.apply_config(server_config, 1)
755
764
  log_connection!(config_data) if @service
756
765
 
766
+ @cross_process_id = Agent.config[:cross_process_id]
767
+ @cross_process_encoding_key = Agent.config[:encoding_key]
768
+
757
769
  @beacon_configuration = BeaconConfiguration.new
758
770
  end
759
771
 
@@ -886,9 +898,22 @@ module NewRelic
886
898
 
887
899
  @unsent_timeslice_data ||= {}
888
900
  @unsent_timeslice_data = @stats_engine.harvest_timeslice_data(@unsent_timeslice_data, @metric_ids)
901
+
902
+ warn_if_no_unicorn_metrics
903
+
889
904
  @unsent_timeslice_data
890
905
  end
891
906
 
907
+ # this is just a support band-aid until we get a chance to
908
+ # overhaul the Unicorn instrumentation properly
909
+ def warn_if_no_unicorn_metrics
910
+ if Agent.config[:dispatcher].to_s == 'unicorn'
911
+ if @stats_engine.get_stats_no_scope('HttpDispatcher').call_count == 0
912
+ NewRelic::Control.instance.log.warn('Unicorn detected but no metric send, please see https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data')
913
+ end
914
+ end
915
+ end
916
+
892
917
  # takes an array of arrays of spec and id, adds it into the
893
918
  # metric cache so we can save the collector some work by
894
919
  # sending integers instead of strings
@@ -1061,6 +1086,7 @@ module NewRelic
1061
1086
  extend ClassMethods
1062
1087
  include InstanceMethods
1063
1088
  include BrowserMonitoring
1089
+ include CrossProcessMonitoring
1064
1090
  end
1065
1091
  end
1066
1092
  end
@@ -35,7 +35,6 @@ module NewRelic
35
35
  :send_environment_info => true,
36
36
  :start_channel_listener => false,
37
37
  :data_report_period => 60,
38
- :keep_retrying => true,
39
38
 
40
39
  :log_file_name => 'newrelic_agent.log',
41
40
  :log_file_path => 'log/',
@@ -0,0 +1,93 @@
1
+ require 'base64'
2
+ module NewRelic
3
+ module Agent
4
+ module CrossProcessMonitoring
5
+ #start copied from BrowserMonitoring
6
+
7
+ class DummyMetricFrame
8
+ def initialize
9
+ @attributes = {}
10
+ end
11
+
12
+ def user_attributes
13
+ @attributes
14
+ end
15
+
16
+ def queue_time
17
+ 0.0
18
+ end
19
+ end
20
+
21
+ @@dummy_metric_frame = DummyMetricFrame.new
22
+
23
+ #end
24
+
25
+ module_function
26
+
27
+ #start copy from BrowserMonitoring
28
+
29
+ def browser_monitoring_transaction_name
30
+ NewRelic::Agent::TransactionInfo.get.transaction_name
31
+ end
32
+
33
+ def browser_monitoring_queue_time_in_seconds
34
+ clamp_to_positive((current_metric_frame.queue_time.to_f).round)
35
+ end
36
+
37
+ def browser_monitoring_app_time_in_seconds
38
+ clamp_to_positive(((Time.now - browser_monitoring_start_time).to_f).round)
39
+ end
40
+
41
+ def current_metric_frame
42
+ Thread.current[:last_metric_frame] || @@dummy_metric_frame
43
+ end
44
+
45
+ def clamp_to_positive(value)
46
+ return 0.0 if value < 0
47
+ value
48
+ end
49
+
50
+ def browser_monitoring_start_time
51
+ NewRelic::Agent::TransactionInfo.get.start_time
52
+ end
53
+
54
+ # end copy
55
+
56
+ def obfuscate_with_key(text, key_bytes)
57
+ obfuscated = ""
58
+ index = 0
59
+ text.each_byte{|byte|
60
+ obfuscated.concat((byte ^ key_bytes[index % key_bytes.length].to_i))
61
+ index+=1
62
+ }
63
+
64
+ [obfuscated].pack("m0").gsub("\n", '')
65
+ end
66
+
67
+ def insert_cross_process_response_header(request, response)
68
+
69
+ if NewRelic::Agent.instance.cross_process_id && (id = cross_process_id_from_request(request))
70
+ content_length = -1
71
+ # FIXME the transaction name might not be properly encoded. use a json generator
72
+ payload = %[["#{NewRelic::Agent.instance.cross_process_id}","#{browser_monitoring_transaction_name}",#{browser_monitoring_queue_time_in_seconds},#{browser_monitoring_app_time_in_seconds},#{content_length}] ]
73
+ payload = obfuscate_with_key payload, NewRelic::Agent.instance.cross_process_encoding_bytes
74
+
75
+ response['X-NewRelic-App-Data'] = payload
76
+ #FIXME generate ClientApplication metric. id must be decoded first
77
+ # String metricName = MessageFormat.format("ClientApplication/{0}/all", id);
78
+ end
79
+ end
80
+
81
+ def cross_process_id_from_request(request)
82
+ headers = ['X-NewRelic-ID', 'HTTP_X_NEWRELIC_ID', 'X_NEWRELIC_ID']
83
+ headers.each do |header|
84
+ id = request.env[header]
85
+ return id if id
86
+ end
87
+ nil
88
+ end
89
+
90
+ private
91
+ end
92
+ end
93
+ end
@@ -269,9 +269,11 @@ module NewRelic
269
269
  else
270
270
  perform_action_without_newrelic_trace(*args)
271
271
  end
272
- if defined?(request) && request && defined?(response) &&
273
- response && !Agent.config[:disable_mobile_headers]
274
- NewRelic::Agent::BrowserMonitoring.insert_mobile_response_header(request, response)
272
+ if defined?(request) && request && defined?(response) && response
273
+ if !Agent.config[:disable_mobile_headers]
274
+ NewRelic::Agent::BrowserMonitoring.insert_mobile_response_header(request, response)
275
+ end
276
+ NewRelic::Agent::CrossProcessMonitoring.insert_cross_process_response_header(request, response)
275
277
  end
276
278
  result
277
279
  rescue => e
@@ -180,14 +180,6 @@ module NewRelic
180
180
  module Agent
181
181
  module Instrumentation
182
182
  module DataMapperInstrumentation
183
-
184
- def self.included(klass)
185
- klass.class_eval do
186
- alias_method :log_without_newrelic_instrumentation, :log
187
- alias_method :log, :log_with_newrelic_instrumentation
188
- end
189
- end
190
-
191
183
  # Unlike in AR, log is called in DM after the query actually ran,
192
184
  # complete with metrics. Since DO has already calculated the
193
185
  # duration, there's nothing more to measure, so just record and log.
@@ -195,7 +187,7 @@ module NewRelic
195
187
  # We rely on the assumption that all possible entry points have been
196
188
  # hooked with tracers, ensuring that notice_sql attaches this SQL to
197
189
  # the proper call scope.
198
- def log_with_newrelic_instrumentation(msg)
190
+ def log(msg)
199
191
  return unless NewRelic::Agent.is_execution_traced?
200
192
  return unless operation = case NewRelic::Helper.correctly_encoded(msg.query)
201
193
  when /^\s*select/i then 'find'
@@ -216,7 +208,7 @@ module NewRelic
216
208
  NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
217
209
  end
218
210
  ensure
219
- log_without_newrelic_instrumentation(msg)
211
+ super
220
212
  end
221
213
 
222
214
  end # DataMapperInstrumentation
@@ -27,11 +27,21 @@ module NewRelic
27
27
  attr_accessor :request
28
28
 
29
29
 
30
+ @@check_server_connection = false
31
+ def self.check_server_connection=(value)
32
+ @@check_server_connection = value
33
+ end
30
34
  # Return the currently active metric frame, or nil. Call with +true+
31
35
  # to create a new metric frame if one is not already on the thread.
32
36
  def self.current(create_if_empty=nil)
33
37
  f = Thread.current[:newrelic_metric_frame]
34
38
  return f if f || !create_if_empty
39
+
40
+ # Reconnect to the server if necessary. This is only done
41
+ # for old versions of passenger that don't implement an explicit after_fork
42
+ # event.
43
+ agent.after_fork(:keep_retrying => false) if @@check_server_connection
44
+
35
45
  Thread.current[:newrelic_metric_frame] = new
36
46
  end
37
47
 
@@ -54,8 +64,8 @@ module NewRelic
54
64
  if defined? JRuby
55
65
  begin
56
66
  require 'java'
57
- include_class 'java.lang.management.ManagementFactory'
58
- include_class 'com.sun.management.OperatingSystemMXBean'
67
+ java_import 'java.lang.management.ManagementFactory'
68
+ java_import 'com.sun.management.OperatingSystemMXBean'
59
69
  @@java_classes_loaded = true
60
70
  rescue => e
61
71
  end
@@ -1,6 +1,6 @@
1
1
  DependencyDetection.defer do
2
2
  @name = :passenger
3
-
3
+
4
4
  depends_on do
5
5
  defined?(::PhusionPassenger)
6
6
  end
@@ -21,3 +21,17 @@ DependencyDetection.defer do
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ DependencyDetection.defer do
26
+ depends_on do
27
+ defined?(::Passenger) && defined?(::Passenger::AbstractServer)
28
+ end
29
+
30
+ executes do
31
+ ## We're on an older version of passenger
32
+ ## FIXME: This warning is printing on current version of passenger
33
+ # NewRelic::Agent.logger.warn "An older version of Phusion Passenger has been detected. We recommend using at least release 2.1.1."
34
+
35
+ NewRelic::Agent::Instrumentation::MetricFrame.check_server_connection = true
36
+ end
37
+ end
@@ -7,7 +7,7 @@ module NewRelic
7
7
  #
8
8
  # New Relic will instrument a #call method as if it were a controller
9
9
  # action, collecting transaction traces and errors. The middleware will
10
- # be identified only by it's class, so if you want to instrument multiple
10
+ # be identified only by its class, so if you want to instrument multiple
11
11
  # actions in a middleware, you need to use
12
12
  # NewRelic::Agent::Instrumentation::ControllerInstrumentation::ClassMethods#add_transaction_tracer
13
13
  #
@@ -22,7 +22,7 @@ module NewRelic
22
22
  end
23
23
  elsif platform =~ /darwin9/ # 10.5
24
24
  @sampler = ShellPS.new("ps -o rsz")
25
- elsif platform =~ /darwin1[01]/ # 10.6 & 10.7
25
+ elsif platform =~ /darwin1\d+/ # >= 10.6
26
26
  @sampler = ShellPS.new("ps -o rss")
27
27
  elsif platform =~ /freebsd/
28
28
  @sampler = ShellPS.new("ps -o rss")
@@ -35,7 +35,7 @@ module NewRelic
35
35
  end
36
36
 
37
37
  def self.supported_on_this_platform?
38
- defined?(JRuby) or platform =~ /linux|darwin9|darwin10|freebsd|solaris/
38
+ defined?(JRuby) or platform =~ /linux|darwin|freebsd|solaris/
39
39
  end
40
40
 
41
41
  def self.platform
@@ -7,6 +7,7 @@ module NewRelic
7
7
  @profiler = RailsBench.new if RailsBench.enabled?
8
8
  @profiler = Ruby19.new if Ruby19.enabled?
9
9
  @profiler = Rubinius.new if Rubinius.enabled?
10
+ @profiler = RubiniusAgent.new if RubiniusAgent.enabled?
10
11
  end
11
12
 
12
13
  def self.capture
@@ -97,6 +98,20 @@ module NewRelic
97
98
  end
98
99
 
99
100
  class Rubinius < Profiler
101
+ def self.enabled?
102
+ defined?(::Rubinius) && defined?(::Rubinius::GC) && ::Rubinius::GC.respond_to?(:count)
103
+ end
104
+
105
+ def call_time
106
+ ::Rubinius::GC.time * 1000
107
+ end
108
+
109
+ def call_count
110
+ ::Rubinius::GC.count
111
+ end
112
+ end
113
+
114
+ class RubiniusAgent < Profiler
100
115
  def self.enabled?
101
116
  if NewRelic::LanguageSupport.using_engine?('rbx')
102
117
  require 'rubinius/agent'
@@ -213,7 +213,7 @@ module NewRelic
213
213
  end
214
214
  end
215
215
 
216
- # Checks to see if the old sample exists, or if it's duration is
216
+ # Checks to see if the old sample exists, or if its duration is
217
217
  # less than the new sample
218
218
  def slowest_sample?(old_sample, new_sample)
219
219
  old_sample.nil? || (new_sample.duration > old_sample.duration)
@@ -45,8 +45,8 @@ module NewRelic
45
45
  end
46
46
  if !Agent.config[:agent_enabled]
47
47
  # Might not be running if it does not think mongrel, thin, passenger, etc
48
- # is running, if it things it's a rake task, or if the agent_enabled is false.
49
- log! "New Relic Agent not running."
48
+ # is running, if it thinks it's a rake task, or if the agent_enabled is false.
49
+ log!("New Relic Agent not running.", :debug)
50
50
  else
51
51
  log! "Starting the New Relic Agent."
52
52
  install_developer_mode rails_config if Agent.config[:developer_mode]
@@ -158,9 +158,11 @@ module NewRelic
158
158
  def install_shim
159
159
  super
160
160
  require 'new_relic/agent/instrumentation/controller_instrumentation'
161
- ::ActionController::Base.class_eval {
162
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim
163
- }
161
+ if ActiveSupport.respond_to?(:on_load) # rails 3+
162
+ ActiveSupport.on_load(:action_controller) { include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim }
163
+ else
164
+ ActionController::Base.class_eval { include NewRelic::Agent::Instrumentation::ControllerInstrumentation::Shim }
165
+ end
164
166
  end
165
167
 
166
168
  end
@@ -14,6 +14,7 @@ module NewRelic
14
14
  #
15
15
  # NewRelic::LocalEnvironment should be accessed through NewRelic::Control#env (via the NewRelic::Control singleton).
16
16
  class LocalEnvironment
17
+
17
18
  # mongrel, thin, webrick, or possibly nil
18
19
  attr_accessor :dispatcher
19
20
  # used to distinguish instances of a dispatcher from each other, may be nil
@@ -22,7 +23,7 @@ module NewRelic
22
23
  attr_accessor :framework
23
24
  # The number of cpus, if detected, or nil - many platforms do not
24
25
  # support this :(
25
- attr_reader :processors
26
+ attr_reader :processors
26
27
  alias environment dispatcher
27
28
 
28
29
  def initialize
@@ -396,7 +397,7 @@ module NewRelic
396
397
  end
397
398
 
398
399
  def check_for_passenger
399
- if defined?(::PhusionPassenger)
400
+ if (defined?(::Passenger) && defined?(::Passenger::AbstractServer)) || defined?(::PhusionPassenger)
400
401
  @dispatcher = :passenger
401
402
  end
402
403
  end
@@ -59,8 +59,6 @@ module NewRelic::Rack
59
59
  # otherwise put the header right above body start
60
60
  body_start
61
61
  end
62
- # otherwise put the header right above body start
63
- head_pos ||= body_start
64
62
 
65
63
  # check that head_pos is less than body close. If it's not something
66
64
  # is really weird and we should punt.
@@ -3,8 +3,8 @@ module NewRelic
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 3
5
5
  MINOR = 5
6
- TINY = 0
7
- BUILD = 1 # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
6
+ TINY = 1
7
+ BUILD = 'alpha' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
10
10
 
data/newrelic_rpm.gemspec CHANGED
@@ -4,20 +4,15 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{newrelic_rpm}
8
- s.version = "3.5.0.1"
7
+ s.name = "newrelic_rpm"
8
+ s.version = "3.5.1.alpha"
9
9
 
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
11
  s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson", "Rob Saul"]
11
- s.date = %q{2012-10-22}
12
- s.description = %q{New Relic is a performance management system, developed by New Relic,
13
- Inc (http://www.newrelic.com). New Relic provides you with deep
14
- information about the performance of your web application as it runs
15
- in production. The New Relic Ruby Agent is dual-purposed as a either a
16
- Gem or plugin, hosted on
17
- http://github.com/newrelic/rpm/
18
- }
19
- s.email = %q{support@newrelic.com}
20
- s.executables = ["newrelic", "mongrel_rpm", "newrelic_cmd"]
12
+ s.date = "2012-10-11"
13
+ s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). New Relic provides you with deep\ninformation about the performance of your web application as it runs\nin production. The New Relic Ruby Agent is dual-purposed as a either a\nGem or plugin, hosted on\nhttp://github.com/newrelic/rpm/\n"
14
+ s.email = "support@newrelic.com"
15
+ s.executables = ["mongrel_rpm", "newrelic_cmd", "newrelic"]
21
16
  s.extra_rdoc_files = [
22
17
  "CHANGELOG",
23
18
  "LICENSE",
@@ -34,6 +29,7 @@ http://github.com/newrelic/rpm/
34
29
  "cert/cacert.pem",
35
30
  "cert/oldsite.pem",
36
31
  "cert/site.pem",
32
+ "config.dot",
37
33
  "install.rb",
38
34
  "lib/conditional_vendored_dependency_detection.rb",
39
35
  "lib/conditional_vendored_metric_parser.rb",
@@ -49,6 +45,7 @@ http://github.com/newrelic/rpm/
49
45
  "lib/new_relic/agent/configuration/manager.rb",
50
46
  "lib/new_relic/agent/configuration/server_source.rb",
51
47
  "lib/new_relic/agent/configuration/yaml_source.rb",
48
+ "lib/new_relic/agent/cross_process_monitoring.rb",
52
49
  "lib/new_relic/agent/database.rb",
53
50
  "lib/new_relic/agent/error_collector.rb",
54
51
  "lib/new_relic/agent/instrumentation.rb",
@@ -312,30 +309,11 @@ http://github.com/newrelic/rpm/
312
309
  "vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb",
313
310
  "vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb"
314
311
  ]
315
- s.homepage = %q{http://www.github.com/newrelic/rpm}
316
- s.post_install_message = %q{
317
- PLEASE NOTE:
318
-
319
- Developer Mode is now a Rack middleware.
320
-
321
- Developer Mode is no longer available in Rails 2.1 and earlier.
322
- However, starting in version 2.12 you can use Developer Mode in any
323
- Rack based framework, in addition to Rails. To install developer mode
324
- in a non-Rails application, just add NewRelic::Rack::DeveloperMode to
325
- your middleware stack.
326
-
327
- If you are using JRuby, we recommend using at least version 1.4 or
328
- later because of issues with the implementation of the timeout library.
329
-
330
- Refer to the README.md file for more information.
331
-
332
- Please see http://github.com/newrelic/rpm/blob/master/CHANGELOG
333
- for a complete description of the features and enhancements available
334
- in version 3.5 of the Ruby Agent.
335
-
336
- }
312
+ s.homepage = "http://www.github.com/newrelic/rpm"
313
+ s.post_install_message = "\nPLEASE NOTE:\n\nDeveloper Mode is now a Rack middleware.\n\nDeveloper Mode is no longer available in Rails 2.1 and earlier.\nHowever, starting in version 2.12 you can use Developer Mode in any\nRack based framework, in addition to Rails. To install developer mode\nin a non-Rails application, just add NewRelic::Rack::DeveloperMode to\nyour middleware stack.\n\nIf you are using JRuby, we recommend using at least version 1.4 or \nlater because of issues with the implementation of the timeout library.\n\nRefer to the README.md file for more information.\n\nPlease see http://github.com/newrelic/rpm/blob/master/CHANGELOG\nfor a complete description of the features and enhancements available\nin version 3.5 of the Ruby Agent.\n \n"
337
314
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "New Relic Ruby Agent"]
338
315
  s.require_paths = ["lib"]
316
+ s.rubygems_version = "1.6.2"
339
317
  s.summary = "New Relic Ruby Agent"
340
318
 
341
319
  if s.respond_to? :specification_version then
@@ -76,6 +76,20 @@ module NewRelic
76
76
  end
77
77
  end
78
78
 
79
+ def test_harvest_timeslice_data_should_not_warn_normally
80
+ NewRelic::Control.instance.log.expects(:warn).never
81
+ @agent.stats_engine.get_stats_no_scope('HttpDispatcher').record_data_point(1.0)
82
+ @agent.send(:harvest_timeslice_data)
83
+ end
84
+
85
+ def test_harvest_timeslice_data_should_warn_if_unicorn_and_no_web_metrics
86
+ NewRelic::Control.instance.log.expects(:warn) \
87
+ .with('Unicorn detected but no metric send, please see https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data')
88
+ with_config(:dispatcher => 'unicorn') do
89
+ @agent.send(:harvest_timeslice_data)
90
+ end
91
+ end
92
+
79
93
  def test_harvest_errors
80
94
  assert_equal([], @agent.send(:harvest_errors), 'should return errors')
81
95
  end
@@ -28,7 +28,8 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
28
28
 
29
29
  def test_passenger
30
30
  class << self
31
- module ::PhusionPassenger
31
+ module ::Passenger
32
+ const_set "AbstractServer", 0
32
33
  end
33
34
  end
34
35
  e = NewRelic::LocalEnvironment.new
@@ -41,9 +42,9 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
41
42
  assert_nil e.dispatcher_instance_id
42
43
  end
43
44
 
44
- Object.send(:remove_const, :PhusionPassenger)
45
+ ::Passenger.class_eval { remove_const :AbstractServer }
45
46
  end
46
-
47
+
47
48
  def test_snapshot
48
49
  e = NewRelic::LocalEnvironment.new
49
50
  s = e.snapshot
data/test/script/ci.sh CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Script to run test suites in CI or in development mode. This script handles
4
- # checking out test dependencies (currently rpm_test_app and it's dependencies)
4
+ # checking out test dependencies (currently rpm_test_app and its dependencies)
5
5
  # and executing them.
6
6
  #
7
7
  # It relies on 2 environment variables:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 85
5
- prerelease:
4
+ hash: 2096628268
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 5
9
- - 0
10
9
  - 1
11
- version: 3.5.0.1
10
+ - alpha
11
+ version: 3.5.1.alpha
12
12
  platform: ruby
13
13
  authors:
14
14
  - Bill Kayser
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2012-10-22 00:00:00 -07:00
23
+ date: 2012-10-11 00:00:00 -07:00
24
24
  default_executable:
25
25
  dependencies:
26
26
  - !ruby/object:Gem::Dependency
@@ -75,9 +75,9 @@ description: |
75
75
 
76
76
  email: support@newrelic.com
77
77
  executables:
78
- - newrelic
79
78
  - mongrel_rpm
80
79
  - newrelic_cmd
80
+ - newrelic
81
81
  extensions: []
82
82
 
83
83
  extra_rdoc_files:
@@ -95,6 +95,7 @@ files:
95
95
  - cert/cacert.pem
96
96
  - cert/oldsite.pem
97
97
  - cert/site.pem
98
+ - config.dot
98
99
  - install.rb
99
100
  - lib/conditional_vendored_dependency_detection.rb
100
101
  - lib/conditional_vendored_metric_parser.rb
@@ -110,6 +111,7 @@ files:
110
111
  - lib/new_relic/agent/configuration/manager.rb
111
112
  - lib/new_relic/agent/configuration/server_source.rb
112
113
  - lib/new_relic/agent/configuration/yaml_source.rb
114
+ - lib/new_relic/agent/cross_process_monitoring.rb
113
115
  - lib/new_relic/agent/database.rb
114
116
  - lib/new_relic/agent/error_collector.rb
115
117
  - lib/new_relic/agent/instrumentation.rb
@@ -417,12 +419,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
417
419
  required_rubygems_version: !ruby/object:Gem::Requirement
418
420
  none: false
419
421
  requirements:
420
- - - ">="
422
+ - - ">"
421
423
  - !ruby/object:Gem::Version
422
- hash: 3
424
+ hash: 25
423
425
  segments:
424
- - 0
425
- version: "0"
426
+ - 1
427
+ - 3
428
+ - 1
429
+ version: 1.3.1
426
430
  requirements: []
427
431
 
428
432
  rubyforge_project: