newrelic_rpm 3.8.0.218 → 3.8.1.221
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +32 -0
- data/README.md +4 -7
- data/Rakefile +3 -0
- data/lib/new_relic/agent.rb +3 -7
- data/lib/new_relic/agent/agent.rb +4 -14
- data/lib/new_relic/agent/agent_logger.rb +19 -11
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +25 -12
- data/lib/new_relic/agent/configuration/manager.rb +14 -7
- data/lib/new_relic/agent/configuration/yaml_source.rb +39 -8
- data/lib/new_relic/agent/cross_app_monitor.rb +9 -7
- data/lib/new_relic/agent/cross_app_tracing.rb +6 -6
- data/lib/new_relic/agent/datastores/mongo.rb +6 -7
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +32 -13
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +4 -3
- data/lib/new_relic/agent/error_collector.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -69
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +77 -93
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/mongo.rb +26 -42
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +15 -6
- data/lib/new_relic/agent/method_tracer.rb +41 -92
- data/lib/new_relic/agent/request_sampler.rb +0 -1
- data/lib/new_relic/agent/rules_engine.rb +36 -12
- data/lib/new_relic/agent/shim_agent.rb +0 -1
- data/lib/new_relic/agent/sql_sampler.rb +8 -15
- data/lib/new_relic/agent/stats_engine.rb +2 -6
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +8 -2
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/supported_versions.rb +1 -1
- data/lib/new_relic/agent/traced_method_stack.rb +87 -0
- data/lib/new_relic/agent/transaction.rb +277 -107
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -2
- data/lib/new_relic/agent/transaction_sampler.rb +18 -27
- data/lib/new_relic/agent/transaction_state.rb +15 -40
- data/lib/new_relic/control/instance_methods.rb +8 -4
- data/lib/new_relic/recipes.rb +3 -3
- data/lib/new_relic/transaction_sample.rb +3 -7
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +3 -3
- data/newrelic_rpm.gemspec +15 -9
- data/test/agent_helper.rb +71 -36
- data/test/environments/norails/Gemfile +2 -0
- data/test/environments/rails21/Gemfile +2 -0
- data/test/environments/rails22/Gemfile +2 -0
- data/test/environments/rails23/Gemfile +2 -0
- data/test/environments/rails30/Gemfile +2 -0
- data/test/environments/rails31/Gemfile +2 -0
- data/test/environments/rails32/Gemfile +2 -0
- data/test/environments/rails40/Gemfile +2 -0
- data/test/environments/rails41/Gemfile +1 -0
- data/test/helpers/mongo_metric_builder.rb +1 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +2 -2
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +9 -1
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/logging_test.rb +2 -2
- data/test/multiverse/suites/agent_only/marshaling_test.rb +8 -9
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +14 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +30 -13
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +9 -8
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +43 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +77 -5
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/mongo/Envfile +4 -7
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +55 -16
- data/test/multiverse/suites/mongo/helpers/mongo_server.rb +6 -4
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +3 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +14 -14
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +45 -0
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/agent/connect_test.rb +4 -4
- data/test/new_relic/agent/agent_logger_test.rb +32 -0
- data/test/new_relic/agent/configuration/manager_test.rb +12 -4
- data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
- data/test/new_relic/agent/cross_app_monitor_test.rb +6 -2
- data/test/new_relic/agent/cross_app_tracing_test.rb +5 -5
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +7 -6
- data/test/new_relic/agent/error_collector_test.rb +1 -2
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +24 -11
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +12 -17
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +43 -32
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +3 -4
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +36 -20
- data/test/new_relic/agent/javascript_instrumentor_test.rb +1 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +15 -26
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +66 -103
- data/test/new_relic/agent/method_tracer_test.rb +2 -2
- data/test/new_relic/agent/mock_scope_listener.rb +3 -6
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -4
- data/test/new_relic/agent/rules_engine_test.rb +13 -0
- data/test/new_relic/agent/sql_sampler_test.rb +8 -10
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +18 -0
- data/test/new_relic/agent/stats_engine_test.rb +0 -173
- data/test/new_relic/agent/threading/agent_thread_test.rb +27 -26
- data/test/new_relic/agent/traced_method_stack_test.rb +139 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +2 -12
- data/test/new_relic/agent/transaction_sampler_test.rb +98 -107
- data/test/new_relic/agent/transaction_state_test.rb +52 -61
- data/test/new_relic/agent/transaction_test.rb +209 -140
- data/test/new_relic/agent_test.rb +3 -2
- data/test/new_relic/control_test.rb +10 -9
- data/test/new_relic/fake_collector.rb +34 -2
- data/test/new_relic/http_client_test_cases.rb +0 -5
- data/test/new_relic/license_test.rb +4 -2
- data/test/new_relic/local_environment_test.rb +14 -28
- data/test/new_relic/multiverse_helpers.rb +2 -2
- data/test/new_relic/rack/developer_mode_test.rb +4 -5
- data/test/new_relic/transaction_ignoring_test_cases.rb +104 -0
- data/test/new_relic/transaction_sample_test.rb +14 -7
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +6 -3
- data/test/performance/suites/transaction_tracing.rb +4 -1
- data/test/test_helper.rb +31 -60
- data/ui/views/newrelic/show_sample.rhtml +1 -1
- metadata +46 -101
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +0 -114
- data/lib/new_relic/agent/transaction/pop.rb +0 -52
- data/test/new_relic/agent/transaction/pop_test.rb +0 -79
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.1.221
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
K0ZZTXduQWIrVm1OT2h2MVMrc0poYmpaMzBQS2d6NnZMaFQ2dW5pZUNqTGs5
|
42
42
|
d0dHbWxTSwpZamJudkE5cXJhTExhalNqCi0tLS0tRU5EIENFUlRJRklDQVRF
|
43
43
|
LS0tLS0K
|
44
|
-
date: 2014-
|
44
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
@@ -92,7 +92,7 @@ dependencies:
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 0.13.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
95
|
+
name: yard
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
@@ -107,22 +107,6 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: rdoc
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 2.4.2
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 2.4.2
|
126
110
|
- !ruby/object:Gem::Dependency
|
127
111
|
name: rails
|
128
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,38 +123,6 @@ dependencies:
|
|
139
123
|
- - ~>
|
140
124
|
- !ruby/object:Gem::Version
|
141
125
|
version: 3.2.13
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: sqlite3
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - '='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.3.8
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - '='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.3.8
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: sequel
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ~>
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 3.46.0
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ~>
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 3.46.0
|
174
126
|
- !ruby/object:Gem::Dependency
|
175
127
|
name: pry
|
176
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +187,22 @@ dependencies:
|
|
235
187
|
- - ~>
|
236
188
|
- !ruby/object:Gem::Version
|
237
189
|
version: 0.9.1
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: sqlite3
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - '='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 1.3.8
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - '='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: 1.3.8
|
238
206
|
description: ! 'New Relic is a performance management system, developed by New Relic,
|
239
207
|
|
240
208
|
Inc (http://www.newrelic.com). New Relic provides you with deep
|
@@ -401,17 +369,16 @@ files:
|
|
401
369
|
- lib/new_relic/agent/stats_engine/metric_stats.rb
|
402
370
|
- lib/new_relic/agent/stats_engine/samplers.rb
|
403
371
|
- lib/new_relic/agent/stats_engine/stats_hash.rb
|
404
|
-
- lib/new_relic/agent/stats_engine/transactions.rb
|
405
372
|
- lib/new_relic/agent/supported_versions.rb
|
406
373
|
- lib/new_relic/agent/system_info.rb
|
407
374
|
- lib/new_relic/agent/threading/agent_thread.rb
|
408
375
|
- lib/new_relic/agent/threading/backtrace_node.rb
|
409
376
|
- lib/new_relic/agent/threading/backtrace_service.rb
|
410
377
|
- lib/new_relic/agent/threading/thread_profile.rb
|
378
|
+
- lib/new_relic/agent/traced_method_stack.rb
|
411
379
|
- lib/new_relic/agent/transaction.rb
|
412
380
|
- lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb
|
413
381
|
- lib/new_relic/agent/transaction/force_persist_sample_buffer.rb
|
414
|
-
- lib/new_relic/agent/transaction/pop.rb
|
415
382
|
- lib/new_relic/agent/transaction/slowest_sample_buffer.rb
|
416
383
|
- lib/new_relic/agent/transaction/transaction_sample_buffer.rb
|
417
384
|
- lib/new_relic/agent/transaction/xray_sample_buffer.rb
|
@@ -744,6 +711,7 @@ files:
|
|
744
711
|
- test/multiverse/suites/agent_only/start_up_test.rb
|
745
712
|
- test/multiverse/suites/agent_only/testing_app.rb
|
746
713
|
- test/multiverse/suites/agent_only/thread_profiling_test.rb
|
714
|
+
- test/multiverse/suites/agent_only/transaction_ignoring_test.rb
|
747
715
|
- test/multiverse/suites/agent_only/xray_sessions_test.rb
|
748
716
|
- test/multiverse/suites/bare/Envfile
|
749
717
|
- test/multiverse/suites/bare/standalone_instrumentation_test.rb
|
@@ -797,6 +765,7 @@ files:
|
|
797
765
|
- test/multiverse/suites/rails/mongrel_queue_depth_test.rb
|
798
766
|
- test/multiverse/suites/rails/queue_time_test.rb
|
799
767
|
- test/multiverse/suites/rails/request_statistics_test.rb
|
768
|
+
- test/multiverse/suites/rails/transaction_ignoring_test.rb
|
800
769
|
- test/multiverse/suites/rails/view_instrumentation_test.rb
|
801
770
|
- test/multiverse/suites/resque/Envfile
|
802
771
|
- test/multiverse/suites/resque/Rakefile
|
@@ -922,9 +891,9 @@ files:
|
|
922
891
|
- test/new_relic/agent/threading/fake_thread.rb
|
923
892
|
- test/new_relic/agent/threading/thread_profile_test.rb
|
924
893
|
- test/new_relic/agent/threading/threaded_test_case.rb
|
894
|
+
- test/new_relic/agent/traced_method_stack_test.rb
|
925
895
|
- test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb
|
926
896
|
- test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb
|
927
|
-
- test/new_relic/agent/transaction/pop_test.rb
|
928
897
|
- test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
|
929
898
|
- test/new_relic/agent/transaction/xray_sample_buffer_test.rb
|
930
899
|
- test/new_relic/agent/transaction_interrobang_test.rb
|
@@ -977,6 +946,7 @@ files:
|
|
977
946
|
- test/new_relic/rack/transaction_reset_test.rb
|
978
947
|
- test/new_relic/transaction_analysis/segment_summary_test.rb
|
979
948
|
- test/new_relic/transaction_analysis_test.rb
|
949
|
+
- test/new_relic/transaction_ignoring_test_cases.rb
|
980
950
|
- test/new_relic/transaction_sample/composite_segment_test.rb
|
981
951
|
- test/new_relic/transaction_sample/fake_segment_test.rb
|
982
952
|
- test/new_relic/transaction_sample/segment_test.rb
|
@@ -1100,54 +1070,28 @@ licenses:
|
|
1100
1070
|
- New Relic
|
1101
1071
|
- MIT
|
1102
1072
|
- Ruby
|
1103
|
-
post_install_message: ! "# New Relic Ruby Agent Release Notes #\n\n## v3.8.
|
1104
|
-
Better
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
\
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
separately.\n\n* More accurate GC measurements on multi-threaded web servers\n\n
|
1124
|
-
\ The agent could previously have reported inaccurate GC times on multi-threaded\n
|
1125
|
-
\ web servers such as Puma. It will now correctly report GC timings in\n multi-threaded
|
1126
|
-
contexts.\n\n* Improved ActiveMerchant instrumentation\n\n The agent will now trace
|
1127
|
-
the store, unstore, and update methods on\n ActiveMerchant gateways. In addition,
|
1128
|
-
a bug preventing ActiveMerchant\n instrumentation from working on Ruby 1.9+ has
|
1129
|
-
been fixed.\n\n Thanks to Troex Nevelin for the contribution!\n\n* More robust
|
1130
|
-
Real User Monitoring script injection with charset meta tags\n\n Previous versions
|
1131
|
-
of the agent with Real User Monitoring enabled could have\n injected JavaScript
|
1132
|
-
code into the page above a charset meta tag. By the HTML5\n spec, the charset tag
|
1133
|
-
must appear in the first 1024 bytes of the page, so the\n Ruby agent will now attempt
|
1134
|
-
to inject RUM script after a charset tag, if one\n is present.\n\n* More robust
|
1135
|
-
connection sequence with New Relic servers\n\n A rare bug that could cause the
|
1136
|
-
agent's initial connection handshake with\n New Relic servers to silently fail
|
1137
|
-
has been fixed, and better logging has been\n added to the related code path to
|
1138
|
-
ease diagnosis of any future issues.\n\n* Prevent over-counting of queue time with
|
1139
|
-
nested transactions\n\n When using add_transaction_tracer on methods called from
|
1140
|
-
within a Rails or\n Sinatra action, it was previously possible to get inflated
|
1141
|
-
queue time\n measurements, because queue time would be recorded for both the outer\n
|
1142
|
-
\ transaction (the Rails or Sinatra action) and the inner transaction (the\n method
|
1143
|
-
given to add_transaction_tracer). This has been fixed, so only the\n outermost
|
1144
|
-
transaction will now record queue time.\n\n See https://github.com/newrelic/rpm/blob/master/CHANGELOG
|
1073
|
+
post_install_message: ! "# New Relic Ruby Agent Release Notes #\n\n## v3.8.1 ##\n\n*
|
1074
|
+
Better handling for Rack applications implemented as middlewares\n\n When using
|
1075
|
+
a Sinatra application as a middleware around another app (for\n example, a Rails
|
1076
|
+
app), or manually instrumenting a Rack middleware wrapped\n around another application,
|
1077
|
+
the agent would previously generate two separate\n transaction names in the New
|
1078
|
+
Relic UI (one for the middleware, and one for\n the inner application).\n\n As
|
1079
|
+
of this release, the agent will instead unify these two parts into a single\n transaction
|
1080
|
+
in the UI. The unified name will be the name assigned to the\n inner-most traced
|
1081
|
+
transaction by default. Calls to\n NewRelic::Agent.set_transaction_name will continue
|
1082
|
+
to override the default\n names assigned by the agent's instrumentation code.\n\n
|
1083
|
+
\ This change also makes it possible to run X-Ray sessions against transactions\n
|
1084
|
+
\ of the 'inner' application in cases where one instrumented app is wrapped in\n
|
1085
|
+
\ another that's implemented as a middleware.\n\n* Support for mongo-1.10.0\n\n
|
1086
|
+
\ The Ruby agent now instruments version 1.10.0 of the mongo gem (versions 1.8.x\n
|
1087
|
+
\ and 1.9.x were already supported, and continue to be).\n\n* Allow setting configuration
|
1088
|
+
file path via an option to manual_start\n\n Previously, passing the :config_path
|
1089
|
+
option to NewRelic::Agent.manual_start\n would not actually affect the location
|
1090
|
+
that the agent would use to look for\n its configuration file. This has been fixed,
|
1091
|
+
and the log messages emitted when\n a configuration file is not found should now
|
1092
|
+
be more helpful.\n\n See https://github.com/newrelic/rpm/blob/master/CHANGELOG
|
1145
1093
|
for a full list of\n changes.\n"
|
1146
|
-
rdoc_options:
|
1147
|
-
- --line-numbers
|
1148
|
-
- --inline-source
|
1149
|
-
- --title
|
1150
|
-
- New Relic Ruby Agent
|
1094
|
+
rdoc_options: []
|
1151
1095
|
require_paths:
|
1152
1096
|
- lib
|
1153
1097
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -1169,3 +1113,4 @@ signing_key:
|
|
1169
1113
|
specification_version: 3
|
1170
1114
|
summary: New Relic Ruby Agent
|
1171
1115
|
test_files: []
|
1116
|
+
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,114 +0,0 @@
|
|
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
|
-
module NewRelic
|
6
|
-
module Agent
|
7
|
-
class StatsEngine
|
8
|
-
# A simple stack element that tracks the current name and length
|
9
|
-
# of the executing stack
|
10
|
-
class ScopeStackElement
|
11
|
-
attr_reader :deduct_call_time_from_parent, :tag
|
12
|
-
attr_accessor :name, :start_time, :children_time
|
13
|
-
def initialize(tag, start_time, deduct_call_time)
|
14
|
-
@tag = tag
|
15
|
-
@start_time = start_time
|
16
|
-
@deduct_call_time_from_parent = deduct_call_time
|
17
|
-
@children_time = 0
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Handles pushing and popping elements onto an internal stack that
|
22
|
-
# tracks where time should be allocated in Transaction Traces
|
23
|
-
module Transactions
|
24
|
-
|
25
|
-
# Defines methods that stub out the stats engine methods
|
26
|
-
# when the agent is disabled
|
27
|
-
module Shim # :nodoc:
|
28
|
-
def start_transaction(*args); end
|
29
|
-
def end_transaction; end
|
30
|
-
def push_scope(*args); end
|
31
|
-
def transaction_sampler=(*args); end
|
32
|
-
def pop_scope(*args); end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
# Pushes a scope onto the transaction stack - this generates a
|
37
|
-
# TransactionSample::Segment at the end of transaction execution
|
38
|
-
# The generated segment will not be named until the corresponding
|
39
|
-
# pop_scope call is made.
|
40
|
-
# +tag+ should be a Symbol, and is only used for debugging purposes to
|
41
|
-
# identify this scope if the stack gets corrupted.
|
42
|
-
def push_scope(tag, time = Time.now.to_f, deduct_call_time_from_parent = true)
|
43
|
-
stack = scope_stack
|
44
|
-
transaction_sampler.notice_push_scope(time) if sampler_enabled?
|
45
|
-
scope = ScopeStackElement.new(tag, time, deduct_call_time_from_parent)
|
46
|
-
stack.push scope
|
47
|
-
scope
|
48
|
-
end
|
49
|
-
|
50
|
-
# Pops a scope off the transaction stack - this updates the
|
51
|
-
# transaction sampler that we've finished execution of a traced method
|
52
|
-
# +expected_scope+ should be the ScopeStackElement that was returned by
|
53
|
-
# the corresponding push_scope call.
|
54
|
-
# +name+ is the name that will be applied to the generated transaction
|
55
|
-
# trace segment.
|
56
|
-
def pop_scope(expected_scope, name, time=Time.now.to_f)
|
57
|
-
stack = scope_stack
|
58
|
-
scope = stack.pop
|
59
|
-
fail "unbalanced pop from blame stack, got #{scope ? scope.tag : 'nil'}, expected #{expected_scope ? expected_scope.tag : 'nil'}" if scope != expected_scope
|
60
|
-
|
61
|
-
if !stack.empty?
|
62
|
-
if scope.deduct_call_time_from_parent
|
63
|
-
stack.last.children_time += (time - scope.start_time)
|
64
|
-
else
|
65
|
-
stack.last.children_time += scope.children_time
|
66
|
-
end
|
67
|
-
end
|
68
|
-
transaction_sampler.notice_pop_scope(name, time) if sampler_enabled?
|
69
|
-
scope.name = name
|
70
|
-
scope
|
71
|
-
end
|
72
|
-
|
73
|
-
def sampler_enabled?
|
74
|
-
Agent.config[:'transaction_tracer.enabled'] || Agent.config[:developer_mode]
|
75
|
-
end
|
76
|
-
|
77
|
-
def transaction_sampler
|
78
|
-
Agent.instance.transaction_sampler
|
79
|
-
end
|
80
|
-
|
81
|
-
# deprecated--used to add transaction sampler, now we always look to the agent
|
82
|
-
def transaction_sampler= sampler
|
83
|
-
NewRelic::Agent.logger.warn("NewRelic::Agent::StatsEngine#transaction_sampler is deprecated")
|
84
|
-
end
|
85
|
-
|
86
|
-
# Start a new transaction, unless one is already in progress
|
87
|
-
def start_transaction
|
88
|
-
NewRelic::Agent.instance.events.notify(:start_transaction)
|
89
|
-
end
|
90
|
-
|
91
|
-
# Try to clean up gracefully, otherwise we leave things hanging around on thread locals.
|
92
|
-
# If it looks like a transaction is still in progress, then maybe this is an inner transaction
|
93
|
-
# and is ignored.
|
94
|
-
#
|
95
|
-
def end_transaction
|
96
|
-
stack = scope_stack
|
97
|
-
|
98
|
-
if stack && stack.empty?
|
99
|
-
NewRelic::Agent::TransactionState.get.clear_stats_scope_stack
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def transaction_stats_hash
|
104
|
-
Transaction.current && Transaction.current.stats_hash
|
105
|
-
end
|
106
|
-
|
107
|
-
# Returns the current scope stack, memoized to a thread local variable
|
108
|
-
def scope_stack
|
109
|
-
NewRelic::Agent::TransactionState.get.stats_scope_stack
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,52 +0,0 @@
|
|
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 'new_relic/agent/instrumentation'
|
6
|
-
module NewRelic
|
7
|
-
module Agent
|
8
|
-
class Transaction
|
9
|
-
module Pop
|
10
|
-
def log_underflow
|
11
|
-
::NewRelic::Agent.logger.error "Underflow in transaction: #{caller.join("\n ")}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def record_transaction_cpu
|
15
|
-
burn = cpu_burn
|
16
|
-
transaction_sampler.notice_transaction_cpu_time(burn) if burn
|
17
|
-
end
|
18
|
-
|
19
|
-
def normal_cpu_burn
|
20
|
-
return unless @process_cpu_start
|
21
|
-
process_cpu - @process_cpu_start
|
22
|
-
end
|
23
|
-
|
24
|
-
def jruby_cpu_burn
|
25
|
-
return unless @jruby_cpu_start
|
26
|
-
burn = (jruby_cpu_time - @jruby_cpu_start)
|
27
|
-
# record_jruby_cpu_burn(burn)
|
28
|
-
burn
|
29
|
-
end
|
30
|
-
|
31
|
-
# we need to do this here because the normal cpu sampler
|
32
|
-
# process doesn't work on JRuby. See the cpu_sampler.rb file
|
33
|
-
# to understand where cpu is recorded for non-jruby processes
|
34
|
-
def record_jruby_cpu_burn(burn)
|
35
|
-
NewRelic::Agent.record_metric(NewRelic::Metrics::USER_TIME, burn)
|
36
|
-
end
|
37
|
-
|
38
|
-
def cpu_burn
|
39
|
-
normal_cpu_burn || jruby_cpu_burn
|
40
|
-
end
|
41
|
-
|
42
|
-
def traced?
|
43
|
-
NewRelic::Agent.is_execution_traced?
|
44
|
-
end
|
45
|
-
|
46
|
-
def current_stack_metric
|
47
|
-
metric_name
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,79 +0,0 @@
|
|
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 File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
|
6
|
-
require 'new_relic/agent/transaction/pop'
|
7
|
-
class NewRelic::Agent::Transaction::PopTest < Minitest::Test
|
8
|
-
include NewRelic::Agent::Transaction::Pop
|
9
|
-
|
10
|
-
attr_reader :agent
|
11
|
-
attr_reader :transaction_sampler
|
12
|
-
attr_reader :sql_sampler
|
13
|
-
|
14
|
-
def setup
|
15
|
-
@transaction_type_stack = []
|
16
|
-
@agent = mock('agent')
|
17
|
-
@transaction_sampler = mock('transaction sampler')
|
18
|
-
@sql_sampler = mock('sql sampler')
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_log_underflow
|
22
|
-
expects_logging(:error, regexp_matches(/Underflow in transaction: /))
|
23
|
-
log_underflow
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_record_transaction_cpu_positive
|
27
|
-
self.expects(:cpu_burn).once.returns(1.0)
|
28
|
-
transaction_sampler.expects(:notice_transaction_cpu_time).with(1.0)
|
29
|
-
record_transaction_cpu
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_record_transaction_cpu_negative
|
33
|
-
self.expects(:cpu_burn).once.returns(nil)
|
34
|
-
# should not be called for the nil case
|
35
|
-
transaction_sampler.expects(:notice_transaction_cpu_time).never
|
36
|
-
record_transaction_cpu
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_normal_cpu_burn_positive
|
40
|
-
@process_cpu_start = 3
|
41
|
-
self.expects(:process_cpu).returns(4)
|
42
|
-
assert_equal 1, normal_cpu_burn
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_normal_cpu_burn_negative
|
46
|
-
@process_cpu_start = nil
|
47
|
-
self.expects(:process_cpu).never
|
48
|
-
assert_equal nil, normal_cpu_burn
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_jruby_cpu_burn_negative
|
52
|
-
@jruby_cpu_start = nil
|
53
|
-
self.expects(:jruby_cpu_time).never
|
54
|
-
self.expects(:record_jruby_cpu_burn).never
|
55
|
-
assert_equal nil, jruby_cpu_burn
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_record_jruby_cpu_burn
|
59
|
-
NewRelic::Agent.get_stats_no_scope(NewRelic::Metrics::USER_TIME).expects(:record_data_point).with(1.0, 1.0)
|
60
|
-
record_jruby_cpu_burn(1.0)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_cpu_burn_normal
|
64
|
-
self.expects(:normal_cpu_burn).returns(1)
|
65
|
-
self.expects(:jruby_cpu_burn).never
|
66
|
-
assert_equal 1, cpu_burn
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_cpu_burn_jruby
|
70
|
-
self.expects(:normal_cpu_burn).returns(nil)
|
71
|
-
self.expects(:jruby_cpu_burn).returns(2)
|
72
|
-
assert_equal 2, cpu_burn
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_current_stack_metric
|
76
|
-
self.expects(:metric_name)
|
77
|
-
current_stack_metric
|
78
|
-
end
|
79
|
-
end
|