newrelic_rpm 4.0.0.332 → 4.1.0.333

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -1
  3. data/CHANGELOG.md +22 -0
  4. data/LICENSE +1 -27
  5. data/README.md +4 -57
  6. data/lib/new_relic/agent.rb +0 -1
  7. data/lib/new_relic/agent/attribute_filter.rb +0 -1
  8. data/lib/new_relic/agent/configuration/default_source.rb +3 -32
  9. data/lib/new_relic/agent/error_collector.rb +0 -2
  10. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
  11. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
  12. data/lib/new_relic/agent/http_clients/uri_util.rb +12 -7
  13. data/lib/new_relic/agent/stats.rb +0 -14
  14. data/lib/new_relic/agent/stats_engine.rb +171 -3
  15. data/lib/new_relic/agent/supported_versions.rb +9 -9
  16. data/lib/new_relic/agent/traced_method_stack.rb +1 -1
  17. data/lib/new_relic/agent/transaction/attributes.rb +0 -2
  18. data/lib/new_relic/agent/transaction/external_request_segment.rb +1 -5
  19. data/lib/new_relic/agent/transaction/trace_node.rb +0 -10
  20. data/lib/new_relic/agent/transaction_sample_builder.rb +0 -3
  21. data/lib/new_relic/agent/transaction_sampler.rb +3 -13
  22. data/lib/new_relic/collection_helper.rb +0 -18
  23. data/lib/new_relic/control/frameworks/rails.rb +1 -21
  24. data/lib/new_relic/control/frameworks/rails3.rb +1 -1
  25. data/lib/new_relic/noticed_error.rb +1 -0
  26. data/lib/new_relic/version.rb +1 -1
  27. data/newrelic.yml +0 -4
  28. data/newrelic_rpm.gemspec +1 -1
  29. data/test/config/newrelic.yml +1 -1
  30. data/test/multiverse/lib/multiverse/runner.rb +9 -1
  31. data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
  32. data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
  33. data/test/multiverse/suites/capistrano/config/newrelic.yml +0 -1
  34. data/test/multiverse/suites/capistrano2/config/newrelic.yml +0 -1
  35. data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
  36. data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
  37. data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
  38. data/test/multiverse/suites/delayed_job/config/newrelic.yml +0 -1
  39. data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
  40. data/test/multiverse/suites/grape/config/newrelic.yml +0 -1
  41. data/test/multiverse/suites/high_security/config/newrelic.yml +0 -1
  42. data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
  43. data/test/multiverse/suites/httprb/config/newrelic.yml +0 -1
  44. data/test/multiverse/suites/json/config/newrelic.yml +0 -1
  45. data/test/multiverse/suites/marshalling/config/newrelic.yml +0 -1
  46. data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
  47. data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
  48. data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
  49. data/test/multiverse/suites/rack/config/newrelic.yml +0 -1
  50. data/test/multiverse/suites/rails/config/newrelic.yml +0 -1
  51. data/test/multiverse/suites/rake/config/newrelic.yml +0 -1
  52. data/test/multiverse/suites/redis/config/newrelic.yml +0 -1
  53. data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
  54. data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
  55. data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
  56. data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
  57. data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
  58. data/test/multiverse/suites/yajl/config/newrelic.yml +0 -1
  59. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
  60. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
  61. data/test/new_relic/agent/agent/connect_test.rb +3 -12
  62. data/test/new_relic/agent/agent/start_test.rb +4 -2
  63. data/test/new_relic/agent/busy_calculator_test.rb +13 -5
  64. data/test/new_relic/agent/pipe_channel_manager_test.rb +3 -4
  65. data/test/new_relic/agent/stats_engine_test.rb +313 -1
  66. data/test/new_relic/agent/stats_test.rb +0 -20
  67. data/test/new_relic/agent/traced_method_stack_test.rb +2 -5
  68. data/test/new_relic/agent/transaction/external_request_segment_test.rb +5 -0
  69. data/test/new_relic/agent/transaction/trace_node_test.rb +0 -19
  70. data/test/new_relic/agent/transaction_sampler_test.rb +3 -6
  71. data/test/new_relic/collection_helper_test.rb +0 -39
  72. data/test/new_relic/control_test.rb +2 -4
  73. data/test/new_relic/license_test.rb +4 -14
  74. data/test/performance/suites/external_segment.rb +0 -2
  75. data/test/performance/suites/rack_middleware.rb +1 -3
  76. data/test/performance/suites/transaction_tracing.rb +0 -1
  77. metadata +2 -94
  78. data/lib/conditional_vendored_metric_parser.rb +0 -9
  79. data/lib/new_relic/agent/instrumentation/rubyprof.rb +0 -26
  80. data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -188
  81. data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +0 -62
  82. data/lib/new_relic/merbtasks.rb +0 -10
  83. data/lib/new_relic/rack/developer_mode.rb +0 -321
  84. data/lib/new_relic/rack/developer_mode/segment_summary.rb +0 -56
  85. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +0 -328
  86. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +0 -75
  87. data/test/new_relic/metric_parser/metric_parser_test.rb +0 -17
  88. data/test/new_relic/rack/developer_mode/segment_summary_test.rb +0 -96
  89. data/test/new_relic/rack/developer_mode_helper_test.rb +0 -136
  90. data/test/new_relic/rack/developer_mode_test.rb +0 -96
  91. data/ui/helpers/developer_mode_helper.rb +0 -325
  92. data/ui/helpers/google_pie_chart.rb +0 -54
  93. data/ui/views/layouts/newrelic_default.rhtml +0 -48
  94. data/ui/views/newrelic/_explain_plans.rhtml +0 -27
  95. data/ui/views/newrelic/_sample.rhtml +0 -20
  96. data/ui/views/newrelic/_segment.rhtml +0 -28
  97. data/ui/views/newrelic/_segment_limit_message.rhtml +0 -1
  98. data/ui/views/newrelic/_segment_row.rhtml +0 -12
  99. data/ui/views/newrelic/_show_sample_detail.rhtml +0 -24
  100. data/ui/views/newrelic/_show_sample_sql.rhtml +0 -24
  101. data/ui/views/newrelic/_show_sample_summary.rhtml +0 -3
  102. data/ui/views/newrelic/_sql_row.rhtml +0 -16
  103. data/ui/views/newrelic/_stack_trace.rhtml +0 -15
  104. data/ui/views/newrelic/_table.rhtml +0 -12
  105. data/ui/views/newrelic/explain_sql.rhtml +0 -43
  106. data/ui/views/newrelic/file/images/arrow-close.png +0 -0
  107. data/ui/views/newrelic/file/images/arrow-open.png +0 -0
  108. data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
  109. data/ui/views/newrelic/file/images/file_icon.png +0 -0
  110. data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
  111. data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
  112. data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
  113. data/ui/views/newrelic/file/images/textmate.png +0 -0
  114. data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +0 -6243
  115. data/ui/views/newrelic/file/javascript/transaction_sample.js +0 -123
  116. data/ui/views/newrelic/file/stylesheets/style.css +0 -490
  117. data/ui/views/newrelic/index.rhtml +0 -70
  118. data/ui/views/newrelic/sample_not_found.rhtml +0 -2
  119. data/ui/views/newrelic/show_sample.rhtml +0 -81
  120. data/ui/views/newrelic/threads.rhtml +0 -45
  121. data/vendor/gems/metric_parser-0.1.0.pre1/.specification +0 -116
  122. data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +0 -5
  123. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +0 -70
  124. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +0 -18
  125. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +0 -35
  126. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +0 -37
  127. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +0 -93
  128. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +0 -11
  129. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +0 -50
  130. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +0 -71
  131. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +0 -47
  132. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +0 -21
  133. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +0 -52
  134. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +0 -28
  135. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +0 -32
  136. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +0 -21
  137. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +0 -15
  138. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +0 -59
  139. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +0 -44
  140. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +0 -24
  141. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +0 -11
  142. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +0 -35
  143. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +0 -21
  144. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +0 -38
  145. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +0 -11
  146. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +0 -56
  147. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -138
  148. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +0 -33
  149. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +0 -23
  150. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +0 -31
  151. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +0 -44
  152. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +0 -11
  153. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +0 -11
  154. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +0 -11
  155. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +0 -11
  156. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +0 -31
  157. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +0 -19
  158. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +0 -58
  159. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +0 -10
  160. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +0 -10
  161. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +0 -24
  162. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +0 -24
  163. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +0 -9
  164. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +0 -74
  165. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +0 -22
  166. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +0 -18
  167. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +0 -137
@@ -7,7 +7,6 @@ development:
7
7
  log_level: debug
8
8
  monitor_mode: true
9
9
  license_key: bootstrap_newrelic_admin_license_key_000
10
- developer_mode: false
11
10
  app_name: test
12
11
  host: 127.0.0.1
13
12
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -7,7 +7,6 @@ development:
7
7
  agent_enabled: true
8
8
  monitor_mode: true
9
9
  license_key: bootstrap_newrelic_admin_license_key_000
10
- developer_mode: false
11
10
  app_name: test
12
11
  host: 127.0.0.1
13
12
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -18,7 +18,6 @@ common: &default_settings
18
18
 
19
19
  development:
20
20
  <<: *default_settings
21
- developer: true
22
21
 
23
22
  test:
24
23
  <<: *default_settings
@@ -9,7 +9,6 @@ development:
9
9
  ssl: false
10
10
  monitor_mode: true
11
11
  license_key: bootstrap_newrelic_admin_license_key_000
12
- developer_mode: false
13
12
  app_name: test
14
13
  host: 127.0.0.1
15
14
  port: <%= $collector ||= nil; $collector && $collector.port %>
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  port: <%= $collector && $collector.port %>
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  port: <%= $collector && $collector.port %>
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -7,7 +7,6 @@ development:
7
7
  agent_enabled: true
8
8
  monitor_mode: true
9
9
  license_key: bootstrap_newrelic_admin_license_key_000
10
- developer_mode: false
11
10
  app_name: test
12
11
  host: 127.0.0.1
13
12
  api_host: 127.0.0.1
@@ -6,7 +6,6 @@ development:
6
6
  ssl: false
7
7
  monitor_mode: true
8
8
  license_key: bootstrap_newrelic_admin_license_key_000
9
- developer_mode: false
10
9
  app_name: test
11
10
  host: 127.0.0.1
12
11
  api_host: 127.0.0.1
@@ -7,7 +7,6 @@ development:
7
7
  log_level: debug
8
8
  monitor_mode: true
9
9
  license_key: bootstrap_newrelic_admin_license_key_000
10
- developer_mode: false
11
10
  app_name: test
12
11
  host: 127.0.0.1
13
12
  api_host: 127.0.0.1
@@ -8,7 +8,6 @@ development:
8
8
  ssl: false
9
9
  monitor_mode: true
10
10
  license_key: bootstrap_newrelic_admin_license_key_000
11
- developer_mode: false
12
11
  app_name: test
13
12
  host: 127.0.0.1
14
13
  api_host: 127.0.0.1
@@ -8,7 +8,6 @@ development:
8
8
  ssl: false
9
9
  monitor_mode: true
10
10
  license_key: bootstrap_newrelic_admin_license_key_000
11
- developer_mode: false
12
11
  app_name: test
13
12
  host: 127.0.0.1
14
13
  api_host: 127.0.0.1
@@ -24,14 +24,7 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
24
24
  NewRelic::Agent.instance.service = @service
25
25
  @local_host = nil
26
26
 
27
- @test_config = { :developer_mode => true }
28
27
  NewRelic::Agent.reset_config
29
- NewRelic::Agent.config.add_config_for_testing(@test_config)
30
- end
31
-
32
- def teardown
33
- NewRelic::Agent.reset_config
34
- NewRelic::Agent.config.remove_config(@test_config)
35
28
  end
36
29
 
37
30
  def control
@@ -129,16 +122,14 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
129
122
 
130
123
  def test_configure_transaction_tracer_negative
131
124
  with_config(:'transaction_tracer.enabled' => false) do
132
- assert @transaction_sampler.enabled?
125
+ refute @transaction_sampler.enabled?
133
126
  end
134
127
  end
135
128
 
136
129
  def test_configure_transaction_tracer_server_disabled
137
130
  config = NewRelic::Agent::Configuration::ServerSource.new('collect_traces' => false)
138
- with_config(:developer_mode => false) do
139
- with_config(config) do
140
- refute @transaction_sampler.enabled?
141
- end
131
+ with_config(config) do
132
+ refute @transaction_sampler.enabled?
142
133
  end
143
134
  end
144
135
 
@@ -61,7 +61,8 @@ class NewRelic::Agent::Agent::StartTest < Minitest::Test
61
61
  self.expects(:generate_environment_report)
62
62
  self.expects(:start_worker_thread)
63
63
  self.expects(:install_exit_handler)
64
- with_config(:dispatcher => 'test', :sync_startup => false, :monitor_mode => true, :license_key => 'a' * 40) do
64
+ with_config(:dispatcher => 'test', :sync_startup => false, :monitor_mode => true,
65
+ :license_key => 'a' * 40, :disable_samplers => false) do
65
66
  check_config_and_start_agent
66
67
  end
67
68
  end
@@ -73,7 +74,8 @@ class NewRelic::Agent::Agent::StartTest < Minitest::Test
73
74
  self.expects(:connect_in_foreground)
74
75
  self.expects(:start_worker_thread)
75
76
  self.expects(:install_exit_handler)
76
- with_config(:dispatcher => 'test', :sync_startup => true, :monitor_mode => true, :license_key => 'a' * 40) do
77
+ with_config(:dispatcher => 'test', :sync_startup => true, :monitor_mode => true,
78
+ :license_key => 'a' * 40, :disable_samplers => false) do
77
79
  check_config_and_start_agent
78
80
  end
79
81
  end
@@ -22,7 +22,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
22
22
  assert_equal 5, NewRelic::Agent::BusyCalculator.accumulator
23
23
  NewRelic::Agent::BusyCalculator.harvest_busy
24
24
 
25
- assert_metrics_recorded 'Instance/Busy' => {:call_count => 1, :total_call_time => 0.50}
25
+ assert_instance_busy_metric_recorded call_count: 1, total_call_time: 0.50
26
26
  end
27
27
 
28
28
  def test_split
@@ -32,7 +32,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
32
32
  NewRelic::Agent::BusyCalculator.dispatcher_start(now - 5.0)
33
33
  NewRelic::Agent::BusyCalculator.harvest_busy
34
34
 
35
- assert_metrics_recorded 'Instance/Busy' => {:call_count => 1, :total_call_time => 0.50}
35
+ assert_instance_busy_metric_recorded call_count: 1, total_call_time: 0.50
36
36
  end
37
37
 
38
38
  def test_reentrancy
@@ -49,7 +49,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
49
49
  NewRelic::Agent::BusyCalculator.dispatcher_finish(now - 1.0)
50
50
  NewRelic::Agent::BusyCalculator.harvest_busy
51
51
 
52
- assert_metrics_recorded 'Instance/Busy' => {:call_count => 1, :total_call_time => 0.50}
52
+ assert_instance_busy_metric_recorded call_count: 1, total_call_time: 0.50
53
53
  end
54
54
 
55
55
  def test_concurrency
@@ -71,7 +71,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
71
71
  NewRelic::Agent::BusyCalculator.stubs(:time_now).returns(now - 1.0)
72
72
  NewRelic::Agent::BusyCalculator.harvest_busy
73
73
 
74
- assert_metrics_recorded 'Instance/Busy' => {:call_count => 1, :total_call_time => 1.0}
74
+ assert_instance_busy_metric_recorded call_count: 1, total_call_time: 1.0
75
75
  end
76
76
 
77
77
  def test_dont_ignore_zero_counts
@@ -79,7 +79,7 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
79
79
  NewRelic::Agent::BusyCalculator.harvest_busy
80
80
  NewRelic::Agent::BusyCalculator.harvest_busy
81
81
 
82
- assert_metrics_recorded 'Instance/Busy' => {:call_count => 3}
82
+ assert_instance_busy_metric_recorded :call_count => 3
83
83
  end
84
84
 
85
85
  def test_can_turn_off_recording
@@ -93,4 +93,12 @@ class NewRelic::Agent::BusyCalculatorTest < Minitest::Test
93
93
  NewRelic::Agent::TransactionState.tl_clear_for_testing
94
94
  NewRelic::Agent::BusyCalculator.dispatcher_finish
95
95
  end
96
+
97
+ def assert_instance_busy_metric_recorded total_call_time: nil, call_count: 1
98
+ spec = NewRelic::MetricSpec.new("Instance/Busy")
99
+ stats = NewRelic::Agent.instance.stats_engine.to_h[spec]
100
+ refute_nil stats
101
+ assert_equal call_count, stats.call_count
102
+ assert_in_delta total_call_time, stats.total_call_time, 0.01 if total_call_time
103
+ end
96
104
  end
@@ -61,20 +61,19 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
61
61
 
62
62
  def test_listener_merges_transaction_traces
63
63
  sampler = NewRelic::Agent.agent.transaction_sampler
64
- sample = run_sample_trace
65
- assert_equal(1, sampler.count)
64
+ assert_equal(0, sampler.count)
66
65
 
67
66
  start_listener_with_pipe(667)
68
67
  run_child(667) do
69
68
  NewRelic::Agent.after_fork
70
69
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
71
- sample = run_sample_trace
70
+ run_sample_trace
72
71
  service = NewRelic::Agent::PipeService.new(667)
73
72
  service.transaction_sample_data(sampler.harvest!)
74
73
  end
75
74
  end
76
75
 
77
- assert_equal(2, sampler.count)
76
+ assert_equal(1, sampler.count)
78
77
  end
79
78
 
80
79
  def test_listener_merges_error_traces
@@ -7,11 +7,16 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','data_container_t
7
7
 
8
8
  class NewRelic::Agent::StatsEngineTest < Minitest::Test
9
9
  def setup
10
- @engine = NewRelic::Agent::StatsEngine.new
10
+ NewRelic::Agent.manual_start
11
+ @engine = NewRelic::Agent.instance.stats_engine
12
+ rescue => e
13
+ puts e
14
+ puts e.backtrace.join("\n")
11
15
  end
12
16
 
13
17
  def teardown
14
18
  @engine.reset!
19
+ NewRelic::Agent.shutdown
15
20
  super
16
21
  end
17
22
 
@@ -29,4 +34,311 @@ class NewRelic::Agent::StatsEngineTest < Minitest::Test
29
34
 
30
35
  include NewRelic::DataContainerTests
31
36
 
37
+
38
+ def test_record_unscoped_metrics_records_to_transaction_stats_if_in_txn
39
+ in_transaction do
40
+ @engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
41
+
42
+ # txn is still active, so metrics should not be merged into global
43
+ # stats hash yet
44
+ assert_metrics_not_recorded(['a', 'b'])
45
+ end
46
+
47
+ expected = {
48
+ :call_count => 1,
49
+ :total_call_time => 20,
50
+ :total_exclusive_time => 10
51
+ }
52
+ assert_metrics_recorded(
53
+ 'a' => expected,
54
+ 'b' => expected
55
+ )
56
+ end
57
+
58
+ def test_record_unscoped_metrics_records_to_global_metrics_if_no_txn
59
+ @engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
60
+ expected = {
61
+ :call_count => 1,
62
+ :total_call_time => 20,
63
+ :total_exclusive_time => 10
64
+ }
65
+ assert_metrics_recorded(
66
+ 'a' => expected,
67
+ 'b' => expected
68
+ )
69
+ end
70
+
71
+ def test_record_unscoped_metrics_takes_single_metric_name
72
+ @engine.tl_record_unscoped_metrics('a', 20)
73
+ assert_metrics_recorded(
74
+ 'a' => {
75
+ :call_count => 1,
76
+ :total_call_time => 20,
77
+ :total_exclusive_time => 20
78
+ }
79
+ )
80
+ end
81
+
82
+ def test_record_unscoped_metrics_takes_block_in_txn
83
+ in_transaction('txn') do
84
+ @engine.tl_record_unscoped_metrics('a') do |stat|
85
+ stat.total_call_time = 42
86
+ stat.call_count = 99
87
+ end
88
+ end
89
+
90
+ expected = { :total_call_time => 42, :call_count => 99 }
91
+ assert_metrics_recorded('a' => expected)
92
+ end
93
+
94
+ def test_record_unscoped_metrics_takes_block_outside_txn
95
+ @engine.tl_record_unscoped_metrics('a') do |stat|
96
+ stat.total_call_time = 42
97
+ stat.call_count = 99
98
+ end
99
+
100
+ expected = { :total_call_time => 42, :call_count => 99 }
101
+ assert_metrics_recorded('a' => expected)
102
+ end
103
+
104
+ def test_record_unscoped_metrics_is_thread_safe
105
+ threads = []
106
+ nthreads = 25
107
+ iterations = 100
108
+
109
+ nthreads.times do |tid|
110
+ threads << Thread.new do
111
+ iterations.times do
112
+ @engine.tl_record_unscoped_metrics('m1', 1)
113
+ @engine.tl_record_unscoped_metrics('m2', 1)
114
+ end
115
+ end
116
+ end
117
+ threads.each { |t| t.join }
118
+
119
+ assert_metrics_recorded(
120
+ 'm1' => { :call_count => nthreads * iterations },
121
+ 'm2' => { :call_count => nthreads * iterations }
122
+ )
123
+ end
124
+
125
+ def test_record_scoped_and_unscoped_metrics_records_scoped_and_unscoped
126
+ in_transaction('txn') do
127
+ @engine.tl_record_scoped_and_unscoped_metrics('a', nil, 20, 10)
128
+ assert_metrics_not_recorded('a')
129
+ end
130
+
131
+ expected = {
132
+ :call_count => 1,
133
+ :total_call_time => 20,
134
+ :total_exclusive_time => 10
135
+ }
136
+ assert_metrics_recorded(
137
+ 'a' => expected,
138
+ ['a', 'txn'] => expected
139
+ )
140
+ end
141
+
142
+ def test_record_scoped_and_unscoped_metrics_takes_block
143
+ in_transaction('txn') do
144
+ @engine.tl_record_scoped_and_unscoped_metrics('a', ['b']) do |stat|
145
+ stat.total_call_time = 42
146
+ stat.call_count = 99
147
+ end
148
+ end
149
+
150
+ expected = { :total_call_time => 42, :call_count => 99 }
151
+ assert_metrics_recorded(
152
+ 'a' => expected,
153
+ ['a', 'txn'] => expected,
154
+ 'b' => expected
155
+ )
156
+ end
157
+
158
+ def test_record_scoped_and_unscoped_metrics_records_multiple_unscoped_metrics
159
+ in_transaction('txn') do
160
+ @engine.tl_record_scoped_and_unscoped_metrics('a', ['b', 'c'], 20, 10)
161
+ assert_metrics_not_recorded(['a', 'b', 'c'])
162
+ end
163
+
164
+ expected = {
165
+ :call_count => 1,
166
+ :total_call_time => 20,
167
+ :total_exclusive_time => 10
168
+ }
169
+ assert_metrics_recorded(
170
+ 'a' => expected,
171
+ ['a', 'txn'] => expected,
172
+ 'b' => expected,
173
+ 'c' => expected
174
+ )
175
+ assert_metrics_not_recorded([
176
+ ['b', 'txn'],
177
+ ['c', 'txn']
178
+ ])
179
+ end
180
+
181
+ def test_record_scoped_and_unscoped_metrics_is_thread_safe
182
+ threads = []
183
+ nthreads = 25
184
+ iterations = 100
185
+
186
+ nthreads.times do |tid|
187
+ threads << Thread.new do
188
+ iterations.times do
189
+ in_transaction('txn') do
190
+ @engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
191
+ @engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
192
+ end
193
+ end
194
+ end
195
+ end
196
+ threads.each { |t| t.join }
197
+
198
+ expected = { :call_count => nthreads * iterations }
199
+ assert_metrics_recorded(
200
+ 'm1' => expected,
201
+ 'm2' => expected,
202
+ ['m1', 'txn'] => expected,
203
+ ['m2', 'txn'] => expected,
204
+ 'm3' => expected,
205
+ 'm4' => expected
206
+ )
207
+ end
208
+
209
+ def test_record_scoped_and_unscoped_metrics_records_unscoped_if_not_in_txn
210
+ @engine.tl_record_scoped_and_unscoped_metrics('a', ['b'], 20, 10)
211
+
212
+ expected = {
213
+ :call_count => 1,
214
+ :total_call_time => 20,
215
+ :total_exclusive_time => 10
216
+ }
217
+ assert_metrics_recorded_exclusive(
218
+ 'a' => expected,
219
+ 'b' => expected
220
+ )
221
+ end
222
+
223
+ def test_harvest
224
+ @engine.clear_stats
225
+
226
+ @engine.tl_record_unscoped_metrics "a", 10
227
+ @engine.tl_record_unscoped_metrics "c", 1
228
+ @engine.tl_record_unscoped_metrics "c", 3
229
+
230
+ assert_metrics_recorded({
231
+ "a" => {:call_count => 1, :total_call_time => 10},
232
+ "c" => {:call_count => 2, :total_call_time => 4}
233
+ })
234
+
235
+ harvested = @engine.harvest!.to_h
236
+
237
+ # after harvest, all the metrics should be reset
238
+ refute_metrics_recorded %w(a c)
239
+
240
+ spec_a = NewRelic::MetricSpec.new('a')
241
+
242
+ assert(harvested.has_key?(spec_a))
243
+ assert_equal(1, harvested[spec_a].call_count)
244
+ assert_equal(10, harvested[spec_a].total_call_time)
245
+ end
246
+
247
+ def test_harvest_applies_metric_rename_rules
248
+ rule = NewRelic::Agent::RulesEngine::ReplacementRule.new(
249
+ 'match_expression' => '[0-9]+',
250
+ 'replacement' => '*',
251
+ 'replace_all' => true
252
+ )
253
+ rules_engine = NewRelic::Agent::RulesEngine.new([rule])
254
+
255
+ @engine.metric_rules = rules_engine
256
+ @engine.tl_record_unscoped_metrics('Custom/foo/1/bar/22', 1)
257
+ @engine.tl_record_unscoped_metrics('Custom/foo/3/bar/44', 1)
258
+ @engine.tl_record_unscoped_metrics('Custom/foo/5/bar/66', 1)
259
+
260
+ harvested = @engine.harvest!.to_h
261
+
262
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/1/bar/22'))
263
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/3/bar/44'))
264
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/5/bar/66'))
265
+ merged = harvested[NewRelic::MetricSpec.new('Custom/foo/*/bar/*')]
266
+ assert_equal(3, merged.call_count)
267
+ end
268
+
269
+ def test_apply_rules_to_metric_data_respects_ignore_rules
270
+ rule = NewRelic::Agent::RulesEngine::ReplacementRule.new(
271
+ 'match_expression' => 'bar',
272
+ 'ignore' => 'true'
273
+ )
274
+ rules_engine = NewRelic::Agent::RulesEngine.new([rule])
275
+
276
+ stats_hash = NewRelic::Agent::StatsHash.new
277
+
278
+ stats_hash.record(NewRelic::MetricSpec.new('foo'), 90210)
279
+ stats_hash.record(NewRelic::MetricSpec.new('bar'), 90210)
280
+
281
+ renamed = @engine.apply_rules_to_metric_data(rules_engine, stats_hash)
282
+
283
+ assert_equal(1 , renamed.size)
284
+ assert_equal('foo', renamed.to_h.keys.first.name)
285
+ end
286
+
287
+ def test_harvest_with_merge
288
+ @engine.tl_record_unscoped_metrics "a", 1
289
+ assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 1}
290
+
291
+ harvest = @engine.harvest!
292
+
293
+ assert_metrics_not_recorded "a"
294
+
295
+ @engine.tl_record_unscoped_metrics "a", 2
296
+ assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 2}
297
+
298
+ # this should merge the contents of the previous harvest,
299
+ # so the stats for metric "a" should have 2 data points
300
+ @engine.merge!(harvest)
301
+ harvest = @engine.harvest!
302
+ stats = harvest[NewRelic::MetricSpec.new("a")]
303
+ assert_equal 2, stats.call_count
304
+ assert_equal 3, stats.total_call_time
305
+ end
306
+
307
+ def test_merge_merges
308
+ @engine.tl_record_unscoped_metrics "foo", 1
309
+
310
+ other_stats_hash = NewRelic::Agent::StatsHash.new()
311
+ other_stats_hash.record(NewRelic::MetricSpec.new('foo'), 1)
312
+ other_stats_hash.record(NewRelic::MetricSpec.new('bar'), 1)
313
+
314
+ @engine.merge!(other_stats_hash)
315
+
316
+ assert_metrics_recorded ({
317
+ 'foo' => {:call_count => 2},
318
+ 'bar' => {:call_count => 1}
319
+ })
320
+ end
321
+
322
+ def test_harvest_adds_harvested_at_time
323
+ t0 = freeze_time
324
+ result = @engine.harvest!
325
+ assert_equal(t0, result.harvested_at)
326
+ end
327
+
328
+ def test_record_unscoped_metrics_unscoped_metrics_only
329
+ in_transaction('scopey') do
330
+ @engine.tl_record_unscoped_metrics('foo', 42)
331
+ end
332
+ assert_metrics_recorded('foo' => { :call_count => 1, :total_call_time => 42 })
333
+ assert_metrics_not_recorded([['foo', 'scopey']])
334
+ end
335
+
336
+ def test_record_supportability_metric_count_records_counts_only
337
+ @engine.tl_record_supportability_metric_count('foo/bar', 1)
338
+ @engine.tl_record_supportability_metric_count('foo/bar', 42)
339
+ assert_metrics_recorded(['Supportability/foo/bar'] => {
340
+ :call_count => 42,
341
+ :total_call_time => 0
342
+ })
343
+ end
32
344
  end