newrelic_rpm 3.6.5.130 → 3.6.6.147
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -3
- data/Gemfile +1 -14
- data/Rakefile +15 -5
- data/config.dot +1 -1
- data/lib/new_relic/agent/agent.rb +15 -0
- data/lib/new_relic/agent/agent_logger.rb +19 -14
- data/lib/new_relic/agent/configuration/defaults.rb +4 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +6 -4
- data/lib/new_relic/agent/configuration/manager.rb +7 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +5 -4
- data/lib/new_relic/agent/cross_app_tracing.rb +0 -1
- data/lib/new_relic/agent/error_collector.rb +30 -1
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +67 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +59 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/authlogic.rb +3 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +179 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +35 -26
- data/lib/new_relic/agent/instrumentation/httpclient.rb +46 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/puma.rb +23 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +40 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +18 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -8
- data/lib/new_relic/agent/request_sampler.rb +4 -6
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +0 -1
- data/lib/new_relic/agent/stats.rb +9 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +44 -6
- data/lib/new_relic/agent/system_info.rb +1 -1
- data/lib/new_relic/agent/thread_profiler.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +1 -1
- data/lib/new_relic/agent/transaction_info.rb +0 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +6 -5
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +6 -0
- data/lib/new_relic/commands/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -2
- data/lib/new_relic/control/instrumentation.rb +2 -2
- data/lib/new_relic/control/server_methods.rb +1 -2
- data/lib/new_relic/delayed_job_injection.rb +0 -40
- data/lib/new_relic/helper.rb +0 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +9 -4
- data/lib/new_relic/metric_spec.rb +19 -3
- data/lib/new_relic/noticed_error.rb +2 -1
- data/lib/new_relic/rack/agent_hooks.rb +0 -1
- data/lib/new_relic/rack/developer_mode.rb +1 -1
- data/lib/new_relic/rack/error_collector.rb +42 -21
- data/lib/new_relic/recipes.rb +0 -1
- data/lib/new_relic/transaction_analysis.rb +0 -1
- data/lib/new_relic/transaction_sample/segment.rb +4 -4
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +6 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +0 -1
- data/lib/tasks/install.rake +2 -2
- data/newrelic_rpm.gemspec +11 -1
- data/test/active_record_fixtures.rb +2 -2
- data/test/agent_helper.rb +46 -3
- data/test/config/newrelic.yml +2 -2
- data/test/multiverse/.gitignore +2 -0
- data/test/multiverse/lib/multiverse/envfile.rb +6 -9
- data/test/multiverse/lib/multiverse/environment.rb +0 -1
- data/test/multiverse/lib/multiverse/output_collector.rb +43 -11
- data/test/multiverse/lib/multiverse/runner.rb +37 -5
- data/test/multiverse/lib/multiverse/suite.rb +149 -67
- data/test/multiverse/script/run_one +4 -2
- data/test/multiverse/script/runner +1 -5
- data/test/multiverse/suites/active_record/Envfile +3 -2
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +13 -12
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -3
- data/test/multiverse/suites/agent_only/audit_log_test.rb +30 -34
- data/test/multiverse/suites/agent_only/before_suite.rb +7 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -7
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +12 -20
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +16 -34
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +18 -28
- data/test/multiverse/suites/agent_only/logging_test.rb +25 -49
- data/test/multiverse/suites/agent_only/marshaling_test.rb +30 -38
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +12 -6
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +30 -38
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +16 -18
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +6 -7
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +26 -32
- data/test/multiverse/suites/agent_only/ssl_test.rb +10 -14
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +2 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +23 -24
- data/test/multiverse/suites/config_file_loading/Envfile +6 -2
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +8 -4
- data/test/multiverse/suites/curb/Envfile +19 -0
- data/test/multiverse/suites/curb/config/newrelic.yml +19 -0
- data/test/multiverse/suites/curb/curb_test.rb +195 -0
- data/test/multiverse/suites/datamapper/Envfile +2 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +6 -10
- data/test/multiverse/suites/deferred_instrumentation/Envfile +19 -0
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +22 -0
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +103 -0
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -2
- data/test/multiverse/suites/excon/excon_test.rb +3 -3
- data/test/multiverse/suites/httpclient/Envfile +15 -0
- data/test/multiverse/suites/httpclient/config/newrelic.yml +19 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +70 -0
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +9 -4
- data/test/multiverse/suites/padrino/Envfile +2 -0
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -3
- data/test/multiverse/suites/padrino/padrino_test.rb +5 -4
- data/test/multiverse/suites/rails/Envfile +3 -0
- data/test/multiverse/suites/rails/app.rb +1 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +31 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +2 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +32 -41
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +6 -16
- data/test/multiverse/suites/rails/queue_time_test.rb +4 -20
- data/test/multiverse/suites/rails/request_statistics_test.rb +7 -32
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -10
- data/test/multiverse/suites/resque/config/newrelic.yml +1 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sequel/Envfile +8 -0
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sequel/sequel_test.rb +1 -2
- data/test/multiverse/suites/sidekiq/Envfile +0 -12
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +1 -3
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +44 -100
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sinatra/ignoring_test.rb +8 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +8 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +9 -12
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +9 -8
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +6 -5
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +10 -13
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +7 -4
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +0 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +0 -1
- data/test/new_relic/agent/agent_logger_test.rb +37 -3
- data/test/new_relic/agent/agent_test.rb +23 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -2
- data/test/new_relic/agent/configuration/environment_source_test.rb +22 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +95 -13
- data/test/new_relic/agent/event_listener_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +23 -0
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +4 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +16 -11
- data/test/new_relic/agent/instrumentation/rack_test.rb +0 -1
- data/test/new_relic/agent/memcache_instrumentation_test.rb +7 -7
- data/test/{multiverse/suites/agent_only/test_trace_method_with_punctuation.rb → new_relic/agent/method_interrobang_test.rb} +3 -5
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -2
- data/test/{multiverse/suites/agent_only → new_relic/agent}/method_visibility_test.rb +17 -29
- data/test/new_relic/agent/new_relic_service_test.rb +1 -1
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +10 -10
- data/test/new_relic/agent/rpm_agent_test.rb +1 -2
- data/test/new_relic/agent/stats_hash_test.rb +83 -5
- data/test/new_relic/agent/stats_test.rb +0 -1
- data/test/new_relic/agent/thread_profiler_test.rb +7 -7
- data/test/new_relic/agent/threaded_test.rb +1 -2
- data/test/new_relic/agent/transaction/pop_test.rb +0 -1
- data/test/{multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb → new_relic/agent/transaction_interrobang_test.rb} +2 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +13 -0
- data/test/new_relic/agent/transaction_test.rb +7 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -1
- data/test/new_relic/agent_test.rb +0 -27
- data/test/new_relic/collection_helper_test.rb +17 -17
- data/test/new_relic/control/class_methods_test.rb +1 -1
- data/test/new_relic/control_test.rb +6 -6
- data/test/new_relic/dependency_detection_test.rb +28 -0
- data/test/new_relic/evil_server.rb +0 -1
- data/test/new_relic/fake_collector.rb +20 -2
- data/test/new_relic/fake_server.rb +0 -12
- data/test/new_relic/http_client_test_cases.rb +20 -24
- data/test/new_relic/metric_spec_test.rb +18 -0
- data/test/new_relic/multiverse_helpers.rb +164 -0
- data/test/new_relic/rack/agent_hooks_test.rb +0 -1
- data/test/new_relic/rack/all_test.rb +0 -1
- data/test/new_relic/rack/deferred_instrumentation_test.rb +35 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +8 -9
- data/test/new_relic/rack/developer_mode_test.rb +0 -2
- data/test/new_relic/rack/error_collector_test.rb +52 -8
- data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -1
- data/test/performance/README.md +162 -0
- data/test/performance/lib/performance.rb +28 -0
- data/test/performance/lib/performance/console_reporter.rb +51 -0
- data/test/performance/lib/performance/hako_client.rb +31 -0
- data/test/performance/lib/performance/hako_reporter.rb +26 -0
- data/test/performance/lib/performance/instrumentation/cpu_usage.rb +26 -0
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +53 -0
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +30 -0
- data/test/performance/lib/performance/instrumentor.rb +110 -0
- data/test/performance/lib/performance/json_reporter.rb +15 -0
- data/test/performance/lib/performance/result.rb +80 -0
- data/test/performance/lib/performance/runner.rb +207 -0
- data/test/performance/lib/performance/test_case.rb +65 -0
- data/test/performance/lib/performance/timer.rb +38 -0
- data/test/performance/script/mega-runner +37 -0
- data/test/performance/script/runner +81 -0
- data/test/performance/suites/startup.rb +12 -0
- data/test/performance/suites/transaction_tracing.rb +66 -0
- data/test/script/ci_agent-tests_runner.sh +4 -4
- data/test/script/ci_multiverse_runner.sh +3 -3
- data/test/test_helper.rb +0 -11
- data/ui/helpers/developer_mode_helper.rb +1 -1
- data/ui/views/layouts/newrelic_default.rhtml +1 -1
- data/ui/views/newrelic/_segment.rhtml +2 -2
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_detail.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_sql.rhtml +4 -4
- data/ui/views/newrelic/_stack_trace.rhtml +2 -2
- data/ui/views/newrelic/file/javascript/transaction_sample.js +3 -3
- data/ui/views/newrelic/file/stylesheets/style.css +13 -13
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +18 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -1
- metadata +186 -17
- metadata.gz.sig +0 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +0 -30
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +0 -21
- data/test/multiverse/suites/sidekiq/app.rb +0 -25
- data/test/new_relic/delayed_job_injection_test.rb +0 -25
@@ -2,49 +2,9 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
require 'dependency_detection'
|
6
|
-
# This installs some code to manually start the agent when a delayed
|
7
|
-
# job worker starts. It's not really instrumentation. It's more like
|
8
|
-
# a hook from DJ to the Ruby Agent so it gets loaded at the time the
|
9
|
-
# Ruby Agent initializes, which must be before the DJ worker
|
10
|
-
# initializes. Loaded from control.rb
|
11
5
|
module NewRelic
|
12
6
|
module DelayedJobInjection
|
13
7
|
extend self
|
14
8
|
attr_accessor :worker_name
|
15
9
|
end
|
16
10
|
end
|
17
|
-
|
18
|
-
DependencyDetection.defer do
|
19
|
-
@name = :delayed_job_injection
|
20
|
-
|
21
|
-
depends_on do
|
22
|
-
defined?(::Delayed) && defined?(::Delayed::Worker) && !NewRelic::Agent.config[:disable_dj]
|
23
|
-
end
|
24
|
-
|
25
|
-
executes do
|
26
|
-
if NewRelic::Agent.respond_to?(:logger)
|
27
|
-
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation hooks'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
executes do
|
32
|
-
Delayed::Worker.class_eval do
|
33
|
-
def initialize_with_new_relic(*args)
|
34
|
-
initialize_without_new_relic(*args)
|
35
|
-
worker_name = case
|
36
|
-
when self.respond_to?(:name) then self.name
|
37
|
-
when self.class.respond_to?(:default_name) then self.class.default_name
|
38
|
-
end
|
39
|
-
dispatcher_instance_id = worker_name || "host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}"
|
40
|
-
say "New Relic Ruby Agent Monitoring DJ worker #{dispatcher_instance_id}"
|
41
|
-
NewRelic::DelayedJobInjection.worker_name = worker_name
|
42
|
-
NewRelic::Control.instance.init_plugin :dispatcher => :delayed_job, :dispatcher_instance_id => dispatcher_instance_id
|
43
|
-
NewRelic::Agent.instance.add_harvest_sampler(NewRelic::Agent::Samplers::DelayedJobSampler)
|
44
|
-
end
|
45
|
-
|
46
|
-
alias initialize_without_new_relic initialize
|
47
|
-
alias initialize initialize_with_new_relic
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/new_relic/helper.rb
CHANGED
@@ -75,7 +75,7 @@ module NewRelic
|
|
75
75
|
# Although you can override the dispatcher with NEWRELIC_DISPATCHER this
|
76
76
|
# is not advisable since it implies certain api's being available.
|
77
77
|
def discover_dispatcher
|
78
|
-
dispatchers = %w[passenger torquebox trinidad glassfish resque sidekiq thin mongrel litespeed webrick fastcgi rainbows unicorn]
|
78
|
+
dispatchers = %w[passenger torquebox trinidad glassfish resque sidekiq delayed_job thin mongrel litespeed webrick fastcgi rainbows unicorn]
|
79
79
|
while dispatchers.any? && @discovered_dispatcher.nil?
|
80
80
|
send 'check_for_'+(dispatchers.shift)
|
81
81
|
end
|
@@ -101,8 +101,7 @@ module NewRelic
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def jruby_rack?
|
104
|
-
(
|
105
|
-
defined?(org::jruby::rack::DefaultRackApplicationFactory))
|
104
|
+
defined?(JRuby::Rack::VERSION)
|
106
105
|
end
|
107
106
|
|
108
107
|
def check_for_webrick
|
@@ -147,7 +146,7 @@ module NewRelic
|
|
147
146
|
def check_for_unicorn
|
148
147
|
if (defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) && NewRelic::LanguageSupport.object_space_enabled?
|
149
148
|
v = find_class_in_object_space(::Unicorn::HttpServer)
|
150
|
-
@discovered_dispatcher = :unicorn if v
|
149
|
+
@discovered_dispatcher = :unicorn if v
|
151
150
|
end
|
152
151
|
end
|
153
152
|
|
@@ -158,6 +157,12 @@ module NewRelic
|
|
158
157
|
end
|
159
158
|
end
|
160
159
|
|
160
|
+
def check_for_delayed_job
|
161
|
+
if $0 =~ /delayed_job$/
|
162
|
+
@discovered_dispatcher = :delayed_job
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
161
166
|
def check_for_resque
|
162
167
|
using_resque = (
|
163
168
|
defined?(::Resque) &&
|
@@ -2,12 +2,14 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'new_relic/agent/internal_agent_error'
|
6
|
+
|
5
7
|
# this struct uniquely defines a metric, optionally inside
|
6
8
|
# the call scope of another metric
|
7
9
|
class NewRelic::MetricSpec
|
8
10
|
attr_accessor :name
|
9
11
|
attr_accessor :scope
|
10
|
-
|
12
|
+
|
11
13
|
# the maximum length of a metric name or metric scope
|
12
14
|
MAX_LENGTH = 255
|
13
15
|
LENGTH_RANGE = (0...MAX_LENGTH)
|
@@ -22,13 +24,27 @@ class NewRelic::MetricSpec
|
|
22
24
|
self.scope = ''
|
23
25
|
end
|
24
26
|
end
|
25
|
-
|
27
|
+
|
28
|
+
class InvalidScopeSettingError < NewRelic::Agent::InternalAgentError
|
29
|
+
def initialize(name, scope)
|
30
|
+
super("Attempted to set scope for #{name} to #{scope.inspect}, ignoring.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def scope=(s)
|
35
|
+
if s.nil? || s == false
|
36
|
+
NewRelic::Agent.instance.error_collector.notice_agent_error(InvalidScopeSettingError.new(@name, s))
|
37
|
+
else
|
38
|
+
@scope = s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
26
42
|
# truncates the name and scope to the MAX_LENGTH
|
27
43
|
def truncate!
|
28
44
|
self.name = name[LENGTH_RANGE] if name && name.size > MAX_LENGTH
|
29
45
|
self.scope = scope[LENGTH_RANGE] if scope && scope.size > MAX_LENGTH
|
30
46
|
end
|
31
|
-
|
47
|
+
|
32
48
|
def ==(o)
|
33
49
|
self.eql?(o)
|
34
50
|
end
|
@@ -7,7 +7,8 @@ require 'new_relic/helper'
|
|
7
7
|
# This class encapsulates an error that was noticed by New Relic in a managed app.
|
8
8
|
class NewRelic::NoticedError
|
9
9
|
extend NewRelic::CollectionHelper
|
10
|
-
attr_accessor :path, :timestamp, :params, :
|
10
|
+
attr_accessor :path, :timestamp, :params, :message,
|
11
|
+
:exception_class_name, :exception_class_constant
|
11
12
|
attr_reader :exception_id
|
12
13
|
|
13
14
|
STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE = "Message removed by New Relic 'strip_exception_messages' setting"
|
@@ -8,40 +8,61 @@ module NewRelic::Rack
|
|
8
8
|
@app = app
|
9
9
|
end
|
10
10
|
|
11
|
+
def params_from_env(env)
|
12
|
+
if defined?(ActionDispatch::Request)
|
13
|
+
# We use ActionDispatch::Request if it's available so that we can get
|
14
|
+
# the parameter filtering supplied by Rails via filtered_parameters.
|
15
|
+
# The action and controller params are synthesized by
|
16
|
+
# ActionDispatch::Request, so we strip them for consistency with Rack::Request
|
17
|
+
params = ActionDispatch::Request.new(env).filtered_parameters
|
18
|
+
params.delete('action')
|
19
|
+
params.delete('controller')
|
20
|
+
params
|
21
|
+
else
|
22
|
+
Rack::Request.new(env).params
|
23
|
+
end
|
24
|
+
rescue => e
|
25
|
+
warning = "failed to capture request parameters: %p: %s" % [ e.class, e.message ]
|
26
|
+
NewRelic::Agent.logger.warn(warning)
|
27
|
+
{ 'error' => warning }
|
28
|
+
end
|
29
|
+
|
30
|
+
def strip_query_string(s)
|
31
|
+
s.gsub(/\?.*/, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
def uri_from_env(env)
|
35
|
+
strip_query_string("#{env['SCRIPT_NAME']}#{env['PATH_INFO']}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def referrer_from_env(env)
|
39
|
+
strip_query_string(env['HTTP_REFERER'].to_s)
|
40
|
+
end
|
41
|
+
|
11
42
|
def call(env)
|
12
43
|
@app.call(env)
|
13
44
|
rescue Exception => exception
|
14
45
|
NewRelic::Agent.logger.debug "collecting %p: %s" % [ exception.class, exception.message ]
|
15
|
-
|
16
|
-
|
17
|
-
if !should_ignore_error?(exception, request)
|
18
|
-
params = begin
|
19
|
-
request.params
|
20
|
-
rescue => err
|
21
|
-
warning = "failed to capture request parameters: %p: %s" % [ err.class, err.message ]
|
22
|
-
NewRelic::Agent.logger.warn(warning)
|
23
|
-
{'error' => warning}
|
24
|
-
end
|
25
|
-
|
46
|
+
if !should_ignore_error?(exception, env)
|
26
47
|
NewRelic::Agent.notice_error(exception,
|
27
|
-
|
28
|
-
|
29
|
-
|
48
|
+
:uri => uri_from_env(env),
|
49
|
+
:referer => referrer_from_env(env),
|
50
|
+
:request_params => params_from_env(env))
|
30
51
|
end
|
31
52
|
raise exception
|
32
53
|
end
|
33
54
|
|
34
|
-
def should_ignore_error?(error,
|
55
|
+
def should_ignore_error?(error, env)
|
35
56
|
NewRelic::Agent.instance.error_collector.error_is_ignored?(error) ||
|
36
|
-
ignored_in_controller?(error,
|
57
|
+
ignored_in_controller?(error, env)
|
37
58
|
end
|
38
59
|
|
39
|
-
def ignored_in_controller?(exception,
|
40
|
-
return true if
|
60
|
+
def ignored_in_controller?(exception, env)
|
61
|
+
return true if env['newrelic.ignored']
|
41
62
|
|
42
|
-
if
|
43
|
-
ignore_actions = newrelic_ignore_for_controller(
|
44
|
-
action_name =
|
63
|
+
if env['action_dispatch.request.parameters']
|
64
|
+
ignore_actions = newrelic_ignore_for_controller(env['action_dispatch.request.parameters']['controller'])
|
65
|
+
action_name = env['action_dispatch.request.parameters']['action']
|
45
66
|
|
46
67
|
case ignore_actions
|
47
68
|
when nil; false
|
data/lib/new_relic/recipes.rb
CHANGED
@@ -124,6 +124,10 @@ module NewRelic
|
|
124
124
|
@params ||= {}
|
125
125
|
end
|
126
126
|
|
127
|
+
def params=(p)
|
128
|
+
@params = p
|
129
|
+
end
|
130
|
+
|
127
131
|
# call the provided block for this segment and each
|
128
132
|
# of the called segments
|
129
133
|
def each_segment(&block)
|
@@ -176,10 +180,6 @@ module NewRelic
|
|
176
180
|
NewRelic::Agent::Database.obfuscate_sql(params[:sql])
|
177
181
|
end
|
178
182
|
|
179
|
-
def params=(p)
|
180
|
-
@params = p
|
181
|
-
end
|
182
|
-
|
183
183
|
def called_segments=(segments)
|
184
184
|
@called_segments = segments
|
185
185
|
end
|
data/lib/new_relic/version.rb
CHANGED
@@ -15,20 +15,20 @@ module Sequel
|
|
15
15
|
# be instrumented, but if you're using a version of Sequel before 3.47.0,
|
16
16
|
# you'll need to add the extension yourself if you create any after the
|
17
17
|
# instrumentation is loaded:
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# db = Sequel.connect( ... )
|
20
20
|
# db.extension :newrelic_instrumentation
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# Versions 3.47.0 and later use `Database.extension` to automatically
|
23
23
|
# install the extension for new connections.
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# == Disabling
|
26
|
-
#
|
26
|
+
#
|
27
27
|
# If you don't want your models or database connections to be instrumented,
|
28
28
|
# you can disable them by setting `disable_database_instrumentation` in
|
29
|
-
# your `newrelic.yml` to `true`. It will also honor the
|
29
|
+
# your `newrelic.yml` to `true`. It will also honor the
|
30
30
|
# `disable_activerecord_instrumentation` setting.
|
31
|
-
#
|
31
|
+
#
|
32
32
|
module NewRelicInstrumentation
|
33
33
|
include NewRelic::Agent::MethodTracer,
|
34
34
|
NewRelic::Agent::Instrumentation::ActiveRecordHelper
|
@@ -100,4 +100,3 @@ module Sequel
|
|
100
100
|
Database.register_extension( :newrelic_instrumentation, NewRelicInstrumentation )
|
101
101
|
|
102
102
|
end # module Sequel
|
103
|
-
|
data/lib/tasks/install.rake
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
namespace :newrelic do
|
3
3
|
desc "install a default config/newrelic.yml file"
|
4
4
|
task :install do
|
5
|
-
load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
|
5
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
data/newrelic_rpm.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem or plugin, hosted on
|
|
20
20
|
http://github.com/newrelic/rpm/
|
21
21
|
EOS
|
22
22
|
s.email = "support@newrelic.com"
|
23
|
-
s.executables = [ "mongrel_rpm", "newrelic_cmd", "newrelic" ]
|
23
|
+
s.executables = [ "mongrel_rpm", "newrelic_cmd", "newrelic", "nrdebug" ]
|
24
24
|
s.extra_rdoc_files = [
|
25
25
|
"CHANGELOG",
|
26
26
|
"LICENSE",
|
@@ -40,6 +40,16 @@ EOS
|
|
40
40
|
s.rubygems_version = Gem::VERSION
|
41
41
|
s.summary = "New Relic Ruby Agent"
|
42
42
|
s.post_install_message = NewRelic::LatestChanges.read
|
43
|
+
s.add_development_dependency 'rake', '10.1.0'
|
44
|
+
s.add_development_dependency 'minitest', '~> 4.7.5'
|
45
|
+
s.add_development_dependency 'mocha', '~> 0.13.0'
|
46
|
+
s.add_development_dependency 'sdoc-helpers'
|
47
|
+
s.add_development_dependency 'rdoc', '>= 2.4.2'
|
48
|
+
s.add_development_dependency 'rails', '~> 3.2.13'
|
49
|
+
s.add_development_dependency 'sqlite3' unless RUBY_PLATFORM == 'java'
|
50
|
+
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter' if RUBY_PLATFORM == 'java'
|
51
|
+
s.add_development_dependency 'jruby-openssl' if RUBY_PLATFORM == 'java'
|
52
|
+
s.add_development_dependency 'sequel', '~> 3.46.0'
|
43
53
|
|
44
54
|
# Only sign with our private key if you can find it
|
45
55
|
signing_key_path = File.expand_path('~/.ssh/newrelic_rpm-private_key.pem')
|
@@ -37,7 +37,7 @@ module ActiveRecordFixtures
|
|
37
37
|
rescue => e
|
38
38
|
false
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def self.add_delay
|
42
42
|
# Introduce a 5 ms delay into db operations on Orders
|
43
43
|
def connection.log_info *args
|
@@ -74,7 +74,7 @@ module ActiveRecordFixtures
|
|
74
74
|
false
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
|
78
78
|
def self.teardown
|
79
79
|
end
|
80
80
|
end
|
data/test/agent_helper.rb
CHANGED
@@ -63,6 +63,26 @@ def assert_calls_unscoped_metrics(*metrics)
|
|
63
63
|
assert_not_equal first_metrics, last_metrics, "should have changed these metrics"
|
64
64
|
end
|
65
65
|
|
66
|
+
def assert_has_error(error_class)
|
67
|
+
assert \
|
68
|
+
NewRelic::Agent.instance.error_collector.errors.find {|e| e.exception_class_constant == error_class} != nil, \
|
69
|
+
"Didn't find error of class #{error_class}"
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
unless defined?( build_message )
|
74
|
+
def build_message(head, template=nil, *arguments)
|
75
|
+
template &&= template.chomp
|
76
|
+
template.gsub(/\?/) { mu_pp(arguments.shift) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
unless defined?( assert_block )
|
81
|
+
def assert_block(*msgs)
|
82
|
+
assert yield, *msgs
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
66
86
|
unless defined?( assert_includes )
|
67
87
|
def assert_includes( collection, member, msg=nil )
|
68
88
|
msg = build_message( msg, "Expected ? to include ?", collection, member )
|
@@ -254,12 +274,25 @@ ensure
|
|
254
274
|
end
|
255
275
|
end
|
256
276
|
|
277
|
+
def constant_path(name)
|
278
|
+
path = [Object]
|
279
|
+
parts = name.gsub(/^::/, '').split('::')
|
280
|
+
parts.each do |part|
|
281
|
+
return nil unless path.last.const_defined?(part)
|
282
|
+
path << path.last.const_get(part)
|
283
|
+
end
|
284
|
+
path
|
285
|
+
end
|
286
|
+
|
257
287
|
def undefine_constant(constant_symbol)
|
258
|
-
|
259
|
-
|
288
|
+
const_path = constant_path(constant_symbol.to_s)
|
289
|
+
return yield unless const_path
|
290
|
+
parent = const_path[-2]
|
291
|
+
const_name = constant_symbol.to_s.gsub(/.*::/, '')
|
292
|
+
removed_constant = parent.send(:remove_const, const_name)
|
260
293
|
yield
|
261
294
|
ensure
|
262
|
-
|
295
|
+
parent.const_set(const_name, removed_constant) if removed_constant
|
263
296
|
end
|
264
297
|
|
265
298
|
def internet_connection?
|
@@ -270,3 +303,13 @@ def internet_connection?
|
|
270
303
|
true
|
271
304
|
end
|
272
305
|
end
|
306
|
+
|
307
|
+
def with_debug_logging
|
308
|
+
orig_logger = NewRelic::Agent.logger
|
309
|
+
$stderr.puts '', '---', ''
|
310
|
+
NewRelic::Agent.logger =
|
311
|
+
NewRelic::Agent::AgentLogger.new( {:log_level => 'debug'}, '', Logger.new($stderr) )
|
312
|
+
yield
|
313
|
+
ensure
|
314
|
+
NewRelic::Agent.logger = orig_logger
|
315
|
+
end
|