newrelic_rpm 3.8.1.221 → 3.9.0.229
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG +95 -0
- data/README.md +9 -3
- data/Rakefile +6 -0
- data/lib/new_relic/agent.rb +37 -52
- data/lib/new_relic/agent/agent.rb +32 -64
- data/lib/new_relic/agent/agent_logger.rb +3 -2
- data/lib/new_relic/agent/audit_logger.rb +2 -1
- data/lib/new_relic/agent/busy_calculator.rb +10 -8
- data/lib/new_relic/agent/configuration.rb +0 -13
- data/lib/new_relic/agent/configuration/default_source.rb +27 -20
- data/lib/new_relic/agent/configuration/manager.rb +101 -27
- data/lib/new_relic/agent/cross_app_monitor.rb +43 -50
- data/lib/new_relic/agent/cross_app_tracing.rb +13 -12
- data/lib/new_relic/agent/error_collector.rb +31 -35
- data/lib/new_relic/agent/harvester.rb +5 -1
- data/lib/new_relic/agent/hostname.rb +17 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/uri_util.rb +13 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +18 -32
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +15 -15
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +18 -20
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +79 -93
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -4
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +96 -0
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +69 -0
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +21 -13
- data/lib/new_relic/agent/instrumentation/rack.rb +85 -74
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -1
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +39 -0
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +28 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +4 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +34 -30
- data/lib/new_relic/agent/memory_logger.rb +12 -12
- data/lib/new_relic/agent/method_tracer.rb +34 -74
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +3 -3
- data/lib/new_relic/agent/request_sampler.rb +10 -11
- data/lib/new_relic/agent/samplers/vm_sampler.rb +6 -6
- data/lib/new_relic/agent/shim_agent.rb +2 -1
- data/lib/new_relic/agent/sql_sampler.rb +52 -27
- data/lib/new_relic/agent/stats.rb +24 -10
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +5 -17
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +106 -58
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +20 -24
- data/lib/new_relic/agent/supported_versions.rb +3 -1
- data/lib/new_relic/agent/threading/agent_thread.rb +42 -11
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
- data/lib/new_relic/agent/traced_method_stack.rb +28 -18
- data/lib/new_relic/agent/transaction.rb +249 -196
- data/lib/new_relic/agent/transaction_metrics.rb +57 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +10 -7
- data/lib/new_relic/agent/transaction_sampler.rb +81 -45
- data/lib/new_relic/agent/transaction_state.rb +38 -49
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +15 -18
- data/lib/new_relic/agent/vm/rubinius_vm.rb +4 -2
- data/lib/new_relic/cli/commands/deployments.rb +3 -2
- data/lib/new_relic/control/frameworks/ruby.rb +2 -3
- data/lib/new_relic/control/frameworks/sinatra.rb +0 -7
- data/lib/new_relic/control/instance_methods.rb +3 -5
- data/lib/new_relic/json_wrapper.rb +2 -0
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -16
- data/lib/new_relic/metric_spec.rb +10 -38
- data/lib/new_relic/noticed_error.rb +16 -11
- data/lib/new_relic/rack/agent_hooks.rb +4 -10
- data/lib/new_relic/rack/agent_middleware.rb +31 -0
- data/lib/new_relic/rack/browser_monitoring.rb +7 -13
- data/lib/new_relic/rack/developer_mode.rb +16 -59
- data/lib/new_relic/rack/error_collector.rb +16 -54
- data/lib/new_relic/recipes.rb +8 -101
- data/lib/new_relic/recipes/capistrano3.rb +66 -0
- data/lib/new_relic/recipes/capistrano_legacy.rb +98 -0
- data/lib/new_relic/transaction_sample.rb +6 -54
- data/lib/new_relic/transaction_sample/composite_segment.rb +1 -1
- data/lib/new_relic/transaction_sample/segment.rb +12 -4
- data/lib/new_relic/transaction_sample/summary_segment.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +19 -19
- data/lib/tasks/tests.rake +20 -1
- data/lib/tasks/versions.html.erb +0 -4
- data/lib/tasks/versions.rake +4 -3
- data/newrelic.yml +4 -12
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +146 -44
- data/test/config/newrelic.yml +0 -1
- data/test/environments/norails/Gemfile +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +13 -1
- data/test/multiverse/lib/multiverse/suite.rb +26 -9
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
- data/test/multiverse/suites/activemerchant/Envfile +18 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +4 -3
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +35 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +3 -2
- data/test/multiverse/suites/agent_only/exclusive_time_test.rb +178 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +10 -6
- data/test/multiverse/suites/agent_only/marshaling_test.rb +11 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +1 -1
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +5 -1
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +2 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +9 -9
- data/test/multiverse/suites/capistrano/Capfile +26 -0
- data/test/multiverse/suites/capistrano/Envfile +18 -0
- data/test/multiverse/suites/capistrano/config/deploy.rb +10 -0
- data/test/multiverse/suites/capistrano/config/deploy/production.rb +9 -0
- data/test/multiverse/suites/capistrano/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano/deployment_test.rb +47 -0
- data/test/multiverse/suites/capistrano2/Capfile +4 -0
- data/test/multiverse/suites/capistrano2/Envfile +4 -0
- data/test/multiverse/suites/capistrano2/config/deploy.rb +19 -0
- data/test/multiverse/suites/capistrano2/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano2/deployment_test.rb +38 -0
- data/test/multiverse/suites/curb/Envfile +10 -1
- data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
- data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rack/Envfile +25 -0
- data/test/multiverse/suites/rack/example_app.rb +50 -0
- data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +66 -0
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +143 -0
- data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +45 -0
- data/test/multiverse/suites/rack/url_map_test.rb +120 -0
- data/test/multiverse/suites/rails/Envfile +10 -0
- data/test/multiverse/suites/rails/app.rb +28 -63
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -4
- data/test/multiverse/suites/rails/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rails/dummy.txt +1 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +46 -31
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/rails/ignore_test.rb +9 -3
- data/test/multiverse/suites/rails/middleware_instrumentation_test.rb +41 -0
- data/test/multiverse/suites/rails/middlewares.rb +19 -0
- data/test/multiverse/suites/rails/parameter_capture_test.rb +169 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +14 -4
- data/test/multiverse/suites/rails/rails2_app/app/controllers/application.rb +7 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +127 -0
- data/test/multiverse/suites/rails/rails2_app/config/database.yml +18 -0
- data/test/multiverse/suites/rails/rails2_app/config/environment.rb +16 -0
- data/test/multiverse/suites/rails/rails2_app/config/environments/development.rb +10 -0
- data/test/multiverse/suites/rails/rails2_app/config/initializers/load_newrelic_rpm.rb +9 -0
- data/test/multiverse/suites/rails/rails2_app/config/preinitializer.rb +25 -0
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +18 -0
- data/test/multiverse/suites/rails/rails2_app/db/schema.rb +5 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +76 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +2 -4
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +3 -5
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +73 -42
- data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/Envfile +4 -0
- data/test/multiverse/suites/sidekiq/after_suite.rb +7 -0
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +55 -34
- data/test/multiverse/suites/sidekiq/sidekiq_server.rb +30 -0
- data/test/multiverse/suites/sidekiq/test_worker.rb +60 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sinatra/ignoring_test.rb +33 -11
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +3 -1
- data/test/multiverse/suites/typhoeus/Envfile +9 -0
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +10 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +3 -10
- data/test/new_relic/agent/agent_logger_test.rb +24 -6
- data/test/new_relic/agent/agent_test.rb +7 -8
- data/test/new_relic/agent/agent_test_controller.rb +2 -2
- data/test/new_relic/agent/audit_logger_test.rb +5 -1
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/configuration/manager_test.rb +68 -69
- data/test/new_relic/agent/cross_app_monitor_test.rb +32 -14
- data/test/new_relic/agent/cross_app_tracing_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -33
- data/test/new_relic/agent/error_collector_test.rb +45 -14
- data/test/new_relic/agent/harvester_test.rb +9 -0
- data/test/new_relic/agent/hostname_test.rb +41 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +27 -19
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +95 -14
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +189 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +18 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +10 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +3 -1
- data/test/new_relic/agent/javascript_instrumentor_test.rb +28 -41
- data/test/new_relic/agent/memory_logger_test.rb +14 -0
- data/test/new_relic/agent/method_interrobang_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -30
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +5 -21
- data/test/new_relic/agent/method_tracer_test.rb +5 -4
- data/test/new_relic/agent/mock_scope_listener.rb +2 -2
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +17 -5
- data/test/new_relic/agent/request_sampler_test.rb +16 -16
- data/test/new_relic/agent/rpm_agent_test.rb +23 -29
- data/test/new_relic/agent/sql_sampler_test.rb +39 -31
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +189 -117
- data/test/new_relic/agent/stats_engine_test.rb +1 -1
- data/test/new_relic/agent/stats_hash_test.rb +28 -1
- data/test/new_relic/agent/stats_test.rb +1 -12
- data/test/new_relic/agent/threading/agent_thread_test.rb +23 -9
- data/test/new_relic/agent/threading/backtrace_service_test.rb +33 -32
- data/test/new_relic/agent/threading/fake_thread.rb +4 -8
- data/test/new_relic/agent/threading/threaded_test_case.rb +4 -14
- data/test/new_relic/agent/traced_method_stack_test.rb +43 -27
- data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
- data/test/new_relic/agent/transaction_metrics_test.rb +113 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -61
- data/test/new_relic/agent/transaction_sampler_test.rb +176 -228
- data/test/new_relic/agent/transaction_state_test.rb +62 -26
- data/test/new_relic/agent/transaction_test.rb +198 -80
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +4 -4
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +68 -0
- data/test/new_relic/agent_test.rb +31 -27
- data/test/new_relic/cli/commands/deployments_test.rb +7 -2
- data/test/new_relic/control/instance_methods_test.rb +4 -4
- data/test/new_relic/control_test.rb +28 -22
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_external_server.rb +1 -0
- data/test/new_relic/fake_rpm_site.rb +35 -0
- data/test/new_relic/http_client_test_cases.rb +12 -3
- data/test/new_relic/json_wrapper_test.rb +5 -0
- data/test/new_relic/language_support_test.rb +7 -0
- data/test/new_relic/license_test.rb +11 -5
- data/test/new_relic/local_environment_test.rb +0 -18
- data/test/new_relic/metric_data_test.rb +2 -2
- data/test/new_relic/metric_spec_test.rb +4 -23
- data/test/new_relic/multiverse_helpers.rb +1 -3
- data/test/new_relic/noticed_error_test.rb +6 -22
- data/test/new_relic/rack/agent_hooks_test.rb +5 -1
- data/test/new_relic/rack/agent_middleware_test.rb +32 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +14 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +0 -8
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +6 -30
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -2
- data/test/new_relic/transaction_sample/segment_test.rb +47 -47
- data/test/new_relic/transaction_sample_test.rb +9 -8
- data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -8
- data/test/performance/script/runner +13 -0
- data/test/performance/suites/config.rb +5 -2
- data/test/performance/suites/rack_middleware.rb +84 -0
- data/test/performance/suites/rum_autoinsertion.rb +1 -1
- data/test/performance/suites/thread_profiling.rb +1 -1
- data/test/test_helper.rb +12 -10
- data/ui/helpers/developer_mode_helper.rb +3 -43
- data/ui/views/layouts/newrelic_default.rhtml +2 -2
- data/ui/views/newrelic/_sample.rhtml +2 -2
- data/ui/views/newrelic/_sql_row.rhtml +11 -11
- data/ui/views/newrelic/index.rhtml +21 -22
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +15 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +2 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +24 -0
- metadata +108 -31
- metadata.gz.sig +0 -0
- data/lib/new_relic/rack/transaction_reset.rb +0 -20
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -42
- data/test/new_relic/rack/transaction_reset_test.rb +0 -35
- data/ui/views/newrelic/show_source.rhtml +0 -3
@@ -12,7 +12,7 @@ module NewRelic
|
|
12
12
|
|
13
13
|
def initialize(segments)
|
14
14
|
summary = SummarySegment.new(segments.first)
|
15
|
-
super summary.entry_timestamp, "Repeating pattern (#{segments.length} repeats)"
|
15
|
+
super summary.entry_timestamp, "Repeating pattern (#{segments.length} repeats)"
|
16
16
|
|
17
17
|
summary.end_trace(segments.last.exit_timestamp)
|
18
18
|
|
@@ -12,14 +12,19 @@ module NewRelic
|
|
12
12
|
# have a timestamp.
|
13
13
|
attr_reader :exit_timestamp
|
14
14
|
attr_reader :parent_segment
|
15
|
+
|
16
|
+
# This is only used from developer mode and rpm_site.
|
17
|
+
# No new clients should be added.
|
15
18
|
attr_reader :segment_id
|
16
19
|
|
17
20
|
attr_accessor :metric_name
|
18
21
|
|
19
|
-
|
22
|
+
UNKNOWN_SEGMENT_NAME = '<unknown>'.freeze
|
23
|
+
|
24
|
+
def initialize(timestamp, metric_name, segment_id=nil)
|
20
25
|
@entry_timestamp = timestamp
|
21
|
-
@metric_name
|
22
|
-
@segment_id
|
26
|
+
@metric_name = metric_name || UNKNOWN_SEGMENT_NAME
|
27
|
+
@segment_id = segment_id || object_id
|
23
28
|
end
|
24
29
|
|
25
30
|
# sets the final timestamp on a segment to indicate the exit
|
@@ -55,6 +60,7 @@ module NewRelic
|
|
55
60
|
def path_string
|
56
61
|
"#{metric_name}[#{called_segments.collect {|segment| segment.path_string }.join('')}]"
|
57
62
|
end
|
63
|
+
|
58
64
|
def to_s_compact
|
59
65
|
str = ""
|
60
66
|
str << metric_name
|
@@ -63,6 +69,7 @@ module NewRelic
|
|
63
69
|
end
|
64
70
|
str
|
65
71
|
end
|
72
|
+
|
66
73
|
def to_debug_str(depth)
|
67
74
|
tab = " " * depth
|
68
75
|
s = tab.clone
|
@@ -155,8 +162,9 @@ module NewRelic
|
|
155
162
|
summary.current_nest_count -= 1 if summary
|
156
163
|
end
|
157
164
|
|
165
|
+
# This is only for use by developer mode
|
158
166
|
def find_segment(id)
|
159
|
-
return self if
|
167
|
+
return self if segment_id == id
|
160
168
|
called_segments.each do |segment|
|
161
169
|
found = segment.find_segment(id)
|
162
170
|
return found if found
|
data/lib/new_relic/version.rb
CHANGED
data/lib/newrelic_rpm.rb
CHANGED
@@ -35,8 +35,9 @@ module Sequel
|
|
35
35
|
|
36
36
|
|
37
37
|
# Instrument all queries that go through #execute_query.
|
38
|
-
def log_yield(
|
39
|
-
|
38
|
+
def log_yield(sql, args=nil) #THREAD_LOCAL_ACCESS
|
39
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
40
|
+
return super unless state.is_execution_traced?
|
40
41
|
|
41
42
|
t0 = Time.now
|
42
43
|
rval = super
|
@@ -44,8 +45,8 @@ module Sequel
|
|
44
45
|
|
45
46
|
begin
|
46
47
|
duration = t1 - t0
|
47
|
-
record_metrics(
|
48
|
-
notice_sql( sql, args, t0, t1
|
48
|
+
record_metrics(sql, args, duration)
|
49
|
+
notice_sql(state, sql, args, t0, t1)
|
49
50
|
rescue => err
|
50
51
|
NewRelic::Agent.logger.debug "while recording metrics for Sequel", err
|
51
52
|
end
|
@@ -55,16 +56,14 @@ module Sequel
|
|
55
56
|
|
56
57
|
# Record metrics for the specified +sql+ and +args+ using the specified
|
57
58
|
# +duration+.
|
58
|
-
def record_metrics(
|
59
|
-
primary_metric = primary_metric_for(
|
59
|
+
def record_metrics(sql, args, duration) #THREAD_LOCAL_ACCESS
|
60
|
+
primary_metric = primary_metric_for(sql, args)
|
60
61
|
engine = NewRelic::Agent.instance.stats_engine
|
61
62
|
|
62
|
-
|
63
|
+
metrics = rollup_metrics_for(primary_metric)
|
64
|
+
metrics << remote_service_metric(*self.opts.values_at(:adapter, :host)) if self.opts.key?(:adapter)
|
63
65
|
|
64
|
-
|
65
|
-
metrics << remote_service_metric( *self.opts.values_at(:adapter, :host) ) if self.opts.key?(:adapter)
|
66
|
-
|
67
|
-
engine.record_metrics( metrics, duration, :scoped => false )
|
66
|
+
engine.tl_record_scoped_and_unscoped_metrics(primary_metric, metrics, duration)
|
68
67
|
end
|
69
68
|
|
70
69
|
THREAD_SAFE_CONNECTION_POOL_CLASSES = [
|
@@ -73,13 +72,14 @@ module Sequel
|
|
73
72
|
|
74
73
|
# Record the given +sql+ within a new frame, using the given +start+ and
|
75
74
|
# +finish+ times.
|
76
|
-
def notice_sql( sql, args, start, finish
|
77
|
-
metric = primary_metric_for(
|
75
|
+
def notice_sql(state, sql, args, start, finish)
|
76
|
+
metric = primary_metric_for(sql, args)
|
78
77
|
agent = NewRelic::Agent.instance
|
79
78
|
duration = finish - start
|
79
|
+
stack = state.traced_method_stack
|
80
80
|
|
81
81
|
begin
|
82
|
-
frame =
|
82
|
+
frame = stack.push_frame(state, :sequel, start)
|
83
83
|
explainer = Proc.new do |*|
|
84
84
|
if THREAD_SAFE_CONNECTION_POOL_CLASSES.include?(self.pool.class)
|
85
85
|
self[ sql ].explain
|
@@ -88,22 +88,22 @@ module Sequel
|
|
88
88
|
nil
|
89
89
|
end
|
90
90
|
end
|
91
|
-
agent.transaction_sampler.notice_sql(
|
92
|
-
agent.sql_sampler.notice_sql(
|
91
|
+
agent.transaction_sampler.notice_sql(sql, self.opts, duration, state, &explainer)
|
92
|
+
agent.sql_sampler.notice_sql(sql, metric, self.opts, duration, state, &explainer)
|
93
93
|
ensure
|
94
|
-
|
94
|
+
stack.pop_frame(state, frame, metric, finish)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
|
99
99
|
# Derive a primary database metric for the specified +sql+.
|
100
|
-
def primary_metric_for(
|
100
|
+
def primary_metric_for(sql, _)
|
101
101
|
return metric_for_sql(NewRelic::Helper.correctly_encoded(sql))
|
102
102
|
end
|
103
103
|
|
104
104
|
end # module NewRelicInstrumentation
|
105
105
|
|
106
106
|
NewRelic::Agent.logger.debug "Registering the :newrelic_instrumentation extension."
|
107
|
-
Database.register_extension(
|
107
|
+
Database.register_extension(:newrelic_instrumentation, NewRelicInstrumentation)
|
108
108
|
|
109
109
|
end # module Sequel
|
data/lib/tasks/tests.rake
CHANGED
@@ -4,7 +4,25 @@ rescue LoadError => e
|
|
4
4
|
end
|
5
5
|
|
6
6
|
if defined? Rake::TestTask
|
7
|
-
namespace :test do
|
7
|
+
namespace :test do |t|
|
8
|
+
def look_for_seed(tasks)
|
9
|
+
matches = tasks.map { |t| /(seed=.*?)[,\]]/.match(t) }.compact
|
10
|
+
if matches.any?
|
11
|
+
matches.first[1]
|
12
|
+
else
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
tasks = Rake.application.top_level_tasks
|
18
|
+
ENV["TESTOPTS"] ||= ""
|
19
|
+
if tasks.any? { |t| t.include?("verbose")}
|
20
|
+
ENV["TESTOPTS"] += " -v"
|
21
|
+
end
|
22
|
+
if seed = look_for_seed(tasks)
|
23
|
+
ENV["TESTOPTS"] += " --" + seed
|
24
|
+
end
|
25
|
+
|
8
26
|
agent_home = File.expand_path(File.join(File.dirname(__FILE__),'..','..'))
|
9
27
|
|
10
28
|
Rake::TestTask.new(:newrelic) do |t|
|
@@ -13,5 +31,6 @@ if defined? Rake::TestTask
|
|
13
31
|
t.pattern = "#{agent_home}/test/new_relic/**/*_test.rb"
|
14
32
|
t.verbose = true
|
15
33
|
end
|
34
|
+
|
16
35
|
end
|
17
36
|
end
|
data/lib/tasks/versions.html.erb
CHANGED
@@ -2,20 +2,16 @@
|
|
2
2
|
<table>
|
3
3
|
<thead>
|
4
4
|
<th>Name</th>
|
5
|
-
<% unless suppress_versions %>
|
6
5
|
<th>Supported</th>
|
7
6
|
<th>Deprecated</th>
|
8
7
|
<th>Experimental</th>
|
9
|
-
<% end %>
|
10
8
|
</thead>
|
11
9
|
<% for version in versions %>
|
12
10
|
<tr>
|
13
11
|
<td><b><%= version.name %></b></td>
|
14
|
-
<% unless suppress_versions %>
|
15
12
|
<td><%= version_list(version.supported) %></td>
|
16
13
|
<td><%= version_list(version.deprecated) %></td>
|
17
14
|
<td><%= version_list(version.experimental) %></td>
|
18
|
-
<% end %>
|
19
15
|
</tr>
|
20
16
|
<% if version.notes %>
|
21
17
|
<tr>
|
data/lib/tasks/versions.rake
CHANGED
@@ -12,7 +12,8 @@ namespace :newrelic do
|
|
12
12
|
|
13
13
|
def versions_for_type(type)
|
14
14
|
NewRelic::Agent::SUPPORTED_VERSIONS.
|
15
|
-
select
|
15
|
+
select {|key, values| values[:type] == type}.
|
16
|
+
sort_by {|key, values| (values[:name] || key).to_s }.
|
16
17
|
map do |key,values|
|
17
18
|
VersionStruct.new(
|
18
19
|
values[:name] || key,
|
@@ -30,7 +31,7 @@ namespace :newrelic do
|
|
30
31
|
ERB.new(template)
|
31
32
|
end
|
32
33
|
|
33
|
-
def write_versions(title, type, erb
|
34
|
+
def write_versions(title, type, erb)
|
34
35
|
anchor = title.downcase.gsub(" ", "_")
|
35
36
|
versions = versions_for_type(type)
|
36
37
|
puts erb.result(binding).gsub(/^ *$/, '')
|
@@ -47,6 +48,6 @@ namespace :newrelic do
|
|
47
48
|
write_versions("Database", :database, erb)
|
48
49
|
write_versions("Background Jobs", :background, erb)
|
49
50
|
write_versions("HTTP Clients", :http, erb)
|
50
|
-
write_versions("Other", :other, erb
|
51
|
+
write_versions("Other", :other, erb)
|
51
52
|
end
|
52
53
|
end
|
data/newrelic.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# This file configures the New Relic Agent. New Relic monitors
|
3
|
-
#
|
4
|
-
# For more information, visit www.newrelic.com.
|
2
|
+
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
|
3
|
+
# .NET, PHP, Python and Node applications with deep visibility and low
|
4
|
+
# overhead. For more information, visit www.newrelic.com.
|
5
5
|
#
|
6
6
|
# Generated <%= Time.now.strftime('%B %d, %Y') %>, for version <%= NewRelic::VERSION::STRING %>
|
7
7
|
#
|
@@ -160,11 +160,6 @@ common: &default_settings
|
|
160
160
|
# product levels.
|
161
161
|
enabled: true
|
162
162
|
|
163
|
-
# Rails Only - tells error collector whether or not to capture a
|
164
|
-
# source snippet around the place of the error when errors are View
|
165
|
-
# related.
|
166
|
-
capture_source: true
|
167
|
-
|
168
163
|
# To stop specific errors from reporting to New Relic, set this property
|
169
164
|
# to comma-separated values. Default is to ignore routing errors,
|
170
165
|
# which are how 404's get triggered.
|
@@ -197,10 +192,7 @@ development:
|
|
197
192
|
# executed since starting the mongrel.
|
198
193
|
# NOTE: There is substantial overhead when running in developer mode.
|
199
194
|
# Do not use for production or load testing.
|
200
|
-
developer_mode:
|
201
|
-
|
202
|
-
# Enable textmate links
|
203
|
-
# textmate: true
|
195
|
+
developer_mode: true
|
204
196
|
|
205
197
|
test:
|
206
198
|
<<: *default_settings
|
data/newrelic_rpm.gemspec
CHANGED
@@ -46,7 +46,7 @@ EOS
|
|
46
46
|
s.add_development_dependency 'mocha', '~> 0.13.0'
|
47
47
|
s.add_development_dependency 'yard'
|
48
48
|
s.add_development_dependency 'rails', '~> 3.2.13'
|
49
|
-
s.add_development_dependency 'pry'
|
49
|
+
s.add_development_dependency 'pry', '~> 0.9.12'
|
50
50
|
# s.add_development_dependency 'pry-nav'
|
51
51
|
s.add_development_dependency 'guard', '~> 1.8.3' # Guard 2.0 is Ruby 1.9 only
|
52
52
|
s.add_development_dependency 'guard-minitest'
|
data/test/agent_helper.rb
CHANGED
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
def assert_has_error(error_class)
|
30
30
|
assert \
|
31
|
-
NewRelic::Agent.instance.error_collector.errors.find {|e| e.
|
31
|
+
NewRelic::Agent.instance.error_collector.errors.find {|e| e.exception_class_name == error_class.name} != nil, \
|
32
32
|
"Didn't find error of class #{error_class}"
|
33
33
|
end
|
34
34
|
|
@@ -90,6 +90,32 @@ def _normalize_metric_expectations(expectations)
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
def dump_stats(stats)
|
94
|
+
str = " Call count: #{stats.call_count}\n"
|
95
|
+
str << " Total call time: #{stats.total_call_time}\n"
|
96
|
+
str << " Total exclusive time: #{stats.total_exclusive_time}\n"
|
97
|
+
str << " Min call time: #{stats.min_call_time}\n"
|
98
|
+
str << " Max call time: #{stats.max_call_time}\n"
|
99
|
+
str << " Sum of squares: #{stats.sum_of_squares}\n"
|
100
|
+
str << " Apdex S: #{stats.apdex_s}\n"
|
101
|
+
str << " Apdex T: #{stats.apdex_t}\n"
|
102
|
+
str << " Apdex F: #{stats.apdex_f}\n"
|
103
|
+
str
|
104
|
+
end
|
105
|
+
|
106
|
+
def assert_stats_has_values(stats, expected_spec, expected_attrs)
|
107
|
+
expected_attrs.each do |attr, expected_value|
|
108
|
+
actual_value = stats.send(attr)
|
109
|
+
if attr == :call_count
|
110
|
+
assert_equal(expected_value, actual_value,
|
111
|
+
"Expected #{attr} for #{expected_spec} to be #{expected_value}, got #{actual_value}.\nActual stats:\n#{dump_stats(stats)}")
|
112
|
+
else
|
113
|
+
assert_in_delta(expected_value, actual_value, 0.0001,
|
114
|
+
"Expected #{attr} for #{expected_spec} to be ~#{expected_value}, got #{actual_value}.\nActual stats:\n#{dump_stats(stats)}")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
93
119
|
def assert_metrics_recorded(expected)
|
94
120
|
expected = _normalize_metric_expectations(expected)
|
95
121
|
expected.each do |specish, expected_attrs|
|
@@ -99,39 +125,47 @@ def assert_metrics_recorded(expected)
|
|
99
125
|
all_specs = NewRelic::Agent.instance.stats_engine.metric_specs.sort
|
100
126
|
matches = all_specs.select { |spec| spec.name == expected_spec.name }
|
101
127
|
matches.map! { |m| " #{m.inspect}" }
|
128
|
+
|
102
129
|
msg = "Did not find stats for spec #{expected_spec.inspect}."
|
103
130
|
msg += "\nDid find specs: [\n#{matches.join(",\n")}\n]" unless matches.empty?
|
104
|
-
|
105
|
-
msg += "\nAll specs in there were: [\n#{all_specs.map do |s|
|
106
|
-
" #{s.name} (#{s.scope.empty? ? '<unscoped>' : s.scope})"
|
107
|
-
end.join(",\n")}\n]"
|
131
|
+
msg += "\nAll specs in there were: #{format_metric_spec_list(all_specs)}"
|
108
132
|
|
109
133
|
assert(actual_stats, msg)
|
110
134
|
end
|
111
|
-
|
112
|
-
actual_value = actual_stats.send(attr)
|
113
|
-
if attr == :call_count
|
114
|
-
assert_equal(expected_value, actual_value,
|
115
|
-
"Expected #{attr} for #{expected_spec} to be #{expected_value}, got #{actual_value}")
|
116
|
-
else
|
117
|
-
assert_in_delta(expected_value, actual_value, 0.0001,
|
118
|
-
"Expected #{attr} for #{expected_spec} to be ~#{expected_value}, got #{actual_value}")
|
119
|
-
end
|
120
|
-
end
|
135
|
+
assert_stats_has_values(actual_stats, expected_spec, expected_attrs)
|
121
136
|
end
|
122
137
|
end
|
123
138
|
|
139
|
+
# Use this to assert that *only* the given set of metrics has been recorded.
|
140
|
+
#
|
141
|
+
# If you want to scope the search for unexpected metrics to a particular
|
142
|
+
# namespace (e.g. metrics matching 'Controller/'), pass a Regex for the
|
143
|
+
# :filter option. Only metrics matching the regex will be searched when looking
|
144
|
+
# for unexpected metrics.
|
145
|
+
#
|
146
|
+
# If you want to *allow* unexpected metrics matching certain patterns, use
|
147
|
+
# the :ignore_filter option. This will allow you to specify a Regex that
|
148
|
+
# whitelists broad swathes of metric territory (e.g. 'Supportability/').
|
149
|
+
#
|
124
150
|
def assert_metrics_recorded_exclusive(expected, options={})
|
125
151
|
expected = _normalize_metric_expectations(expected)
|
126
152
|
assert_metrics_recorded(expected)
|
127
|
-
|
153
|
+
|
154
|
+
recorded_metrics = NewRelic::Agent.instance.stats_engine.metric_specs
|
155
|
+
|
128
156
|
if options[:filter]
|
129
|
-
recorded_metrics = recorded_metrics.select { |m| m.match(options[:filter]) }
|
157
|
+
recorded_metrics = recorded_metrics.select { |m| m.name.match(options[:filter]) }
|
130
158
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
159
|
+
if options[:ignore_filter]
|
160
|
+
recorded_metrics.reject! { |m| m.name.match(options[:ignore_filter]) }
|
161
|
+
end
|
162
|
+
|
163
|
+
expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s) }
|
164
|
+
|
165
|
+
unexpected_metrics = recorded_metrics - expected_metrics
|
166
|
+
unexpected_metrics.reject! { |m| m.name =~ /GC\/Transaction/ }
|
167
|
+
|
168
|
+
assert_equal(0, unexpected_metrics.size, "Found unexpected metrics: #{format_metric_spec_list(unexpected_metrics)}")
|
135
169
|
end
|
136
170
|
|
137
171
|
def assert_metrics_not_recorded(not_expected)
|
@@ -143,7 +177,14 @@ def assert_metrics_not_recorded(not_expected)
|
|
143
177
|
found_but_not_expected << spec
|
144
178
|
end
|
145
179
|
end
|
146
|
-
assert_equal([], found_but_not_expected, "Found unexpected metrics:
|
180
|
+
assert_equal([], found_but_not_expected, "Found unexpected metrics: #{format_metric_spec_list(found_but_not_expected)}")
|
181
|
+
end
|
182
|
+
|
183
|
+
def format_metric_spec_list(specs)
|
184
|
+
spec_strings = specs.map do |spec|
|
185
|
+
"#{spec.name} (#{spec.scope.empty? ? '<unscoped>' : spec.scope})"
|
186
|
+
end
|
187
|
+
"[\n #{spec_strings.join(",\n ")}\n]"
|
147
188
|
end
|
148
189
|
|
149
190
|
def assert_truthy(expected, msg = nil)
|
@@ -167,45 +208,46 @@ unless defined?(refute)
|
|
167
208
|
end
|
168
209
|
|
169
210
|
# Mock up a transaction for testing purposes, optionally specifying a name and
|
170
|
-
# transaction
|
211
|
+
# transaction category. The given block will be executed within the context of the
|
171
212
|
# dummy transaction.
|
172
213
|
#
|
173
214
|
# Examples:
|
174
215
|
#
|
175
|
-
# With default name ('dummy') and
|
216
|
+
# With default name ('dummy') and category (:other):
|
176
217
|
# in_transaction { ... }
|
177
218
|
#
|
178
|
-
# With an explicit transaction name and default
|
219
|
+
# With an explicit transaction name and default category:
|
179
220
|
# in_transaction('foobar') { ... }
|
180
221
|
#
|
181
|
-
# With default name and explicit
|
182
|
-
# in_transaction(:
|
222
|
+
# With default name and explicit category:
|
223
|
+
# in_transaction(:category => :controller) { ... }
|
183
224
|
#
|
184
|
-
# With a transaction name plus
|
185
|
-
# in_transaction('foobar', :
|
225
|
+
# With a transaction name plus category:
|
226
|
+
# in_transaction('foobar', :category => :controller) { ... }
|
186
227
|
#
|
187
228
|
def in_transaction(*args)
|
188
229
|
opts = (args.last && args.last.is_a?(Hash)) ? args.pop : {}
|
189
230
|
opts[:transaction_name] = args.first || 'dummy'
|
190
|
-
|
231
|
+
category = (opts && opts.delete(:category)) || :other
|
232
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
191
233
|
|
192
|
-
NewRelic::Agent::Transaction.start(
|
234
|
+
NewRelic::Agent::Transaction.start(state, category, opts)
|
193
235
|
|
194
236
|
val = nil
|
195
237
|
|
196
238
|
begin
|
197
|
-
val = yield
|
239
|
+
val = yield state.current_transaction
|
198
240
|
ensure
|
199
|
-
NewRelic::Agent::Transaction.stop()
|
241
|
+
NewRelic::Agent::Transaction.stop(state)
|
200
242
|
end
|
201
243
|
|
202
244
|
val
|
203
245
|
end
|
204
246
|
|
205
|
-
# Convenience wrapper around in_transaction that sets the
|
247
|
+
# Convenience wrapper around in_transaction that sets the category so that it
|
206
248
|
# looks like we are in a web transaction
|
207
249
|
def in_web_transaction(name='dummy')
|
208
|
-
in_transaction(name, :
|
250
|
+
in_transaction(name, :category => :controller) do
|
209
251
|
yield
|
210
252
|
end
|
211
253
|
end
|
@@ -214,7 +256,7 @@ def find_last_transaction_segment(transaction_sample=nil)
|
|
214
256
|
if transaction_sample
|
215
257
|
root_segment = transaction_sample.root_segment
|
216
258
|
else
|
217
|
-
builder = NewRelic::Agent.agent.transaction_sampler.
|
259
|
+
builder = NewRelic::Agent.agent.transaction_sampler.tl_builder
|
218
260
|
root_segment = builder.current_segment
|
219
261
|
end
|
220
262
|
|
@@ -224,15 +266,49 @@ def find_last_transaction_segment(transaction_sample=nil)
|
|
224
266
|
return last_segment
|
225
267
|
end
|
226
268
|
|
227
|
-
def
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
269
|
+
def collect_segment_names(transaction_sample)
|
270
|
+
names = []
|
271
|
+
|
272
|
+
transaction_sample.root_segment.each_segment do |segment|
|
273
|
+
names << segment.metric_name
|
274
|
+
end
|
275
|
+
|
276
|
+
names
|
277
|
+
end
|
278
|
+
|
279
|
+
def find_segment_with_name(transaction_sample, name)
|
280
|
+
transaction_sample.root_segment.each_segment do |segment|
|
281
|
+
if segment.metric_name == name
|
282
|
+
return segment
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
nil
|
287
|
+
end
|
288
|
+
|
289
|
+
def find_segment_with_name_matching(transaction_sample, regex)
|
290
|
+
transaction_sample.root_segment.each_segment do |segment|
|
291
|
+
if segment.metric_name.match regex
|
292
|
+
return segment
|
233
293
|
end
|
234
294
|
end
|
235
|
-
|
295
|
+
|
296
|
+
nil
|
297
|
+
end
|
298
|
+
|
299
|
+
def find_all_segments_with_name_matching(transaction_sample, regexes)
|
300
|
+
regexes = [regexes].flatten
|
301
|
+
matching_segments = []
|
302
|
+
|
303
|
+
transaction_sample.root_segment.each_segment do |segment|
|
304
|
+
regexes.each do |regex|
|
305
|
+
if segment.metric_name.match regex
|
306
|
+
matching_segments << segment
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
matching_segments
|
236
312
|
end
|
237
313
|
|
238
314
|
def with_config(config_hash, opts={})
|
@@ -242,7 +318,7 @@ def with_config(config_hash, opts={})
|
|
242
318
|
else
|
243
319
|
config = NewRelic::Agent::Configuration::DottedHash.new(config_hash)
|
244
320
|
end
|
245
|
-
NewRelic::Agent.config.
|
321
|
+
NewRelic::Agent.config.add_config_for_testing(config, opts[:level])
|
246
322
|
begin
|
247
323
|
yield
|
248
324
|
ensure
|
@@ -355,3 +431,29 @@ def with_array_logger(level=:info)
|
|
355
431
|
ensure
|
356
432
|
NewRelic::Agent.logger = orig_logger
|
357
433
|
end
|
434
|
+
|
435
|
+
def with_environment(env)
|
436
|
+
old_env = {}
|
437
|
+
env.each do |key, val|
|
438
|
+
old_env[key] = ENV[key]
|
439
|
+
ENV[key] = val.to_s
|
440
|
+
end
|
441
|
+
begin
|
442
|
+
yield
|
443
|
+
ensure
|
444
|
+
old_env.each { |key, old_val| ENV[key] = old_val }
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
def with_ignore_error_filter(filter, &blk)
|
449
|
+
original_filter = NewRelic::Agent.ignore_error_filter
|
450
|
+
NewRelic::Agent.ignore_error_filter(&filter)
|
451
|
+
|
452
|
+
yield
|
453
|
+
ensure
|
454
|
+
if original_filter.nil?
|
455
|
+
NewRelic::Agent.instance.error_collector.clear_ignore_error_filter
|
456
|
+
else
|
457
|
+
NewRelic::Agent.ignore_error_filter(&original_filter)
|
458
|
+
end
|
459
|
+
end
|