newrelic_rpm 3.7.1.188 → 3.7.2.190.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data.tar.gz.sig +3 -2
  2. data/CHANGELOG +1 -1
  3. data/Guardfile +3 -3
  4. data/README.md +1 -1
  5. data/Rakefile +0 -2
  6. data/init.rb +2 -5
  7. data/lib/new_relic/agent.rb +3 -0
  8. data/lib/new_relic/agent/agent.rb +2 -0
  9. data/lib/new_relic/agent/configuration/default_source.rb +32 -14
  10. data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -2
  12. data/lib/new_relic/agent/cross_app_tracing.rb +2 -2
  13. data/lib/new_relic/agent/error_collector.rb +1 -1
  14. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -1
  15. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -8
  16. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -6
  17. data/lib/new_relic/agent/javascript_instrumentor.rb +27 -36
  18. data/lib/new_relic/agent/method_tracer.rb +20 -2
  19. data/lib/new_relic/agent/new_relic_service.rb +35 -27
  20. data/lib/new_relic/agent/request_sampler.rb +20 -13
  21. data/lib/new_relic/agent/sampler_collection.rb +4 -0
  22. data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
  23. data/lib/new_relic/agent/system_info.rb +25 -15
  24. data/lib/new_relic/agent/transaction.rb +23 -4
  25. data/lib/new_relic/agent/transaction_sampler.rb +1 -1
  26. data/lib/new_relic/cli/install.rb +1 -1
  27. data/lib/new_relic/control.rb +1 -0
  28. data/lib/new_relic/helper.rb +1 -29
  29. data/lib/new_relic/json_wrapper.rb +92 -0
  30. data/lib/new_relic/language_support.rb +4 -0
  31. data/lib/new_relic/rack/agent_hooks.rb +4 -0
  32. data/lib/new_relic/rack/browser_monitoring.rb +4 -0
  33. data/lib/new_relic/rack/developer_mode.rb +4 -1
  34. data/lib/new_relic/rack/error_collector.rb +5 -0
  35. data/lib/new_relic/rack/transaction_reset.rb +20 -0
  36. data/lib/new_relic/version.rb +1 -1
  37. data/lib/tasks/install.rake +0 -1
  38. data/newrelic_rpm.gemspec +1 -1
  39. data/test/agent_helper.rb +7 -8
  40. data/test/environments/norails/Gemfile +2 -1
  41. data/test/environments/rails21/Gemfile +2 -2
  42. data/test/environments/rails21/config/environment.rb +1 -3
  43. data/test/environments/rails21/config/environments/development.rb +0 -6
  44. data/test/environments/rails22/Gemfile +2 -2
  45. data/test/environments/rails22/config/environment.rb +0 -2
  46. data/test/environments/rails22/config/environments/development.rb +0 -6
  47. data/test/environments/rails23/Gemfile +2 -3
  48. data/test/environments/rails23/config/environment.rb +0 -9
  49. data/test/environments/rails23/config/environments/development.rb +0 -5
  50. data/test/environments/rails30/Gemfile +2 -2
  51. data/test/environments/rails31/Gemfile +2 -2
  52. data/test/environments/rails32/Gemfile +2 -1
  53. data/test/environments/rails40/Gemfile +2 -1
  54. data/test/intentional_fail.rb +1 -2
  55. data/test/multiverse/lib/multiverse/envfile.rb +1 -5
  56. data/test/multiverse/lib/multiverse/suite.rb +10 -27
  57. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +49 -67
  58. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +128 -0
  59. data/test/multiverse/suites/agent_only/marshaling_test.rb +7 -9
  60. data/test/multiverse/suites/agent_only/script/loading.rb +20 -0
  61. data/test/multiverse/suites/agent_only/start_up_test.rb +7 -0
  62. data/test/multiverse/suites/bare/Envfile +3 -0
  63. data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +43 -0
  64. data/test/multiverse/suites/rails/Envfile +0 -2
  65. data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
  66. data/test/multiverse/suites/rails/app/views/views/index.html.erb +1 -1
  67. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
  68. data/test/multiverse/suites/rails/request_statistics_test.rb +9 -4
  69. data/test/multiverse/suites/rails/view_instrumentation_test.rb +111 -106
  70. data/test/multiverse/suites/typhoeus/Envfile +1 -1
  71. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +16 -2
  72. data/test/multiverse/test/multiverse_test.rb +2 -2
  73. data/test/new_relic/agent/agent/connect_test.rb +1 -1
  74. data/test/new_relic/agent/agent/start_test.rb +1 -1
  75. data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
  76. data/test/new_relic/agent/agent_logger_test.rb +3 -7
  77. data/test/new_relic/agent/agent_test.rb +33 -57
  78. data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
  79. data/test/new_relic/agent/audit_logger_test.rb +5 -8
  80. data/test/new_relic/agent/autostart_test.rb +1 -1
  81. data/test/new_relic/agent/browser_token_test.rb +1 -1
  82. data/test/new_relic/agent/busy_calculator_test.rb +2 -4
  83. data/test/new_relic/agent/commands/agent_command_router_test.rb +5 -5
  84. data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
  85. data/test/new_relic/agent/commands/thread_profiler_session_test.rb +6 -6
  86. data/test/new_relic/agent/commands/xray_session_collection_test.rb +10 -10
  87. data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
  88. data/test/new_relic/agent/configuration/default_source_test.rb +4 -4
  89. data/test/new_relic/agent/configuration/environment_source_test.rb +14 -2
  90. data/test/new_relic/agent/configuration/manager_test.rb +3 -3
  91. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
  92. data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
  93. data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
  94. data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
  95. data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
  96. data/test/new_relic/agent/cross_app_tracing_test.rb +5 -4
  97. data/test/new_relic/agent/database_test.rb +1 -1
  98. data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
  99. data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +1 -1
  100. data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
  101. data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +2 -2
  102. data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
  103. data/test/new_relic/agent/error_collector_test.rb +5 -3
  104. data/test/new_relic/agent/event_listener_test.rb +1 -1
  105. data/test/new_relic/agent/harvester_test.rb +1 -1
  106. data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
  107. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
  108. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
  109. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +1 -1
  110. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +495 -495
  111. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
  112. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
  113. data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
  114. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
  115. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -6
  116. data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
  117. data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
  118. data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
  119. data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
  120. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +7 -7
  121. data/test/new_relic/agent/javascript_instrumentor_test.rb +47 -55
  122. data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
  123. data/test/new_relic/agent/memory_logger_test.rb +1 -1
  124. data/test/new_relic/agent/method_interrobang_test.rb +2 -3
  125. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -4
  126. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
  127. data/test/new_relic/agent/method_tracer_test.rb +6 -7
  128. data/test/new_relic/agent/method_visibility_test.rb +1 -1
  129. data/test/new_relic/agent/new_relic_service_test.rb +129 -19
  130. data/test/new_relic/agent/obfuscator_test.rb +1 -1
  131. data/test/new_relic/agent/pipe_channel_manager_test.rb +143 -145
  132. data/test/new_relic/agent/pipe_service_test.rb +2 -4
  133. data/test/new_relic/agent/request_sampler_test.rb +23 -19
  134. data/test/new_relic/agent/rpm_agent_test.rb +3 -3
  135. data/test/new_relic/agent/rules_engine_test.rb +1 -1
  136. data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
  137. data/test/new_relic/agent/sampler_collection_test.rb +3 -3
  138. data/test/new_relic/agent/sampler_test.rb +1 -1
  139. data/test/new_relic/agent/shim_agent_test.rb +1 -1
  140. data/test/new_relic/agent/sql_sampler_test.rb +4 -6
  141. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
  142. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +5 -5
  143. data/test/new_relic/agent/stats_engine/samplers_test.rb +2 -2
  144. data/test/new_relic/agent/stats_engine_test.rb +3 -3
  145. data/test/new_relic/agent/stats_hash_test.rb +2 -2
  146. data/test/new_relic/agent/stats_test.rb +1 -1
  147. data/test/new_relic/agent/threading/agent_thread_test.rb +2 -4
  148. data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
  149. data/test/new_relic/agent/threading/backtrace_service_test.rb +5 -5
  150. data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
  151. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
  152. data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
  153. data/test/new_relic/agent/transaction/pop_test.rb +1 -1
  154. data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
  155. data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
  156. data/test/new_relic/agent/transaction_interrobang_test.rb +2 -3
  157. data/test/new_relic/agent/transaction_sample_builder_test.rb +16 -14
  158. data/test/new_relic/agent/transaction_sampler_test.rb +16 -21
  159. data/test/new_relic/agent/transaction_state_test.rb +1 -1
  160. data/test/new_relic/agent/transaction_test.rb +61 -1
  161. data/test/new_relic/agent/transaction_timings_test.rb +1 -1
  162. data/test/new_relic/agent/worker_loop_test.rb +1 -1
  163. data/test/new_relic/agent_test.rb +2 -3
  164. data/test/new_relic/cli/deployments_test.rb +3 -3
  165. data/test/new_relic/coerce_test.rb +1 -1
  166. data/test/new_relic/collection_helper_test.rb +1 -1
  167. data/test/new_relic/control/class_methods_test.rb +2 -2
  168. data/test/new_relic/control/frameworks/rails_test.rb +1 -1
  169. data/test/new_relic/control_test.rb +9 -4
  170. data/test/new_relic/dependency_detection_test.rb +1 -1
  171. data/test/new_relic/dispatcher_test.rb +1 -1
  172. data/test/new_relic/environment_report_test.rb +4 -6
  173. data/test/new_relic/fake_collector.rb +1 -158
  174. data/test/new_relic/framework_test.rb +2 -1
  175. data/test/new_relic/http_client_test_cases.rb +2 -3
  176. data/test/new_relic/json_wrapper_test.rb +77 -0
  177. data/test/new_relic/language_support_test.rb +1 -1
  178. data/test/new_relic/license_test.rb +2 -2
  179. data/test/new_relic/load_test.rb +2 -8
  180. data/test/new_relic/local_environment_test.rb +1 -1
  181. data/test/new_relic/metric_data_test.rb +1 -1
  182. data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
  183. data/test/new_relic/metric_spec_test.rb +1 -1
  184. data/test/new_relic/multiverse_helpers.rb +26 -30
  185. data/test/new_relic/noticed_error_test.rb +1 -1
  186. data/test/new_relic/rack/agent_hooks_test.rb +1 -1
  187. data/test/new_relic/rack/all_test.rb +1 -1
  188. data/test/new_relic/rack/browser_monitoring_test.rb +4 -2
  189. data/test/new_relic/rack/deferred_instrumentation_test.rb +3 -5
  190. data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
  191. data/test/new_relic/rack/developer_mode_test.rb +1 -1
  192. data/test/new_relic/rack/error_collector_test.rb +8 -8
  193. data/test/new_relic/rack/transaction_reset_test.rb +35 -0
  194. data/test/new_relic/transaction_analysis/segment_summary_test.rb +2 -2
  195. data/test/new_relic/transaction_analysis_test.rb +1 -1
  196. data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
  197. data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -4
  198. data/test/new_relic/transaction_sample/segment_test.rb +3 -7
  199. data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
  200. data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
  201. data/test/new_relic/transaction_sample_test.rb +4 -6
  202. data/test/new_relic/version_number_test.rb +1 -1
  203. data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
  204. data/test/performance/lib/performance/json_reporter.rb +1 -1
  205. data/test/performance/suites/marshalling.rb +76 -0
  206. data/test/test_helper.rb +6 -39
  207. metadata +19 -12
  208. metadata.gz.sig +0 -0
  209. data/test/new_relic/helper_test.rb +0 -32
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- �� �ڪb��f�� w+�;Q�ڇ0g �Q�* �0T�hA(� ���9��Oh�r��
2
- )~��U�6�.g�V]�F�<�@!���{�1�Ug��k1�����͆c����[�5v�gU�H�:�L��WM��6������
1
+ c��eF6,���|���%�4�M�r7cH���/
2
+
3
+ 9~�5�X(����J�_VN�36B.�L�n�D�vԨw ��{������)�ѧ~���e�)���B��
data/CHANGELOG CHANGED
@@ -17,7 +17,7 @@
17
17
  successfully report data after an app forked or daemonized. Gems or scripts
18
18
  with daemonizing modes had to wait for agent support or find workarounds.
19
19
 
20
- With 3.7.1 setting `restart_thread_in_child: true` in your newrelic.yml
20
+ With 3.7.1 setting `restart_thread_in_children: true` in your newrelic.yml
21
21
  automatically restarts the agent in child processes without requiring custom
22
22
  code. For now the feature is opt-in, but future releases may default it on.
23
23
 
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
- guard :test, :test_paths => ['test/new_relic'], :all_after_pass => false do
1
+ guard :minitest, :test_folders => ['test/new_relic'], :all_after_pass => false do
2
2
  watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
3
3
  watch(%r{^test/.+_test\.rb$})
4
4
  watch(%r{^test/rum/.*}) { "test/new_relic/rack/browser_monitoring_test.rb" }
5
- watch('test/test_helper.rb') { "test" }
6
- watch('test/agent_helper.rb') { "test" }
5
+ watch('test/test_helper.rb') { "test/new_relic" }
6
+ watch('test/agent_helper.rb') { "test/new_relic" }
7
7
  end
data/README.md CHANGED
@@ -34,7 +34,7 @@ can be found on [our docs site](http://docs.newrelic.com/docs/ruby/supported-fra
34
34
 
35
35
  Any Rack based framework should work but may not be tested. Install
36
36
  the Ruby Agent as a gem and add the Developer Mode middleware if
37
- desired. Report any problems to support@newrelic.com.
37
+ desired. Report any problems by visiting support.newrelic.com.
38
38
 
39
39
  You can also monitor non-web applications. Refer to the "Other
40
40
  Environments" section under "Getting Started".
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rake/testtask'
3
- require "#{File.dirname(__FILE__)}/lib/new_relic/version.rb"
4
3
  require "#{File.dirname(__FILE__)}/lib/tasks/all.rb"
5
4
 
6
5
  task :default => :test
7
-
8
6
  task :test => ['test:newrelic']
9
7
 
10
8
  namespace :test do
data/init.rb CHANGED
@@ -7,13 +7,10 @@
7
7
  require 'new_relic/control'
8
8
 
9
9
  # If you are having problems seeing data, be sure and check the
10
- # newrelic_agent.log files in the log diretory of your application
10
+ # newrelic_agent.log files in the log directory of your application
11
11
  #
12
12
  # If you can't find any log files and you don't see anything in your
13
- # application log files, try uncommenting the two lines at the
14
- # bottom of this file to verify the plugin is being loaded,
15
- # then send the output to support@newrelic.com if you are unable to
16
- # resolve the issue.
13
+ # application log files please visit support.newrelic.com.
17
14
 
18
15
  # Initializer for the NewRelic Ruby Agent
19
16
 
@@ -139,6 +139,9 @@ module NewRelic
139
139
  # An unrecoverable client-side error that prevents the agent from continuing
140
140
  class UnrecoverableAgentException < ServerConnectionException; end
141
141
 
142
+ # An error while serializing data for the collector
143
+ class SerializationError < StandardError; end
144
+
142
145
  class BackgroundLoadingError < StandardError; end
143
146
 
144
147
  # placeholder name used when we cannot determine a transaction's name
@@ -951,6 +951,8 @@ module NewRelic
951
951
  @service.send(endpoint, items)
952
952
  rescue ForceRestartException, ForceDisconnectException
953
953
  raise
954
+ rescue SerializationError => e
955
+ NewRelic::Agent.logger.warn("Failed to serialize data for #{endpoint}, discarding. Error: ", e)
954
956
  rescue UnrecoverableServerException => e
955
957
  NewRelic::Agent.logger.warn("#{endpoint} data was rejected by remote service, discarding. Error: ", e)
956
958
  rescue => e
@@ -606,6 +606,12 @@ module NewRelic
606
606
  :type => String,
607
607
  :description => "Obfuscation level for sql queries reported in transaction trace segments (e.g. 'obfuscated', 'raw', 'none')."
608
608
  },
609
+ :'transaction_tracer.capture_attributes' => {
610
+ :default => true,
611
+ :public => true,
612
+ :type => Boolean,
613
+ :description => 'Enable or disable collection of custom attributes on transaction traces.'
614
+ },
609
615
  :'transaction_tracer.limit_segments' => {
610
616
  :default => 4000,
611
617
  :public => true,
@@ -684,6 +690,12 @@ module NewRelic
684
690
  :type => Boolean,
685
691
  :description => 'Enable or disable collection of source code for errors that support it.'
686
692
  },
693
+ :'error_collector.capture_attributes' => {
694
+ :default => true,
695
+ :public => true,
696
+ :type => Boolean,
697
+ :description => 'Enable or disable collection of custom attributes on errors.'
698
+ },
687
699
  :'error_collector.ignore_errors' => {
688
700
  :default => 'ActionController::RoutingError,Sinatra::NotFound',
689
701
  :public => true,
@@ -757,6 +769,18 @@ module NewRelic
757
769
  :type => Boolean,
758
770
  :description => 'Enable or disable HTTPS instrumentation by JavaScript agent on HTTP pages.'
759
771
  },
772
+ :'browser_monitoring.capture_attributes' => {
773
+ :default => false,
774
+ :public => false,
775
+ :type => Boolean,
776
+ :description => 'Include custom attributes in real user monitoring script in outgoing responses.'
777
+ },
778
+ :'capture_attributes.page_view_events' => {
779
+ :default => false,
780
+ :public => false,
781
+ :type => Boolean,
782
+ :description => 'Deprecated setting that is still in use by a few clients. Correct setting is browser_monitoring.capture_attributes.'
783
+ },
760
784
  :js_agent_loader => {
761
785
  :default => '',
762
786
  :public => false,
@@ -854,23 +878,11 @@ module NewRelic
854
878
  :type => Fixnum,
855
879
  :description => 'Maximum number of request events recorded by the analytics event sampling in a single harvest.'
856
880
  },
857
- :'capture_attributes.traces' => {
858
- :default => true,
859
- :public => false,
860
- :type => Boolean,
861
- :description => 'Include custom parameters in transaction traces and traced errors'
862
- },
863
- :'capture_attributes.transaction_events' => {
881
+ :'analytics_events.capture_attributes' => {
864
882
  :default => true,
865
883
  :public => true,
866
884
  :type => Boolean,
867
- :description => 'Include TT custom params in analytics event data.'
868
- },
869
- :'capture_attributes.page_view_events' => {
870
- :default => false,
871
- :public => false,
872
- :type => Boolean,
873
- :description => 'Include TT custom params in real user monitoring script in outgoing responses.'
885
+ :description => 'Include custom attributes in analytics event data.'
874
886
  },
875
887
  :restart_thread_in_children => {
876
888
  :default => false,
@@ -878,6 +890,12 @@ module NewRelic
878
890
  :type => Boolean,
879
891
  :description => 'Controls whether to check on running a transaction whether to respawn the harvest thread.'
880
892
  },
893
+ :normalize_json_string_encodings => {
894
+ :default => true,
895
+ :public => false,
896
+ :type => Boolean,
897
+ :description => 'Controls whether to normalize string encodings prior to serializing data for the collector to JSON.'
898
+ }
881
899
  }.freeze
882
900
 
883
901
  end
@@ -62,6 +62,7 @@ module NewRelic
62
62
  nr_env_var_keys = collect_new_relic_environment_variable_keys
63
63
 
64
64
  nr_env_var_keys.each do |key|
65
+ next if key.upcase == 'NEW_RELIC_LOG'
65
66
  set_value_from_environment_variable(key)
66
67
  end
67
68
  end
@@ -88,7 +88,7 @@ module NewRelic
88
88
  def save_referring_transaction_info(request_headers)
89
89
  txn_header = from_headers( request_headers, NEWRELIC_TXN_HEADER_KEYS ) or return
90
90
  txn_header = obfuscator.deobfuscate( txn_header )
91
- txn_info = NewRelic.json_load( txn_header )
91
+ txn_info = NewRelic::JSONWrapper.load( txn_header )
92
92
  NewRelic::Agent.logger.debug "Referring txn_info: %p" % [ txn_info ]
93
93
 
94
94
  TransactionState.get.referring_transaction_info = txn_info
@@ -147,7 +147,7 @@ module NewRelic
147
147
  content_length,
148
148
  transaction_guid()
149
149
  ]
150
- payload = obfuscator.obfuscate(NewRelic.json_dump(payload))
150
+ payload = obfuscator.obfuscate(NewRelic::JSONWrapper.dump(payload))
151
151
  end
152
152
 
153
153
  def set_transaction_custom_parameters
@@ -154,7 +154,7 @@ module NewRelic
154
154
  cross_app_id = NewRelic::Agent.config[:cross_process_id] or
155
155
  raise NewRelic::Agent::CrossAppTracing::Error, "no cross app ID configured"
156
156
  txn_guid = NewRelic::Agent::TransactionState.get.request_guid
157
- txn_data = NewRelic.json_dump([ txn_guid, false ])
157
+ txn_data = NewRelic::JSONWrapper.dump([ txn_guid, false ])
158
158
 
159
159
  request[ NR_ID_HEADER ] = obfuscator.obfuscate( cross_app_id )
160
160
  request[ NR_TXN_HEADER ] = obfuscator.obfuscate( txn_data )
@@ -273,7 +273,7 @@ module NewRelic
273
273
  decoded_appdata.set_encoding( ::Encoding::UTF_8 ) if
274
274
  decoded_appdata.respond_to?( :set_encoding )
275
275
 
276
- return NewRelic.json_load( decoded_appdata )
276
+ return NewRelic::JSONWrapper.load( decoded_appdata )
277
277
  end
278
278
 
279
279
 
@@ -163,7 +163,7 @@ module NewRelic
163
163
  # If anything else is left over, we treat it like a custom param
164
164
  def custom_params_from_opts(options)
165
165
  # If anything else is left over, treat it like a custom param:
166
- if Agent.config[:'capture_attributes.traces']
166
+ if Agent.config[:'error_collector.capture_attributes']
167
167
  fetch_from_options(options, :custom_params, {}).merge(options)
168
168
  else
169
169
  {}
@@ -38,7 +38,10 @@ module NewRelic
38
38
  class TyphoeusHTTPRequest
39
39
  def initialize(request)
40
40
  @request = request
41
- @uri = URI.parse(request.url)
41
+ @uri = case request.url
42
+ when ::URI then request.url
43
+ else ::URI.parse(request.url.to_s)
44
+ end
42
45
  end
43
46
 
44
47
  def type
@@ -23,8 +23,8 @@ module NewRelic
23
23
  end
24
24
 
25
25
  def start(name, id, payload)
26
- payload[:request] = TransactionState.get.request
27
- event = ControllerEvent.new(name, Time.now, nil, id, payload)
26
+ request = TransactionState.get.request
27
+ event = ControllerEvent.new(name, Time.now, nil, id, payload, request)
28
28
  push_event(event)
29
29
 
30
30
  if NewRelic::Agent.is_execution_traced? && !event.ignored?
@@ -96,7 +96,7 @@ module NewRelic
96
96
 
97
97
  def start_transaction(event)
98
98
  txn = Transaction.start(:controller,
99
- :request => event.payload[:request],
99
+ :request => event.request,
100
100
  :filtered_params => filter(event.payload[:params]))
101
101
  txn.apdex_start = (event.queue_start || event.time)
102
102
  txn.name = event.metric_name
@@ -120,16 +120,18 @@ module NewRelic
120
120
 
121
121
  class ControllerEvent < Event
122
122
  attr_accessor :parent, :scope
123
- attr_reader :queue_start
123
+ attr_reader :queue_start, :request
124
124
 
125
- def initialize(name, start, ending, transaction_id, payload)
126
- super
125
+ def initialize(name, start, ending, transaction_id, payload, request)
126
+ # We have a different initialize parameter list, so be explicit
127
+ super(name, start, ending, transaction_id, payload)
127
128
 
129
+ @request = request
128
130
  @controller_class = payload[:controller].split('::') \
129
131
  .inject(Object){|m,o| m.const_get(o)}
130
132
 
131
- if payload[:request] && payload[:request].respond_to?(:env)
132
- @queue_start = QueueTime.parse_frontend_timestamp(payload[:request].env, self.time)
133
+ if request && request.respond_to?(:env)
134
+ @queue_start = QueueTime.parse_frontend_timestamp(request.env, self.time)
133
135
  end
134
136
  end
135
137
 
@@ -25,19 +25,24 @@ module NewRelic
25
25
  event = pop_event(id)
26
26
 
27
27
  if NewRelic::Agent.is_execution_traced? && event.recordable?
28
- record_metrics(event)
29
- NewRelic::Agent.instance.stats_engine \
28
+ scope = NewRelic::Agent.instance.stats_engine \
30
29
  .pop_scope(event.scope, event.metric_name, event.end)
30
+ record_metrics(event, scope)
31
31
  end
32
32
  rescue => e
33
33
  log_notification_error(e, name, 'finish')
34
34
  end
35
35
 
36
- def record_metrics(event)
36
+ def record_metrics(event, scope)
37
+ exclusive = event.duration - scope.children_time
38
+ metric_specs = [
39
+ NewRelic::MetricSpec.new(event.metric_name),
40
+ NewRelic::MetricSpec.new(event.metric_name, StatsEngine::MetricStats::SCOPE_PLACEHOLDER)
41
+ ]
37
42
  NewRelic::Agent.instance.stats_engine \
38
- .record_metrics(event.metric_name,
39
- event.duration,
40
- :scoped => true)
43
+ .record_metrics_internal(metric_specs,
44
+ event.duration,
45
+ exclusive)
41
46
  end
42
47
 
43
48
  class RenderEvent < Event
@@ -71,6 +71,9 @@ module NewRelic
71
71
  else
72
72
  true
73
73
  end
74
+ rescue => e
75
+ ::NewRelic::Agent.logger.debug "Failure during insert_js", e
76
+ false
74
77
  end
75
78
 
76
79
  def missing_config?(key)
@@ -81,6 +84,9 @@ module NewRelic
81
84
  def browser_timing_header
82
85
  return "" unless insert_js?
83
86
  browser_timing_config + browser_timing_loader
87
+ rescue => e
88
+ ::NewRelic::Agent.logger.debug "Failure during RUM browser_timing_header construction", e
89
+ ""
84
90
  end
85
91
 
86
92
  # NOTE: Internal prototyping often overrides this, so leave name stable!
@@ -92,7 +98,7 @@ module NewRelic
92
98
  def browser_timing_config
93
99
  NewRelic::Agent::Transaction.freeze_name
94
100
  data = data_for_js_agent
95
- json = NewRelic.json_dump(data)
101
+ json = NewRelic::JSONWrapper.dump(data)
96
102
  html_safe_if_needed("\n<script type=\"text/javascript\">window.NREUM||(NREUM={});NREUM.info=#{json}</script>")
97
103
  end
98
104
 
@@ -106,7 +112,7 @@ module NewRelic
106
112
  TT_GUID_KEY = "ttGuid".freeze
107
113
  AGENT_TOKEN_KEY = "agentToken".freeze
108
114
  AGENT_KEY = "agent".freeze
109
- EXTRA_KEY = "extra".freeze
115
+ USER_ATTRIBUTES_KEY = "userAttributes".freeze
110
116
  SSL_FOR_HTTP_KEY = "sslForHttp".freeze
111
117
 
112
118
  # NOTE: Internal prototyping may override this, so leave name stable!
@@ -124,10 +130,11 @@ module NewRelic
124
130
  APPLICATION_TIME_KEY => timings.app_time_in_millis,
125
131
  TT_GUID_KEY => state.request_guid_to_include,
126
132
  AGENT_TOKEN_KEY => state.request_token,
127
- AGENT_KEY => NewRelic::Agent.config[:js_agent_file],
128
- EXTRA_KEY => obfuscator.obfuscate(formatted_extra_parameter_for_js_agent)
133
+ AGENT_KEY => NewRelic::Agent.config[:js_agent_file]
129
134
  }
135
+
130
136
  add_ssl_for_http(data)
137
+ add_user_attributes(data)
131
138
 
132
139
  data
133
140
  end
@@ -139,43 +146,27 @@ module NewRelic
139
146
  end
140
147
  end
141
148
 
142
- # NOTE: Internal prototyping may override this, so leave name stable!
143
- def data_for_js_agent_extra_parameter
144
- return {} unless include_custom_parameters_in_extra?
145
- current_transaction.custom_parameters.dup
146
- end
147
-
148
- def include_custom_parameters_in_extra?
149
- current_transaction &&
150
- NewRelic::Agent.config[:'analytics_events.enabled'] &&
151
- NewRelic::Agent.config[:'capture_attributes.page_view_events']
152
- end
149
+ def add_user_attributes(data)
150
+ return unless include_custom_parameters?
153
151
 
154
- def formatted_extra_parameter_for_js_agent
155
- format_extra_data(data_for_js_agent_extra_parameter)
152
+ params = event_params(current_transaction.custom_parameters)
153
+ json = NewRelic::JSONWrapper.dump(params)
154
+ data[USER_ATTRIBUTES_KEY] = obfuscator.obfuscate(json)
156
155
  end
157
156
 
158
- # Format the props using semicolon separated pairs separated by '=':
159
- # product=pro;user=bill@microsoft.com
160
- def format_extra_data(extra_props)
161
- event_params(extra_props).
162
- map {|k,v| format_pair(k, v)}.
163
- join(';')
157
+ # Still support deprecated capture_attributes.page_view_events for
158
+ # clients that use it. Could potentially be removed if we don't have
159
+ # anymore users with it set according to zeitgeist.
160
+ def include_custom_parameters?
161
+ has_custom_parameters? &&
162
+ (NewRelic::Agent.config[:'browser_monitoring.capture_attributes'] ||
163
+ NewRelic::Agent.config[:'capture_attributes.page_view_events'])
164
164
  end
165
165
 
166
- def format_pair(key, value)
167
- key = escape_special_characters(key)
168
- value = format_value(value)
169
- "#{key}=#{value}"
170
- end
171
-
172
- def escape_special_characters(string)
173
- string.to_s.tr("\";=", "':-" )
174
- end
175
-
176
- def format_value(v)
177
- v = "##{v}" if v.is_a?(Numeric)
178
- escape_special_characters(v)
166
+ def has_custom_parameters?
167
+ current_transaction &&
168
+ current_transaction.custom_parameters &&
169
+ !current_transaction.custom_parameters.empty?
179
170
  end
180
171
 
181
172
  def html_safe_if_needed(string)
@@ -403,8 +403,26 @@ module NewRelic
403
403
  # returns an eval-able string that contains the tracing code
404
404
  # for a fully traced metric including scoping
405
405
  def method_with_push_scope(method_name, metric_name_code, options)
406
- klass = (self === Module) ? "self" : "self.class"
407
-
406
+ # At this point, we expect 'self' to point to a Class or Module that
407
+ # has included the NewRelic::Agent::MethodTracer module, which means
408
+ # it should have an instance method defined called
409
+ # 'trace_execution_scoped'.
410
+ #
411
+ # If this is not the case, assume that
412
+ # we're relying on the fact that MethodTracer is included into the
413
+ # Module class by init_plugin, and try to call
414
+ # trace_execution_scoped as a class rather than instance method.
415
+ #
416
+ # The inclusion of MethodTracer into Module will be going away in
417
+ # the future, so if we detect people relying on that behavior, warn
418
+ # and record a supportability metric.
419
+ if self.method_defined?(:trace_execution_scoped)
420
+ klass = 'self'
421
+ else
422
+ NewRelic::Agent.logger.warn("Called add_method_tracer from #{self} without including the NewRelic::Agent::MethodTracer module. This is deprecated and will stop working in the future. Please see http://docs.newrelic.com/docs/ruby/ruby-custom-metric-collection for examples of correct add_method_tracer usage.")
423
+ NewRelic::Agent.increment_metric("Supportability/usage/improper_add_method_tracer")
424
+ klass = 'self.class'
425
+ end
408
426
  "def #{_traced_method_name(method_name, metric_name_code)}(*args, &block)
409
427
  #{options[:code_header]}
410
428
  result = #{klass}.trace_execution_scoped(\"#{metric_name_code}\",