ghazel-newrelic_rpm 3.4.0.2 → 3.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.project +23 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +180 -1
- data/GUIDELINES_FOR_CONTRIBUTING.md +73 -0
- data/Gemfile +16 -0
- data/InstallationNotes.md +15 -0
- data/LICENSE +1 -1
- data/{README.rdoc → README.md} +71 -55
- data/Rakefile +54 -0
- data/config.dot +290 -0
- data/config/database.yml +5 -0
- data/init.rb +38 -0
- data/lib/new_relic/agent.rb +9 -4
- data/lib/new_relic/agent/agent.rb +189 -230
- data/lib/new_relic/agent/beacon_configuration.rb +34 -48
- data/lib/new_relic/agent/browser_monitoring.rb +108 -61
- data/lib/new_relic/agent/busy_calculator.rb +12 -4
- data/lib/new_relic/agent/configuration.rb +49 -0
- data/lib/new_relic/agent/configuration/defaults.rb +89 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +56 -0
- data/lib/new_relic/agent/configuration/manager.rb +116 -0
- data/lib/new_relic/agent/configuration/server_source.rb +27 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +61 -0
- data/lib/new_relic/agent/database.rb +37 -22
- data/lib/new_relic/agent/error_collector.rb +47 -43
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -5
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +27 -6
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +2 -10
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +4 -14
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +4 -18
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +5 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +14 -10
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +4 -3
- data/lib/new_relic/agent/method_tracer.rb +5 -1
- data/lib/new_relic/agent/new_relic_service.rb +231 -61
- data/lib/new_relic/agent/pipe_channel_manager.rb +37 -23
- data/lib/new_relic/agent/pipe_service.rb +5 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -5
- data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +44 -68
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +40 -24
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +89 -14
- data/lib/new_relic/agent/stats_engine/samplers.rb +7 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +19 -11
- data/lib/new_relic/agent/thread.rb +27 -0
- data/lib/new_relic/agent/thread_profiler.rb +295 -0
- data/lib/new_relic/agent/transaction_info.rb +24 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +11 -11
- data/lib/new_relic/agent/transaction_sampler.rb +51 -61
- data/lib/new_relic/agent/worker_loop.rb +29 -15
- data/lib/new_relic/collection_helper.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +19 -10
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/control/class_methods.rb +2 -3
- data/lib/new_relic/control/frameworks/rails.rb +24 -18
- data/lib/new_relic/control/frameworks/rails3.rb +18 -1
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/instance_methods.rb +36 -53
- data/lib/new_relic/control/logging_methods.rb +5 -23
- data/lib/new_relic/control/server_methods.rb +11 -13
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/helper.rb +13 -0
- data/lib/new_relic/language_support.rb +19 -22
- data/lib/new_relic/local_environment.rb +2 -3
- data/lib/new_relic/metric_data.rb +10 -2
- data/lib/new_relic/metric_spec.rb +6 -2
- data/lib/new_relic/noticed_error.rb +24 -9
- data/lib/new_relic/rack.rb +4 -0
- data/lib/new_relic/rack/browser_monitoring.rb +28 -10
- data/lib/new_relic/rack/developer_mode.rb +3 -0
- data/lib/new_relic/rack/error_collector.rb +56 -0
- data/lib/new_relic/transaction_sample.rb +23 -13
- data/lib/new_relic/transaction_sample/segment.rb +13 -15
- data/lib/new_relic/version.rb +3 -3
- data/lib/tasks/tests.rake +8 -8
- data/newrelic.yml +15 -32
- data/newrelic_rpm.gemspec +158 -38
- data/newrelic_rpm.gemspec.erb +55 -0
- data/test/config/newrelic.yml +3 -2
- data/test/intentional_fail.rb +10 -0
- data/test/multiverse/.gitignore +10 -0
- data/test/multiverse/README.md +90 -0
- data/test/multiverse/Rakefile +17 -0
- data/test/multiverse/lib/multiverse/color.rb +13 -0
- data/test/multiverse/lib/multiverse/envfile.rb +66 -0
- data/test/multiverse/lib/multiverse/environment.rb +16 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
- data/test/multiverse/lib/multiverse/runner.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +162 -0
- data/test/multiverse/script/run_one +3 -0
- data/test/multiverse/script/runner +9 -0
- data/test/multiverse/suites/active_record/Envfile +13 -0
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
- data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
- data/test/multiverse/suites/agent_only/Envfile +3 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +22 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +109 -0
- data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +29 -0
- data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
- data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +80 -0
- data/test/multiverse/suites/datamapper/Envfile +8 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
- data/test/multiverse/suites/datamapper/encoding_test.rb +36 -0
- data/test/multiverse/suites/monitor_mode_false/Envfile +2 -0
- data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +25 -0
- data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +29 -0
- data/test/multiverse/suites/no_load/Envfile +2 -0
- data/test/multiverse/suites/no_load/config/newrelic.yml +23 -0
- data/test/multiverse/suites/no_load/start_up_test.rb +14 -0
- data/test/multiverse/suites/rails_3_error_tracing/Envfile +15 -0
- data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +165 -0
- data/test/multiverse/suites/rails_3_error_tracing/error_tracing_test.rb +236 -0
- data/test/multiverse/suites/rails_3_gc/Envfile +8 -0
- data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +167 -0
- data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +92 -0
- data/test/multiverse/suites/rails_3_queue_time/Envfile +15 -0
- data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +165 -0
- data/test/multiverse/suites/rails_3_queue_time/queue_time_test.rb +75 -0
- data/test/multiverse/suites/rails_3_views/.gitignore +3 -0
- data/test/multiverse/suites/rails_3_views/Envfile +16 -0
- data/test/multiverse/suites/rails_3_views/app/views/foos/_foo.html.haml +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_mid_partial.html.erb +1 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/_top_partial.html.erb +3 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/deep_partial.html.erb +3 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/haml_view.html.haml +6 -0
- data/test/multiverse/suites/rails_3_views/app/views/test/index.html.erb +4 -0
- data/test/multiverse/suites/rails_3_views/config/newrelic.yml +164 -0
- data/test/multiverse/suites/rails_3_views/view_instrumentation_test.rb +245 -0
- data/test/multiverse/suites/resque/Envfile +21 -0
- data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
- data/test/multiverse/suites/resque/dump.rdb +0 -0
- data/test/multiverse/suites/resque/instrumentation_test.rb +73 -0
- data/test/multiverse/suites/rum_auto_instrumentation/Envfile +4 -0
- data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +24 -0
- data/test/multiverse/suites/rum_auto_instrumentation/problem_response.html +422 -0
- data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +5000 -0
- data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +115 -0
- data/test/multiverse/suites/sinatra/Envfile +13 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +76 -0
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
- data/test/multiverse/test/multiverse_test.rb +55 -0
- data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
- data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
- data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
- data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
- data/test/new_relic/agent/agent/connect_test.rb +134 -164
- data/test/new_relic/agent/agent/start_test.rb +111 -81
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +6 -33
- data/test/new_relic/agent/agent_test.rb +88 -9
- data/test/new_relic/agent/agent_test_controller.rb +1 -1
- data/test/new_relic/agent/agent_test_controller_test.rb +42 -10
- data/test/new_relic/agent/beacon_configuration_test.rb +63 -67
- data/test/new_relic/agent/browser_monitoring_test.rb +150 -79
- data/test/new_relic/agent/configuration/environment_source_test.rb +74 -0
- data/test/new_relic/agent/configuration/manager_test.rb +149 -0
- data/test/new_relic/agent/configuration/server_source_test.rb +45 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +56 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +63 -50
- data/test/new_relic/agent/error_collector_test.rb +22 -12
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +21 -11
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +6 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +5 -5
- data/test/new_relic/agent/method_tracer_test.rb +6 -6
- data/test/new_relic/agent/mock_scope_listener.rb +3 -0
- data/test/new_relic/agent/new_relic_service_test.rb +208 -23
- data/test/new_relic/agent/pipe_channel_manager_test.rb +34 -17
- data/test/new_relic/agent/rpm_agent_test.rb +27 -23
- data/test/new_relic/agent/sql_sampler_test.rb +81 -56
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +3 -20
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +12 -1
- data/test/new_relic/agent/stats_engine_test.rb +17 -8
- data/test/new_relic/agent/thread_profiler_test.rb +536 -0
- data/test/new_relic/agent/thread_test.rb +76 -0
- data/test/new_relic/agent/threaded_test.rb +65 -0
- data/test/new_relic/agent/transaction_info_test.rb +45 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +8 -6
- data/test/new_relic/agent/transaction_sampler_test.rb +193 -204
- data/test/new_relic/agent/worker_loop_test.rb +20 -0
- data/test/new_relic/agent_test.rb +69 -41
- data/test/new_relic/collection_helper_test.rb +7 -8
- data/test/new_relic/command/deployments_test.rb +18 -2
- data/test/new_relic/control/frameworks/rails_test.rb +26 -0
- data/test/new_relic/control/logging_methods_test.rb +78 -52
- data/test/new_relic/control_test.rb +91 -129
- data/test/new_relic/fake_collector.rb +103 -31
- data/test/new_relic/fake_service.rb +8 -2
- data/test/new_relic/load_test.rb +13 -0
- data/test/new_relic/local_environment_test.rb +7 -10
- data/test/new_relic/metric_data_test.rb +45 -16
- data/test/new_relic/noticed_error_test.rb +14 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +15 -9
- data/test/new_relic/rack/developer_mode_test.rb +13 -7
- data/test/new_relic/rack/error_collector_test.rb +74 -0
- data/test/new_relic/transaction_sample/segment_test.rb +23 -4
- data/test/new_relic/transaction_sample_test.rb +47 -2
- data/test/script/build_test_gem.sh +9 -3
- data/test/script/ci.sh +48 -21
- data/test/script/ci_multiverse_runner.sh +11 -11
- data/test/test_helper.rb +37 -18
- data/ui/helpers/developer_mode_helper.rb +21 -11
- data/ui/views/layouts/newrelic_default.rhtml +1 -0
- data/ui/views/newrelic/show_sample.rhtml +1 -1
- data/ui/views/newrelic/threads.rhtml +2 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/.specification +116 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +7 -0
- metadata +132 -58
- data/lib/new_relic/control/configuration.rb +0 -206
- data/test/new_relic/control/configuration_test.rb +0 -77
@@ -10,38 +10,43 @@ module NewRelic
|
|
10
10
|
module Shim #:nodoc:
|
11
11
|
def notice_error(*args); end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# Maximum possible length of the queue - defaults to 20, may be
|
15
15
|
# made configurable in the future. This is a tradeoff between
|
16
16
|
# memory and data retention
|
17
17
|
MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
|
18
18
|
|
19
|
-
attr_accessor :
|
20
|
-
|
21
|
-
|
19
|
+
attr_accessor :errors
|
20
|
+
|
22
21
|
# Returns a new error collector
|
23
22
|
def initialize
|
24
23
|
@errors = []
|
25
24
|
# lookup of exception class names to ignore. Hash for fast access
|
26
25
|
@ignore = {}
|
26
|
+
@capture_source = Agent.config[:'error_collector.capture_source']
|
27
27
|
|
28
|
-
config
|
29
|
-
|
30
|
-
@enabled = @config_enabled = config.fetch('enabled', true)
|
31
|
-
@capture_source = config.fetch('capture_source', true)
|
28
|
+
initialize_ignored_errors(Agent.config[:'error_collector.ignore_errors'])
|
29
|
+
@lock = Mutex.new
|
32
30
|
|
33
|
-
|
31
|
+
Agent.config.register_callback(:'error_collector.enabled') do |config_enabled|
|
32
|
+
log.debug "Errors will #{config_enabled ? '' : 'not '}be sent to the New Relic service."
|
33
|
+
end
|
34
|
+
Agent.config.register_callback(:'error_collector.ignore_errors') do |ignore_errors|
|
35
|
+
initialize_ignored_errors(ignore_errors)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize_ignored_errors(ignore_errors)
|
40
|
+
@ignore.clear
|
34
41
|
ignore_errors = ignore_errors.split(",") if ignore_errors.is_a? String
|
35
42
|
ignore_errors.each { |error| error.strip! }
|
36
43
|
ignore(ignore_errors)
|
37
|
-
@lock = Mutex.new
|
38
44
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
NewRelic::Control.instance
|
45
|
+
|
46
|
+
def enabled?
|
47
|
+
Agent.config[:'error_collector.enabled']
|
43
48
|
end
|
44
|
-
|
49
|
+
|
45
50
|
# Returns the error filter proc that is used to check if an
|
46
51
|
# error should be reported. When given a block, resets the
|
47
52
|
# filter to the provided block. The define_method() is used to
|
@@ -59,45 +64,43 @@ module NewRelic
|
|
59
64
|
# errors is an array of Exception Class Names
|
60
65
|
#
|
61
66
|
def ignore(errors)
|
62
|
-
errors.each
|
67
|
+
errors.each do |error|
|
68
|
+
@ignore[error] = true
|
69
|
+
log.debug("Ignoring errors of type '#{error}'")
|
70
|
+
end
|
63
71
|
end
|
64
|
-
|
72
|
+
|
65
73
|
# This module was extracted from the notice_error method - it is
|
66
74
|
# internally tested and can be refactored without major issues.
|
67
75
|
module NoticeError
|
68
|
-
# Whether the error collector is disabled or not
|
69
|
-
def disabled?
|
70
|
-
!@enabled
|
71
|
-
end
|
72
|
-
|
73
76
|
# Checks the provided error against the error filter, if there
|
74
77
|
# is an error filter
|
75
78
|
def filtered_by_error_filter?(error)
|
76
79
|
return unless @ignore_filter
|
77
80
|
!@ignore_filter.call(error)
|
78
81
|
end
|
79
|
-
|
82
|
+
|
80
83
|
# Checks the array of error names and the error filter against
|
81
84
|
# the provided error
|
82
85
|
def filtered_error?(error)
|
83
86
|
@ignore[error.class.name] || filtered_by_error_filter?(error)
|
84
87
|
end
|
85
|
-
|
88
|
+
|
86
89
|
# an error is ignored if it is nil or if it is filtered
|
87
90
|
def error_is_ignored?(error)
|
88
91
|
error && filtered_error?(error)
|
89
92
|
end
|
90
|
-
|
93
|
+
|
91
94
|
# Increments a statistic that tracks total error rate
|
92
95
|
def increment_error_count!
|
93
96
|
NewRelic::Agent.get_stats("Errors/all").increment_count
|
94
97
|
end
|
95
|
-
|
98
|
+
|
96
99
|
# whether we should return early from the notice_error process
|
97
100
|
# - based on whether the error is ignored or the error
|
98
101
|
# collector is disabled
|
99
102
|
def should_exit_notice_error?(exception)
|
100
|
-
if
|
103
|
+
if enabled?
|
101
104
|
if !error_is_ignored?(exception)
|
102
105
|
increment_error_count!
|
103
106
|
return exception.nil? # exit early if the exception is nil
|
@@ -106,40 +109,40 @@ module NewRelic
|
|
106
109
|
# disabled or an ignored error, per above
|
107
110
|
true
|
108
111
|
end
|
109
|
-
|
112
|
+
|
110
113
|
# acts just like Hash#fetch, but deletes the key from the hash
|
111
114
|
def fetch_from_options(options, key, default=nil)
|
112
115
|
options.delete(key) || default
|
113
116
|
end
|
114
|
-
|
117
|
+
|
115
118
|
# returns some basic option defaults pulled from the provided
|
116
119
|
# options hash
|
117
120
|
def uri_ref_and_root(options)
|
118
121
|
{
|
119
122
|
:request_uri => fetch_from_options(options, :uri, ''),
|
120
123
|
:request_referer => fetch_from_options(options, :referer, ''),
|
121
|
-
:rails_root =>
|
124
|
+
:rails_root => NewRelic::Control.instance.root
|
122
125
|
}
|
123
126
|
end
|
124
|
-
|
127
|
+
|
125
128
|
# If anything else is left over, we treat it like a custom param
|
126
129
|
def custom_params_from_opts(options)
|
127
130
|
# If anything else is left over, treat it like a custom param:
|
128
131
|
fetch_from_options(options, :custom_params, {}).merge(options)
|
129
132
|
end
|
130
|
-
|
133
|
+
|
131
134
|
# takes the request parameters out of the options hash, and
|
132
135
|
# returns them if we are capturing parameters, otherwise
|
133
136
|
# returns nil
|
134
137
|
def request_params_from_opts(options)
|
135
138
|
value = options.delete(:request_params)
|
136
|
-
if
|
139
|
+
if Agent.config[:capture_params]
|
137
140
|
value
|
138
141
|
else
|
139
142
|
nil
|
140
143
|
end
|
141
144
|
end
|
142
|
-
|
145
|
+
|
143
146
|
# normalizes the request and custom parameters before attaching
|
144
147
|
# them to the error. See NewRelic::CollectionHelper#normalize_params
|
145
148
|
def normalized_request_and_custom_params(options)
|
@@ -148,32 +151,32 @@ module NewRelic
|
|
148
151
|
:custom_params => normalize_params(custom_params_from_opts(options))
|
149
152
|
}
|
150
153
|
end
|
151
|
-
|
154
|
+
|
152
155
|
# Merges together many of the options into something that can
|
153
156
|
# actually be attached to the error
|
154
157
|
def error_params_from_options(options)
|
155
158
|
uri_ref_and_root(options).merge(normalized_request_and_custom_params(options))
|
156
159
|
end
|
157
|
-
|
160
|
+
|
158
161
|
# calls a method on an object, if it responds to it - used for
|
159
162
|
# detection and soft fail-safe. Returns nil if the method does
|
160
163
|
# not exist
|
161
164
|
def sense_method(object, method)
|
162
165
|
object.send(method) if object.respond_to?(method)
|
163
166
|
end
|
164
|
-
|
167
|
+
|
165
168
|
# extracts source from the exception, if the exception supports
|
166
169
|
# that method
|
167
170
|
def extract_source(exception)
|
168
171
|
sense_method(exception, 'source_extract') if @capture_source
|
169
172
|
end
|
170
|
-
|
173
|
+
|
171
174
|
# extracts a stack trace from the exception for debugging purposes
|
172
175
|
def extract_stack_trace(exception)
|
173
176
|
actual_exception = sense_method(exception, 'original_exception') || exception
|
174
177
|
sense_method(actual_exception, 'backtrace') || '<no stack trace>'
|
175
178
|
end
|
176
|
-
|
179
|
+
|
177
180
|
# extracts a bunch of information from the exception to include
|
178
181
|
# in the noticed error - some may or may not be available, but
|
179
182
|
# we try to include all of it
|
@@ -185,7 +188,7 @@ module NewRelic
|
|
185
188
|
:stack_trace => extract_stack_trace(exception)
|
186
189
|
}
|
187
190
|
end
|
188
|
-
|
191
|
+
|
189
192
|
# checks the size of the error queue to make sure we are under
|
190
193
|
# the maximum limit, and logs a warning if we are over the limit.
|
191
194
|
def over_queue_limit?(message)
|
@@ -194,13 +197,14 @@ module NewRelic
|
|
194
197
|
over_limit
|
195
198
|
end
|
196
199
|
|
197
|
-
|
198
200
|
# Synchronizes adding an error to the error queue, and checks if
|
199
201
|
# the error queue is too long - if so, we drop the error on the
|
200
202
|
# floor after logging a warning.
|
201
203
|
def add_to_error_queue(noticed_error)
|
202
204
|
@lock.synchronize do
|
203
|
-
|
205
|
+
if !over_queue_limit?(noticed_error.message) && !@errors.include?(noticed_error)
|
206
|
+
@errors << noticed_error
|
207
|
+
end
|
204
208
|
end
|
205
209
|
end
|
206
210
|
end
|
@@ -224,7 +228,7 @@ module NewRelic
|
|
224
228
|
add_to_error_queue(NewRelic::NoticedError.new(action_path, exception_options, exception))
|
225
229
|
exception
|
226
230
|
rescue => e
|
227
|
-
log.error("Error capturing an error
|
231
|
+
log.error("Error capturing an error #{e}")
|
228
232
|
end
|
229
233
|
|
230
234
|
# Get the errors currently queued up. Unsent errors are left
|
@@ -100,11 +100,7 @@ DependencyDetection.defer do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
depends_on do
|
103
|
-
!NewRelic::
|
104
|
-
end
|
105
|
-
|
106
|
-
depends_on do
|
107
|
-
!NewRelic::Control.instance['disable_activerecord_instrumentation']
|
103
|
+
!NewRelic::Agent.config[:disable_activerecord_instrumentation]
|
108
104
|
end
|
109
105
|
|
110
106
|
executes do
|
@@ -26,6 +26,7 @@ module NewRelic
|
|
26
26
|
module ClassMethodsShim # :nodoc:
|
27
27
|
def newrelic_ignore(*args); end
|
28
28
|
def newrelic_ignore_apdex(*args); end
|
29
|
+
def newrelic_ignore_enduser(*args); end
|
29
30
|
end
|
30
31
|
|
31
32
|
module Shim # :nodoc:
|
@@ -51,6 +52,10 @@ module NewRelic
|
|
51
52
|
newrelic_ignore_aspect('ignore_apdex', specifiers)
|
52
53
|
end
|
53
54
|
|
55
|
+
def newrelic_ignore_enduser(specifiers={})
|
56
|
+
newrelic_ignore_aspect('ignore_enduser', specifiers)
|
57
|
+
end
|
58
|
+
|
54
59
|
def newrelic_ignore_aspect(property, specifiers={}) # :nodoc:
|
55
60
|
if specifiers.empty?
|
56
61
|
self.newrelic_write_attr property, true
|
@@ -139,6 +144,7 @@ module NewRelic
|
|
139
144
|
options_arg << %Q[:#{key} => #{valuestr}]
|
140
145
|
end
|
141
146
|
traced_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
|
147
|
+
visibility = NewRelic::Helper.instance_method_visibility self, method
|
142
148
|
|
143
149
|
class_eval <<-EOC
|
144
150
|
def #{traced_method.to_s}_with_newrelic_transaction_trace#{punctuation}(*args, &block)
|
@@ -147,8 +153,12 @@ module NewRelic
|
|
147
153
|
end
|
148
154
|
end
|
149
155
|
EOC
|
150
|
-
|
151
|
-
|
156
|
+
without_method_name = "#{traced_method.to_s}_without_newrelic_transaction_trace#{punctuation}"
|
157
|
+
with_method_name = "#{traced_method.to_s}_with_newrelic_transaction_trace#{punctuation}"
|
158
|
+
alias_method without_method_name, method.to_s
|
159
|
+
alias_method method.to_s, with_method_name
|
160
|
+
send visibility, method
|
161
|
+
send visibility, with_method_name
|
152
162
|
NewRelic::Control.instance.log.debug("Traced transaction: class = #{self.name}, method = #{method.to_s}, options = #{options.inspect}")
|
153
163
|
end
|
154
164
|
end
|
@@ -244,8 +254,9 @@ module NewRelic
|
|
244
254
|
return perform_action_without_newrelic_trace(*args)
|
245
255
|
end
|
246
256
|
end
|
247
|
-
|
248
|
-
|
257
|
+
|
258
|
+
control = NewRelic::Control.instance
|
259
|
+
return perform_action_with_newrelic_profile(args, &block) if control.profiling?
|
249
260
|
|
250
261
|
frame_data = _push_metric_frame(block_given? ? args : [])
|
251
262
|
begin
|
@@ -253,11 +264,16 @@ module NewRelic
|
|
253
264
|
frame_data.start_transaction
|
254
265
|
begin
|
255
266
|
NewRelic::Agent::BusyCalculator.dispatcher_start frame_data.start
|
256
|
-
if block_given?
|
267
|
+
result = if block_given?
|
257
268
|
yield
|
258
269
|
else
|
259
270
|
perform_action_without_newrelic_trace(*args)
|
260
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)
|
275
|
+
end
|
276
|
+
result
|
261
277
|
rescue => e
|
262
278
|
frame_data.notice_error(e)
|
263
279
|
raise
|
@@ -268,8 +284,9 @@ module NewRelic
|
|
268
284
|
# Look for a metric frame in the thread local and process it.
|
269
285
|
# Clear the thread local when finished to ensure it only gets called once.
|
270
286
|
frame_data.record_apdex unless ignore_apdex?
|
271
|
-
|
272
287
|
frame_data.pop
|
288
|
+
|
289
|
+
NewRelic::Agent::TransactionInfo.get.ignore_end_user = true if ignore_enduser?
|
273
290
|
end
|
274
291
|
end
|
275
292
|
|
@@ -311,6 +328,10 @@ module NewRelic
|
|
311
328
|
def ignore_apdex?
|
312
329
|
_is_filtered?('ignore_apdex')
|
313
330
|
end
|
331
|
+
|
332
|
+
def ignore_enduser?
|
333
|
+
_is_filtered?('ignore_enduser')
|
334
|
+
end
|
314
335
|
|
315
336
|
private
|
316
337
|
|
@@ -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
|
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
|
-
|
211
|
+
super
|
220
212
|
end
|
221
213
|
|
222
214
|
end # DataMapperInstrumentation
|
@@ -32,7 +32,7 @@ module NewRelic
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
def memcache_key_snippet(method_name)
|
35
|
-
return "" unless NewRelic::
|
35
|
+
return "" unless NewRelic::Agent.config[:capture_memcache_keys]
|
36
36
|
"NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil"
|
37
37
|
end
|
38
38
|
end
|
@@ -44,7 +44,7 @@ DependencyDetection.defer do
|
|
44
44
|
@name = :memcache
|
45
45
|
|
46
46
|
depends_on do
|
47
|
-
!NewRelic::
|
47
|
+
!NewRelic::Agent.config[:disable_memcache_instrumentation]
|
48
48
|
end
|
49
49
|
|
50
50
|
depends_on do
|
@@ -27,21 +27,11 @@ 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
|
34
30
|
# Return the currently active metric frame, or nil. Call with +true+
|
35
31
|
# to create a new metric frame if one is not already on the thread.
|
36
32
|
def self.current(create_if_empty=nil)
|
37
33
|
f = Thread.current[:newrelic_metric_frame]
|
38
34
|
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
|
-
|
45
35
|
Thread.current[:newrelic_metric_frame] = new
|
46
36
|
end
|
47
37
|
|
@@ -64,8 +54,8 @@ module NewRelic
|
|
64
54
|
if defined? JRuby
|
65
55
|
begin
|
66
56
|
require 'java'
|
67
|
-
|
68
|
-
|
57
|
+
java_import 'java.lang.management.ManagementFactory'
|
58
|
+
java_import 'com.sun.management.OperatingSystemMXBean'
|
69
59
|
@@java_classes_loaded = true
|
70
60
|
rescue => e
|
71
61
|
end
|
@@ -263,7 +253,7 @@ module NewRelic
|
|
263
253
|
end
|
264
254
|
|
265
255
|
def queue_time
|
266
|
-
|
256
|
+
start - apdex_start
|
267
257
|
end
|
268
258
|
|
269
259
|
def add_custom_parameters(p)
|
@@ -320,7 +310,7 @@ module NewRelic
|
|
320
310
|
# the apdex should be recorded as a failure regardless of duration.
|
321
311
|
def self.update_apdex(stat, duration, failed)
|
322
312
|
duration = duration.to_f
|
323
|
-
apdex_t =
|
313
|
+
apdex_t = Agent.config[:apdex_t]
|
324
314
|
case
|
325
315
|
when failed
|
326
316
|
stat.record_apdex_f
|
@@ -1,19 +1,19 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
2
|
@name = :passenger
|
3
|
-
|
3
|
+
|
4
4
|
depends_on do
|
5
|
-
defined?(PhusionPassenger)
|
5
|
+
defined?(::PhusionPassenger)
|
6
6
|
end
|
7
7
|
|
8
8
|
executes do
|
9
9
|
NewRelic::Agent.logger.debug "Installing Passenger event hooks."
|
10
10
|
|
11
|
-
PhusionPassenger.on_event(:stopping_worker_process) do
|
11
|
+
::PhusionPassenger.on_event(:stopping_worker_process) do
|
12
12
|
NewRelic::Agent.logger.debug "Passenger stopping this process, shutdown the agent."
|
13
13
|
NewRelic::Agent.instance.shutdown
|
14
14
|
end
|
15
15
|
|
16
|
-
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
16
|
+
::PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
17
17
|
# We want to reset the stats from the stats engine in case any carried
|
18
18
|
# over into the spawned process. Don't clear them in case any were
|
19
19
|
# cached. We do this even in conservative spawning.
|
@@ -21,17 +21,3 @@ 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) || defined?(::IN_PHUSION_PASSENGER)
|
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
|