newrelic_rpm 3.9.1.236 → 3.9.2.239
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -4
- data/CHANGELOG +96 -2
- data/lib/new_relic/agent.rb +47 -4
- data/lib/new_relic/agent/agent.rb +51 -26
- data/lib/new_relic/agent/agent_logger.rb +4 -0
- data/lib/new_relic/agent/configuration.rb +2 -32
- data/lib/new_relic/agent/configuration/default_source.rb +153 -118
- data/lib/new_relic/agent/configuration/dotted_hash.rb +52 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +101 -2
- data/lib/new_relic/agent/configuration/manual_source.rb +17 -0
- data/lib/new_relic/agent/configuration/server_source.rb +12 -4
- data/lib/new_relic/agent/configuration/yaml_source.rb +46 -22
- data/lib/new_relic/agent/cross_app_monitor.rb +1 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +55 -14
- data/lib/new_relic/agent/database/obfuscator.rb +22 -7
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +6 -8
- data/lib/new_relic/agent/error_collector.rb +24 -16
- data/lib/new_relic/agent/event_loop.rb +189 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +8 -17
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -16
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +41 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -11
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -8
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -9
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -18
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +12 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +33 -39
- data/lib/new_relic/agent/new_relic_service.rb +35 -156
- data/lib/new_relic/agent/new_relic_service/encoders.rb +34 -0
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +50 -0
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +52 -0
- data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +52 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
- data/lib/new_relic/agent/traced_method_stack.rb +16 -2
- data/lib/new_relic/agent/transaction.rb +0 -4
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +3 -0
- data/lib/new_relic/control/instrumentation.rb +6 -2
- data/lib/new_relic/json_wrapper.rb +47 -25
- data/lib/new_relic/language_support.rb +0 -4
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/rack/developer_mode.rb +4 -3
- data/lib/new_relic/recipes/capistrano3.rb +2 -2
- data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
- data/lib/new_relic/timer_lib.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/config.html.erb +28 -0
- data/lib/tasks/config.rake +134 -0
- data/lib/tasks/config.text.erb +7 -0
- data/lib/tasks/install.rake +0 -63
- data/newrelic.yml +7 -0
- data/test/active_record_fixtures.rb +4 -4
- data/test/agent_helper.rb +58 -18
- data/test/environments/lib/environments/runner.rb +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails21/config/boot.rb +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails22/config/boot.rb +1 -1
- data/test/environments/rails23/config/boot.rb +2 -2
- 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/fixtures/cross_agent_tests/labels.json +104 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +23 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.sql +3 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +1 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +19 -4
- data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -38
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +25 -35
- data/test/multiverse/suites/agent_only/config/newrelic.yml +2 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -0
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
- data/test/multiverse/suites/agent_only/keepalive_test.rb +29 -0
- data/test/multiverse/suites/agent_only/labels_test.rb +89 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -3
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +9 -1
- data/test/multiverse/suites/capistrano/config/deploy.rb +6 -2
- data/test/multiverse/suites/capistrano/deployment_test.rb +12 -4
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +29 -1
- data/test/multiverse/suites/curb/Envfile +6 -2
- data/test/multiverse/suites/datamapper/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
- data/test/multiverse/suites/excon/Envfile +5 -4
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/httpclient/Envfile +0 -4
- data/test/multiverse/suites/marshalling/Envfile +12 -0
- data/test/multiverse/suites/marshalling/config/newrelic.yml +20 -0
- data/test/multiverse/suites/marshalling/marshalling_test.rb +60 -0
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_replica_set.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_server.rb +4 -4
- data/test/multiverse/suites/padrino/Envfile +0 -5
- data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +2 -1
- data/test/multiverse/suites/rails/ignore_test.rb +22 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +2 -2
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +1 -0
- data/test/multiverse/suites/resque/Envfile +0 -4
- data/test/multiverse/suites/sequel/Envfile +0 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +22 -0
- data/test/multiverse/suites/typhoeus/Envfile +1 -4
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -13
- data/test/new_relic/agent/agent_logger_test.rb +11 -0
- data/test/new_relic/agent/agent_test.rb +43 -20
- data/test/new_relic/agent/audit_logger_test.rb +7 -3
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +0 -1
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
- data/test/new_relic/agent/configuration/dotted_hash_test.rb +53 -0
- data/test/new_relic/agent/configuration/manager_test.rb +99 -6
- data/test/new_relic/agent/configuration/manual_source_test.rb +18 -0
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +8 -4
- data/test/new_relic/agent/database/sql_obfuscation_test.rb +76 -0
- data/test/new_relic/agent/database_test.rb +2 -38
- data/test/new_relic/agent/error_collector/notice_error_test.rb +21 -3
- data/test/new_relic/agent/error_collector_test.rb +15 -2
- data/test/new_relic/agent/event_loop_test.rb +202 -0
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +283 -182
- data/test/new_relic/agent/method_tracer_test.rb +1 -2
- data/test/new_relic/agent/new_relic_service_test.rb +83 -27
- data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -6
- data/test/new_relic/agent/rpm_agent_test.rb +1 -8
- data/test/new_relic/agent/sql_sampler_test.rb +10 -8
- data/test/new_relic/agent/threading/backtrace_service_test.rb +1 -1
- data/test/new_relic/agent/traced_method_stack_test.rb +45 -13
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -2
- data/test/new_relic/agent/transaction_test.rb +3 -3
- data/test/new_relic/agent_test.rb +47 -8
- data/test/new_relic/collection_helper_test.rb +5 -5
- data/test/new_relic/control/instrumentation_test.rb +56 -0
- data/test/new_relic/control_test.rb +4 -3
- data/test/new_relic/fake_collector.rb +7 -2
- data/test/new_relic/http_client_test_cases.rb +4 -4
- data/test/new_relic/latest_changes_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample_test.rb +19 -2
- data/test/performance/lib/performance/runner.rb +4 -4
- data/test/performance/suites/marshalling.rb +46 -30
- data/test/performance/suites/sql_obfuscation.rb +30 -0
- data/test/test_helper.rb +1 -1
- data/ui/helpers/developer_mode_helper.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
- metadata +84 -3
- metadata.gz.sig +0 -0
- data/test/environments/rails23/config/environments/development.rb +0 -11
@@ -155,10 +155,32 @@ bazbangbarn:
|
|
155
155
|
|
156
156
|
log = with_array_logger { NewRelic::Agent.manual_start }
|
157
157
|
|
158
|
-
assert_log_contains(log, /ERROR.*Failed
|
158
|
+
assert_log_contains(log, /ERROR.*Failed ERB processing/)
|
159
159
|
assert_log_contains(log, /\(erb\):4/)
|
160
160
|
end
|
161
161
|
|
162
|
+
def test_exclude_commented_out_erb_lines
|
163
|
+
config_contents = <<-YAML
|
164
|
+
development:
|
165
|
+
foo: "success!!"
|
166
|
+
test:
|
167
|
+
foo: "success!!"
|
168
|
+
boom:
|
169
|
+
# <%= this is not ruby %>
|
170
|
+
YAML
|
171
|
+
|
172
|
+
path = File.join(File.dirname(__FILE__), 'config', 'newrelic.yml')
|
173
|
+
setup_config(path, {}, config_contents)
|
174
|
+
setup_agent
|
175
|
+
|
176
|
+
log = with_array_logger { NewRelic::Agent.manual_start }
|
177
|
+
|
178
|
+
assert_equal "success!!", NewRelic::Agent.config[:foo]
|
179
|
+
|
180
|
+
refute_log_contains(log, /ERROR.*Failed ERB processing/)
|
181
|
+
refute_log_contains(log, /\(erb\)/)
|
182
|
+
end
|
183
|
+
|
162
184
|
def test_config_loads_from_env_NRCONFIG
|
163
185
|
ENV["NRCONFIG"] = "/tmp/foo/bar.yml"
|
164
186
|
assert_config_read_from("/tmp/foo/bar.yml")
|
@@ -184,4 +206,10 @@ bazbangbarn:
|
|
184
206
|
failure_message = "Did not find '#{message}' in log. Log contained:\n#{lines.join('')}"
|
185
207
|
assert (lines.any? { |line| line.match(message) }), failure_message
|
186
208
|
end
|
209
|
+
|
210
|
+
def refute_log_contains(log, message)
|
211
|
+
lines = log.array
|
212
|
+
failure_message = "Found unexpected '#{message}' in log. Log contained:\n#{lines.join('')}"
|
213
|
+
refute (lines.any? { |line| line.match(message) }), failure_message
|
214
|
+
end
|
187
215
|
end
|
@@ -2,8 +2,12 @@ suite_condition("Curb is not useful on JRuby") do
|
|
2
2
|
RUBY_PLATFORM != 'java'
|
3
3
|
end
|
4
4
|
|
5
|
+
# There appears to be a bug in curb 0.8.6 that manifests in hangs of this suite
|
6
|
+
# when run on Ruby 1.8.7 or REE, so don't run against that version on those
|
7
|
+
# Rubies.
|
8
|
+
curb_version_spec = RUBY_VERSION == "1.8.7" ? '0.8.5' : '~>0.8.6'
|
5
9
|
gemfile <<-RB
|
6
|
-
gem 'curb', '
|
10
|
+
gem 'curb', '#{curb_version_spec}'
|
7
11
|
gem 'rack'
|
8
12
|
gem 'json', :platforms => [:rbx, :mri_18]
|
9
13
|
|
@@ -12,7 +16,7 @@ gemfile <<-RB
|
|
12
16
|
RB
|
13
17
|
|
14
18
|
gemfile <<-RB
|
15
|
-
gem 'curb', '
|
19
|
+
gem 'curb', '#{curb_version_spec}'
|
16
20
|
gem 'rack'
|
17
21
|
gem 'json', :platforms => [:rbx, :mri_18]
|
18
22
|
RB
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
|
2
|
+
# Excon 0.10.0 doesn't seem to work on Rubinius 2.2.10
|
3
|
+
excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0)
|
4
|
+
else
|
5
|
+
excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0 0.10.0)
|
3
6
|
end
|
4
7
|
|
5
|
-
excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0 0.10.0)
|
6
|
-
|
7
8
|
excon_versions.each do |excon_version|
|
8
9
|
gemfile <<-RB
|
9
10
|
gem 'excon', '~> #{excon_version}'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
development:
|
3
|
+
error_collector:
|
4
|
+
enabled: true
|
5
|
+
apdex_t: 0.24
|
6
|
+
ssl: false
|
7
|
+
monitor_mode: true
|
8
|
+
license_key: bootstrap_newrelic_admin_license_key_000
|
9
|
+
developer_mode: false
|
10
|
+
app_name: test
|
11
|
+
host: 127.0.0.1
|
12
|
+
api_host: 127.0.0.1
|
13
|
+
port: <%= $collector && $collector.port %>
|
14
|
+
transaction_tracer:
|
15
|
+
record_sql: obfuscated
|
16
|
+
enabled: true
|
17
|
+
stack_trace_threshold: 0.5
|
18
|
+
capture_params: false
|
19
|
+
browser_monitoring:
|
20
|
+
auto_instrument: true
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'multiverse_helpers'
|
6
|
+
|
7
|
+
# These tests are intended to exercise the basic marshalling functionality of
|
8
|
+
# the agent in it's different permutations (Ruby and JSON)
|
9
|
+
class MarshallingTest < Minitest::Test
|
10
|
+
|
11
|
+
include MultiverseHelpers
|
12
|
+
|
13
|
+
setup_and_teardown_agent
|
14
|
+
|
15
|
+
def test_sends_metrics
|
16
|
+
NewRelic::Agent.record_metric('Boo', 42)
|
17
|
+
|
18
|
+
transmit_data
|
19
|
+
|
20
|
+
result = $collector.calls_for('metric_data')
|
21
|
+
assert_equal 1, result.length
|
22
|
+
assert_includes result.first.metric_names, 'Boo'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_sends_errors
|
26
|
+
NewRelic::Agent.notice_error(StandardError.new("Boom"))
|
27
|
+
|
28
|
+
transmit_data
|
29
|
+
|
30
|
+
result = $collector.calls_for('error_data')
|
31
|
+
assert_equal 1, result.length
|
32
|
+
assert_equal 1, result.first.errors.length
|
33
|
+
assert_equal "StandardError", result.first.errors.first.exception_class_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_sends_transaction_traces
|
37
|
+
with_config(:'transaction_tracer.transaction_threshold' => -1.0) do
|
38
|
+
Transactioner.new.do_it
|
39
|
+
end
|
40
|
+
|
41
|
+
transmit_data
|
42
|
+
|
43
|
+
result = $collector.calls_for('transaction_sample_data')
|
44
|
+
assert_equal 1, result.length
|
45
|
+
assert_equal "Controller/MarshallingTest::Transactioner/do_it", result.first.metric_name
|
46
|
+
end
|
47
|
+
|
48
|
+
class Transactioner
|
49
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
50
|
+
|
51
|
+
def do_it
|
52
|
+
end
|
53
|
+
|
54
|
+
add_transaction_tracer :do_it
|
55
|
+
end
|
56
|
+
|
57
|
+
def transmit_data
|
58
|
+
NewRelic::Agent.instance.send(:transmit_data)
|
59
|
+
end
|
60
|
+
end
|
@@ -61,7 +61,7 @@ module MongoOperationTests
|
|
61
61
|
@collection.save(@tribble)
|
62
62
|
|
63
63
|
metrics = build_test_metrics(:save)
|
64
|
-
|
64
|
+
metrics_with_attributes(metrics)
|
65
65
|
|
66
66
|
assert_metrics_not_recorded(['Datastore/operation/MongoDB/insert'])
|
67
67
|
end
|
@@ -143,7 +143,7 @@ class MongoServer
|
|
143
143
|
begin
|
144
144
|
self.client = client_class.new('localhost', self.port, :connect_timeout => 10)
|
145
145
|
rescue Mongo::ConnectionFailure => e
|
146
|
-
raise e unless message
|
146
|
+
raise e unless message == "Failed to connect to a master node at localhost:#{port}"
|
147
147
|
retry
|
148
148
|
end
|
149
149
|
end
|
@@ -152,7 +152,7 @@ class MongoServer
|
|
152
152
|
if pid
|
153
153
|
begin
|
154
154
|
Process.kill('TERM', pid)
|
155
|
-
rescue Errno::ESRCH
|
155
|
+
rescue Errno::ESRCH
|
156
156
|
# fine if we're already gone...
|
157
157
|
end
|
158
158
|
|
@@ -171,7 +171,7 @@ class MongoServer
|
|
171
171
|
def running?
|
172
172
|
return false unless pid
|
173
173
|
Process.kill(0, pid) == 1
|
174
|
-
rescue Errno::ESRCH
|
174
|
+
rescue Errno::ESRCH
|
175
175
|
false
|
176
176
|
end
|
177
177
|
|
@@ -214,7 +214,7 @@ class MongoServer
|
|
214
214
|
tries = 0
|
215
215
|
|
216
216
|
begin
|
217
|
-
|
217
|
+
yield
|
218
218
|
rescue exception => e
|
219
219
|
if message
|
220
220
|
raise e unless e.message.include? message
|
@@ -1,8 +1,3 @@
|
|
1
|
-
suite_condition("Sinatra not compatible with 1.8.6 or Rubinius") do
|
2
|
-
is_rbx = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
3
|
-
RUBY_VERSION != '1.8.6' && !is_rbx # https://github.com/rubinius/rubinius/issues/2671
|
4
|
-
end
|
5
|
-
|
6
1
|
gemfile <<-RB
|
7
2
|
# Gemspec from rubygems on this version gets illformed warnings on 1.8.7
|
8
3
|
gem 'http_router', '0.11.0', :git => 'git://github.com/joshbuddy/http_router.git', :tag => 'v0.11.0'
|
@@ -126,7 +126,7 @@ class RackAutoInstrumentationTest < Minitest::Test
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_middleware_that_returns_early_middleware_all_has_correct_call_times
|
129
|
-
|
129
|
+
freeze_time
|
130
130
|
|
131
131
|
get '/?return-early=true'
|
132
132
|
assert_metrics_recorded('Middleware/all' => { :total_exclusive_time => 3.0, :call_count => 2 })
|
@@ -11,7 +11,7 @@ if NewRelic::LanguageSupport.ree? ||
|
|
11
11
|
class GcController < ApplicationController
|
12
12
|
def gc_action
|
13
13
|
begin
|
14
|
-
|
14
|
+
NewRelic::Agent::StatsEngine::GCProfiler.init
|
15
15
|
initial_gc_count = current_gc_count
|
16
16
|
|
17
17
|
Timeout.timeout(5) do
|
@@ -19,6 +19,7 @@ class GcController < ApplicationController
|
|
19
19
|
long_string = "01234567" * 100_000
|
20
20
|
long_string = nil
|
21
21
|
another_long_string = "01234567" * 100_000
|
22
|
+
another_long_string = nil
|
22
23
|
end
|
23
24
|
end
|
24
25
|
rescue Timeout::Error
|
@@ -19,6 +19,21 @@ class IgnoredController < ApplicationController
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class ParentController < ApplicationController
|
23
|
+
newrelic_ignore_apdex
|
24
|
+
|
25
|
+
def foo(*args); end
|
26
|
+
|
27
|
+
add_transaction_tracer :foo
|
28
|
+
end
|
29
|
+
|
30
|
+
class ChildController < ParentController
|
31
|
+
def bar(*args); end
|
32
|
+
|
33
|
+
add_transaction_tracer :bar
|
34
|
+
end
|
35
|
+
|
36
|
+
|
22
37
|
class IgnoredActionsTest < RailsMultiverseTest
|
23
38
|
include MultiverseHelpers
|
24
39
|
|
@@ -54,4 +69,11 @@ class IgnoredActionsTest < RailsMultiverseTest
|
|
54
69
|
get 'ignored/action_to_ignore', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
55
70
|
assert_nil @response.headers["X-NewRelic-App-Data"]
|
56
71
|
end
|
72
|
+
|
73
|
+
def test_apdex_ignored_if_ignored_in_parent_class
|
74
|
+
get 'child/foo'
|
75
|
+
get 'child/bar'
|
76
|
+
|
77
|
+
assert_metrics_not_recorded("Apdex")
|
78
|
+
end
|
57
79
|
end
|
@@ -64,7 +64,7 @@ module Rails
|
|
64
64
|
else
|
65
65
|
gem 'rails'
|
66
66
|
end
|
67
|
-
rescue Gem::LoadError
|
67
|
+
rescue Gem::LoadError
|
68
68
|
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
69
69
|
exit 1
|
70
70
|
end
|
@@ -121,7 +121,7 @@ class Rails::Boot
|
|
121
121
|
|
122
122
|
Rails::Initializer.run(:set_load_path)
|
123
123
|
end
|
124
|
-
end
|
124
|
+
end
|
125
125
|
|
126
126
|
# All that for this:
|
127
127
|
Rails.boot!
|
@@ -13,6 +13,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
13
13
|
map.connect 'views/:action', :controller => 'views'
|
14
14
|
map.connect 'ignored/:action', :controller => 'ignored'
|
15
15
|
map.connect 'parameter_capture/:action', :controller => 'parameter_capture'
|
16
|
+
map.connect 'child/:action', :controller => 'child'
|
16
17
|
|
17
18
|
map.connect ':controller/:action'
|
18
19
|
end
|
@@ -114,4 +114,26 @@ module SinatraTestCases
|
|
114
114
|
assert_equal 200, last_response.status
|
115
115
|
assert_metrics_not_recorded(["Controller/Sinatra/#{app_name}/GET ignored"])
|
116
116
|
end
|
117
|
+
|
118
|
+
def test_rack_request_params_errors_are_swallowed
|
119
|
+
fail_on_second_params_call
|
120
|
+
|
121
|
+
get '/pass'
|
122
|
+
assert_equal 200, last_response.status
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_rack_request_params_errors_are_logged
|
126
|
+
NewRelic::Agent.logger.stubs(:debug)
|
127
|
+
NewRelic::Agent.logger.expects(:debug).with("Failed to get params from Rack request.", kind_of(StandardError)).at_least_once
|
128
|
+
|
129
|
+
fail_on_second_params_call
|
130
|
+
|
131
|
+
get '/pass'
|
132
|
+
end
|
133
|
+
|
134
|
+
def fail_on_second_params_call
|
135
|
+
Sinatra::Request.any_instance.
|
136
|
+
stubs(:params).returns({}).
|
137
|
+
then.raises("Rack::Request#params error")
|
138
|
+
end
|
117
139
|
end
|