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.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/CHANGELOG.md +22 -0
- data/LICENSE +1 -27
- data/README.md +4 -57
- data/lib/new_relic/agent.rb +0 -1
- data/lib/new_relic/agent/attribute_filter.rb +0 -1
- data/lib/new_relic/agent/configuration/default_source.rb +3 -32
- data/lib/new_relic/agent/error_collector.rb +0 -2
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/uri_util.rb +12 -7
- data/lib/new_relic/agent/stats.rb +0 -14
- data/lib/new_relic/agent/stats_engine.rb +171 -3
- data/lib/new_relic/agent/supported_versions.rb +9 -9
- data/lib/new_relic/agent/traced_method_stack.rb +1 -1
- data/lib/new_relic/agent/transaction/attributes.rb +0 -2
- data/lib/new_relic/agent/transaction/external_request_segment.rb +1 -5
- data/lib/new_relic/agent/transaction/trace_node.rb +0 -10
- data/lib/new_relic/agent/transaction_sample_builder.rb +0 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -13
- data/lib/new_relic/collection_helper.rb +0 -18
- data/lib/new_relic/control/frameworks/rails.rb +1 -21
- data/lib/new_relic/control/frameworks/rails3.rb +1 -1
- data/lib/new_relic/noticed_error.rb +1 -0
- data/lib/new_relic/version.rb +1 -1
- data/newrelic.yml +0 -4
- data/newrelic_rpm.gemspec +1 -1
- data/test/config/newrelic.yml +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +9 -1
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
- data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
- data/test/multiverse/suites/capistrano/config/newrelic.yml +0 -1
- data/test/multiverse/suites/capistrano2/config/newrelic.yml +0 -1
- data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/delayed_job/config/newrelic.yml +0 -1
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
- data/test/multiverse/suites/grape/config/newrelic.yml +0 -1
- data/test/multiverse/suites/high_security/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httprb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/json/config/newrelic.yml +0 -1
- data/test/multiverse/suites/marshalling/config/newrelic.yml +0 -1
- data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rack/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rails/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rake/config/newrelic.yml +0 -1
- data/test/multiverse/suites/redis/config/newrelic.yml +0 -1
- data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
- data/test/multiverse/suites/yajl/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +3 -12
- data/test/new_relic/agent/agent/start_test.rb +4 -2
- data/test/new_relic/agent/busy_calculator_test.rb +13 -5
- data/test/new_relic/agent/pipe_channel_manager_test.rb +3 -4
- data/test/new_relic/agent/stats_engine_test.rb +313 -1
- data/test/new_relic/agent/stats_test.rb +0 -20
- data/test/new_relic/agent/traced_method_stack_test.rb +2 -5
- data/test/new_relic/agent/transaction/external_request_segment_test.rb +5 -0
- data/test/new_relic/agent/transaction/trace_node_test.rb +0 -19
- data/test/new_relic/agent/transaction_sampler_test.rb +3 -6
- data/test/new_relic/collection_helper_test.rb +0 -39
- data/test/new_relic/control_test.rb +2 -4
- data/test/new_relic/license_test.rb +4 -14
- data/test/performance/suites/external_segment.rb +0 -2
- data/test/performance/suites/rack_middleware.rb +1 -3
- data/test/performance/suites/transaction_tracing.rb +0 -1
- metadata +2 -94
- data/lib/conditional_vendored_metric_parser.rb +0 -9
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +0 -26
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -188
- data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +0 -62
- data/lib/new_relic/merbtasks.rb +0 -10
- data/lib/new_relic/rack/developer_mode.rb +0 -321
- data/lib/new_relic/rack/developer_mode/segment_summary.rb +0 -56
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +0 -328
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +0 -75
- data/test/new_relic/metric_parser/metric_parser_test.rb +0 -17
- data/test/new_relic/rack/developer_mode/segment_summary_test.rb +0 -96
- data/test/new_relic/rack/developer_mode_helper_test.rb +0 -136
- data/test/new_relic/rack/developer_mode_test.rb +0 -96
- data/ui/helpers/developer_mode_helper.rb +0 -325
- data/ui/helpers/google_pie_chart.rb +0 -54
- data/ui/views/layouts/newrelic_default.rhtml +0 -48
- data/ui/views/newrelic/_explain_plans.rhtml +0 -27
- data/ui/views/newrelic/_sample.rhtml +0 -20
- data/ui/views/newrelic/_segment.rhtml +0 -28
- data/ui/views/newrelic/_segment_limit_message.rhtml +0 -1
- data/ui/views/newrelic/_segment_row.rhtml +0 -12
- data/ui/views/newrelic/_show_sample_detail.rhtml +0 -24
- data/ui/views/newrelic/_show_sample_sql.rhtml +0 -24
- data/ui/views/newrelic/_show_sample_summary.rhtml +0 -3
- data/ui/views/newrelic/_sql_row.rhtml +0 -16
- data/ui/views/newrelic/_stack_trace.rhtml +0 -15
- data/ui/views/newrelic/_table.rhtml +0 -12
- data/ui/views/newrelic/explain_sql.rhtml +0 -43
- data/ui/views/newrelic/file/images/arrow-close.png +0 -0
- data/ui/views/newrelic/file/images/arrow-open.png +0 -0
- data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/file/images/file_icon.png +0 -0
- data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
- data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/file/images/textmate.png +0 -0
- data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +0 -6243
- data/ui/views/newrelic/file/javascript/transaction_sample.js +0 -123
- data/ui/views/newrelic/file/stylesheets/style.css +0 -490
- data/ui/views/newrelic/index.rhtml +0 -70
- data/ui/views/newrelic/sample_not_found.rhtml +0 -2
- data/ui/views/newrelic/show_sample.rhtml +0 -81
- data/ui/views/newrelic/threads.rhtml +0 -45
- data/vendor/gems/metric_parser-0.1.0.pre1/.specification +0 -116
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +0 -5
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +0 -70
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +0 -18
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +0 -35
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +0 -37
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +0 -93
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +0 -50
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +0 -71
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +0 -47
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +0 -21
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +0 -52
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +0 -28
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +0 -32
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +0 -21
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +0 -15
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +0 -59
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +0 -44
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +0 -24
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +0 -35
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +0 -21
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +0 -38
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +0 -56
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -138
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +0 -33
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +0 -23
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +0 -31
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +0 -44
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +0 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +0 -31
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +0 -19
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +0 -58
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +0 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +0 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +0 -24
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +0 -24
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +0 -9
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +0 -74
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +0 -22
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +0 -18
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +0 -137
@@ -1,56 +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
|
-
# summarizes performance data for all calls to segments
|
6
|
-
# with the same metric_name
|
7
|
-
module NewRelic
|
8
|
-
module Rack
|
9
|
-
class DeveloperMode
|
10
|
-
class SegmentSummary
|
11
|
-
attr_accessor :metric_name, :total_time, :exclusive_time, :call_count, :current_nest_count
|
12
|
-
|
13
|
-
def initialize(metric_name, sample)
|
14
|
-
@metric_name = metric_name
|
15
|
-
@total_time, @exclusive_time, @call_count = 0,0,0
|
16
|
-
@sample = sample
|
17
|
-
@current_nest_count = 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def <<(segment)
|
21
|
-
if metric_name != segment.metric_name
|
22
|
-
raise ArgumentError, "Metric Name Mismatch: #{segment.metric_name} != #{metric_name}"
|
23
|
-
end
|
24
|
-
|
25
|
-
# a nested segment should use the sum of the top level totals
|
26
|
-
@total_time += segment.duration if current_nest_count == 0
|
27
|
-
@exclusive_time += segment.exclusive_duration
|
28
|
-
@call_count += 1
|
29
|
-
end
|
30
|
-
|
31
|
-
def average_time
|
32
|
-
@total_time / @call_count
|
33
|
-
end
|
34
|
-
|
35
|
-
def average_exclusive_time
|
36
|
-
@exclusive_time / @call_count
|
37
|
-
end
|
38
|
-
|
39
|
-
def exclusive_time_percentage
|
40
|
-
return 0 unless @exclusive_time && @sample.duration && @sample.duration > 0
|
41
|
-
@exclusive_time / @sample.duration
|
42
|
-
end
|
43
|
-
|
44
|
-
def total_time_percentage
|
45
|
-
return 0 unless @total_time && @sample.duration && @sample.duration > 0
|
46
|
-
@total_time / @sample.duration
|
47
|
-
end
|
48
|
-
|
49
|
-
def ui_name
|
50
|
-
return @metric_name if @metric_name == 'Remainder'
|
51
|
-
NewRelic::MetricParser::MetricParser.parse(@metric_name).developer_name
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,328 +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
|
-
|
7
|
-
class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
8
|
-
def setup
|
9
|
-
NewRelic::Agent.manual_start
|
10
|
-
@engine = NewRelic::Agent.instance.stats_engine
|
11
|
-
rescue => e
|
12
|
-
puts e
|
13
|
-
puts e.backtrace.join("\n")
|
14
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
@engine.reset!
|
18
|
-
NewRelic::Agent.shutdown
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_record_unscoped_metrics_records_to_transaction_stats_if_in_txn
|
23
|
-
in_transaction do
|
24
|
-
@engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
|
25
|
-
|
26
|
-
# txn is still active, so metrics should not be merged into global
|
27
|
-
# stats hash yet
|
28
|
-
assert_metrics_not_recorded(['a', 'b'])
|
29
|
-
end
|
30
|
-
|
31
|
-
expected = {
|
32
|
-
:call_count => 1,
|
33
|
-
:total_call_time => 20,
|
34
|
-
:total_exclusive_time => 10
|
35
|
-
}
|
36
|
-
assert_metrics_recorded(
|
37
|
-
'a' => expected,
|
38
|
-
'b' => expected
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_record_unscoped_metrics_records_to_global_metrics_if_no_txn
|
43
|
-
@engine.tl_record_unscoped_metrics(['a', 'b'], 20, 10)
|
44
|
-
expected = {
|
45
|
-
:call_count => 1,
|
46
|
-
:total_call_time => 20,
|
47
|
-
:total_exclusive_time => 10
|
48
|
-
}
|
49
|
-
assert_metrics_recorded(
|
50
|
-
'a' => expected,
|
51
|
-
'b' => expected
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_record_unscoped_metrics_takes_single_metric_name
|
56
|
-
@engine.tl_record_unscoped_metrics('a', 20)
|
57
|
-
assert_metrics_recorded(
|
58
|
-
'a' => {
|
59
|
-
:call_count => 1,
|
60
|
-
:total_call_time => 20,
|
61
|
-
:total_exclusive_time => 20
|
62
|
-
}
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_record_unscoped_metrics_takes_block_in_txn
|
67
|
-
in_transaction('txn') do
|
68
|
-
@engine.tl_record_unscoped_metrics('a') do |stat|
|
69
|
-
stat.total_call_time = 42
|
70
|
-
stat.call_count = 99
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
expected = { :total_call_time => 42, :call_count => 99 }
|
75
|
-
assert_metrics_recorded('a' => expected)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_record_unscoped_metrics_takes_block_outside_txn
|
79
|
-
@engine.tl_record_unscoped_metrics('a') do |stat|
|
80
|
-
stat.total_call_time = 42
|
81
|
-
stat.call_count = 99
|
82
|
-
end
|
83
|
-
|
84
|
-
expected = { :total_call_time => 42, :call_count => 99 }
|
85
|
-
assert_metrics_recorded('a' => expected)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_record_unscoped_metrics_is_thread_safe
|
89
|
-
threads = []
|
90
|
-
nthreads = 25
|
91
|
-
iterations = 100
|
92
|
-
|
93
|
-
nthreads.times do |tid|
|
94
|
-
threads << Thread.new do
|
95
|
-
iterations.times do
|
96
|
-
@engine.tl_record_unscoped_metrics('m1', 1)
|
97
|
-
@engine.tl_record_unscoped_metrics('m2', 1)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
threads.each { |t| t.join }
|
102
|
-
|
103
|
-
assert_metrics_recorded(
|
104
|
-
'm1' => { :call_count => nthreads * iterations },
|
105
|
-
'm2' => { :call_count => nthreads * iterations }
|
106
|
-
)
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_record_scoped_and_unscoped_metrics_records_scoped_and_unscoped
|
110
|
-
in_transaction('txn') do
|
111
|
-
@engine.tl_record_scoped_and_unscoped_metrics('a', nil, 20, 10)
|
112
|
-
assert_metrics_not_recorded('a')
|
113
|
-
end
|
114
|
-
|
115
|
-
expected = {
|
116
|
-
:call_count => 1,
|
117
|
-
:total_call_time => 20,
|
118
|
-
:total_exclusive_time => 10
|
119
|
-
}
|
120
|
-
assert_metrics_recorded(
|
121
|
-
'a' => expected,
|
122
|
-
['a', 'txn'] => expected
|
123
|
-
)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_record_scoped_and_unscoped_metrics_takes_block
|
127
|
-
in_transaction('txn') do
|
128
|
-
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b']) do |stat|
|
129
|
-
stat.total_call_time = 42
|
130
|
-
stat.call_count = 99
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
expected = { :total_call_time => 42, :call_count => 99 }
|
135
|
-
assert_metrics_recorded(
|
136
|
-
'a' => expected,
|
137
|
-
['a', 'txn'] => expected,
|
138
|
-
'b' => expected
|
139
|
-
)
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_record_scoped_and_unscoped_metrics_records_multiple_unscoped_metrics
|
143
|
-
in_transaction('txn') do
|
144
|
-
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b', 'c'], 20, 10)
|
145
|
-
assert_metrics_not_recorded(['a', 'b', 'c'])
|
146
|
-
end
|
147
|
-
|
148
|
-
expected = {
|
149
|
-
:call_count => 1,
|
150
|
-
:total_call_time => 20,
|
151
|
-
:total_exclusive_time => 10
|
152
|
-
}
|
153
|
-
assert_metrics_recorded(
|
154
|
-
'a' => expected,
|
155
|
-
['a', 'txn'] => expected,
|
156
|
-
'b' => expected,
|
157
|
-
'c' => expected
|
158
|
-
)
|
159
|
-
assert_metrics_not_recorded([
|
160
|
-
['b', 'txn'],
|
161
|
-
['c', 'txn']
|
162
|
-
])
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_record_scoped_and_unscoped_metrics_is_thread_safe
|
166
|
-
threads = []
|
167
|
-
nthreads = 25
|
168
|
-
iterations = 100
|
169
|
-
|
170
|
-
nthreads.times do |tid|
|
171
|
-
threads << Thread.new do
|
172
|
-
iterations.times do
|
173
|
-
in_transaction('txn') do
|
174
|
-
@engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
|
175
|
-
@engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
threads.each { |t| t.join }
|
181
|
-
|
182
|
-
expected = { :call_count => nthreads * iterations }
|
183
|
-
assert_metrics_recorded(
|
184
|
-
'm1' => expected,
|
185
|
-
'm2' => expected,
|
186
|
-
['m1', 'txn'] => expected,
|
187
|
-
['m2', 'txn'] => expected,
|
188
|
-
'm3' => expected,
|
189
|
-
'm4' => expected
|
190
|
-
)
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_record_scoped_and_unscoped_metrics_records_unscoped_if_not_in_txn
|
194
|
-
@engine.tl_record_scoped_and_unscoped_metrics('a', ['b'], 20, 10)
|
195
|
-
|
196
|
-
expected = {
|
197
|
-
:call_count => 1,
|
198
|
-
:total_call_time => 20,
|
199
|
-
:total_exclusive_time => 10
|
200
|
-
}
|
201
|
-
assert_metrics_recorded_exclusive(
|
202
|
-
'a' => expected,
|
203
|
-
'b' => expected
|
204
|
-
)
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_harvest
|
208
|
-
@engine.clear_stats
|
209
|
-
|
210
|
-
@engine.tl_record_unscoped_metrics "a", 10
|
211
|
-
@engine.tl_record_unscoped_metrics "c", 1
|
212
|
-
@engine.tl_record_unscoped_metrics "c", 3
|
213
|
-
|
214
|
-
assert_metrics_recorded({
|
215
|
-
"a" => {:call_count => 1, :total_call_time => 10},
|
216
|
-
"c" => {:call_count => 2, :total_call_time => 4}
|
217
|
-
})
|
218
|
-
|
219
|
-
harvested = @engine.harvest!.to_h
|
220
|
-
|
221
|
-
# after harvest, all the metrics should be reset
|
222
|
-
refute_metrics_recorded %w(a c)
|
223
|
-
|
224
|
-
spec_a = NewRelic::MetricSpec.new('a')
|
225
|
-
|
226
|
-
assert(harvested.has_key?(spec_a))
|
227
|
-
assert_equal(1, harvested[spec_a].call_count)
|
228
|
-
assert_equal(10, harvested[spec_a].total_call_time)
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_harvest_applies_metric_rename_rules
|
232
|
-
rule = NewRelic::Agent::RulesEngine::ReplacementRule.new(
|
233
|
-
'match_expression' => '[0-9]+',
|
234
|
-
'replacement' => '*',
|
235
|
-
'replace_all' => true
|
236
|
-
)
|
237
|
-
rules_engine = NewRelic::Agent::RulesEngine.new([rule])
|
238
|
-
|
239
|
-
@engine.metric_rules = rules_engine
|
240
|
-
@engine.tl_record_unscoped_metrics('Custom/foo/1/bar/22', 1)
|
241
|
-
@engine.tl_record_unscoped_metrics('Custom/foo/3/bar/44', 1)
|
242
|
-
@engine.tl_record_unscoped_metrics('Custom/foo/5/bar/66', 1)
|
243
|
-
|
244
|
-
harvested = @engine.harvest!.to_h
|
245
|
-
|
246
|
-
refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/1/bar/22'))
|
247
|
-
refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/3/bar/44'))
|
248
|
-
refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/5/bar/66'))
|
249
|
-
merged = harvested[NewRelic::MetricSpec.new('Custom/foo/*/bar/*')]
|
250
|
-
assert_equal(3, merged.call_count)
|
251
|
-
end
|
252
|
-
|
253
|
-
def test_apply_rules_to_metric_data_respects_ignore_rules
|
254
|
-
rule = NewRelic::Agent::RulesEngine::ReplacementRule.new(
|
255
|
-
'match_expression' => 'bar',
|
256
|
-
'ignore' => 'true'
|
257
|
-
)
|
258
|
-
rules_engine = NewRelic::Agent::RulesEngine.new([rule])
|
259
|
-
|
260
|
-
stats_hash = NewRelic::Agent::StatsHash.new
|
261
|
-
|
262
|
-
stats_hash.record(NewRelic::MetricSpec.new('foo'), 90210)
|
263
|
-
stats_hash.record(NewRelic::MetricSpec.new('bar'), 90210)
|
264
|
-
|
265
|
-
renamed = @engine.apply_rules_to_metric_data(rules_engine, stats_hash)
|
266
|
-
|
267
|
-
assert_equal(1 , renamed.size)
|
268
|
-
assert_equal('foo', renamed.to_h.keys.first.name)
|
269
|
-
end
|
270
|
-
|
271
|
-
def test_harvest_with_merge
|
272
|
-
@engine.tl_record_unscoped_metrics "a", 1
|
273
|
-
assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 1}
|
274
|
-
|
275
|
-
harvest = @engine.harvest!
|
276
|
-
|
277
|
-
assert_metrics_not_recorded "a"
|
278
|
-
|
279
|
-
@engine.tl_record_unscoped_metrics "a", 2
|
280
|
-
assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 2}
|
281
|
-
|
282
|
-
# this should merge the contents of the previous harvest,
|
283
|
-
# so the stats for metric "a" should have 2 data points
|
284
|
-
@engine.merge!(harvest)
|
285
|
-
harvest = @engine.harvest!
|
286
|
-
stats = harvest[NewRelic::MetricSpec.new("a")]
|
287
|
-
assert_equal 2, stats.call_count
|
288
|
-
assert_equal 3, stats.total_call_time
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_merge_merges
|
292
|
-
@engine.tl_record_unscoped_metrics "foo", 1
|
293
|
-
|
294
|
-
other_stats_hash = NewRelic::Agent::StatsHash.new()
|
295
|
-
other_stats_hash.record(NewRelic::MetricSpec.new('foo'), 1)
|
296
|
-
other_stats_hash.record(NewRelic::MetricSpec.new('bar'), 1)
|
297
|
-
|
298
|
-
@engine.merge!(other_stats_hash)
|
299
|
-
|
300
|
-
assert_metrics_recorded ({
|
301
|
-
'foo' => {:call_count => 2},
|
302
|
-
'bar' => {:call_count => 1}
|
303
|
-
})
|
304
|
-
end
|
305
|
-
|
306
|
-
def test_harvest_adds_harvested_at_time
|
307
|
-
t0 = freeze_time
|
308
|
-
result = @engine.harvest!
|
309
|
-
assert_equal(t0, result.harvested_at)
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_record_unscoped_metrics_unscoped_metrics_only
|
313
|
-
in_transaction('scopey') do
|
314
|
-
@engine.tl_record_unscoped_metrics('foo', 42)
|
315
|
-
end
|
316
|
-
assert_metrics_recorded('foo' => { :call_count => 1, :total_call_time => 42 })
|
317
|
-
assert_metrics_not_recorded([['foo', 'scopey']])
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_record_supportability_metric_count_records_counts_only
|
321
|
-
@engine.tl_record_supportability_metric_count('foo/bar', 1)
|
322
|
-
@engine.tl_record_supportability_metric_count('foo/bar', 42)
|
323
|
-
assert_metrics_recorded(['Supportability/foo/bar'] => {
|
324
|
-
:call_count => 42,
|
325
|
-
:total_call_time => 0
|
326
|
-
})
|
327
|
-
end
|
328
|
-
end
|
@@ -1,75 +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
|
-
|
7
|
-
class NewRelic::Agent::Transaction
|
8
|
-
class DeveloperModeSampleBufferTest < Minitest::Test
|
9
|
-
def setup
|
10
|
-
@buffer = DeveloperModeSampleBuffer.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_store_sample_for_developer_mode_in_dev_mode
|
14
|
-
with_config(:developer_mode => true) do
|
15
|
-
sample = stub
|
16
|
-
@buffer.store(sample)
|
17
|
-
assert_equal([sample], @buffer.samples)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_store_sample_for_developer_mode_not_in_dev_mode
|
22
|
-
with_config(:developer_mode => false) do
|
23
|
-
@buffer.store(stub)
|
24
|
-
assert(@buffer.samples.empty?)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_stores_up_to_truncate_max
|
29
|
-
with_config(:developer_mode => true) do
|
30
|
-
sample = stub
|
31
|
-
@buffer.capacity.times { @buffer.store(sample) }
|
32
|
-
|
33
|
-
assert_equal(Array.new(@buffer.capacity, sample), @buffer.samples)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_stores_and_truncates
|
38
|
-
with_config(:developer_mode => true) do
|
39
|
-
sample = stub
|
40
|
-
(@buffer.capacity * 2).times { @buffer.store(sample) }
|
41
|
-
|
42
|
-
assert_equal(Array.new(@buffer.capacity, sample), @buffer.samples)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_visit_node_takes_backtraces_in_dev_mode
|
47
|
-
with_config(:developer_mode => true) do
|
48
|
-
node = {}
|
49
|
-
@buffer.visit_node(node)
|
50
|
-
assert node[:backtrace].any? {|trace_line| trace_line.include?(__FILE__)}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_visit_node_takes_backtraces_not_in_dev_mode
|
55
|
-
with_config(:developer_mode => false) do
|
56
|
-
node = {}
|
57
|
-
@buffer.visit_node(node)
|
58
|
-
assert_nil node[:backtrace]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_visit_node_safe_against_nils
|
63
|
-
with_config(:developer_mode => true) do
|
64
|
-
@buffer.visit_node(nil)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_doesnt_store_previous
|
69
|
-
with_config(:developer_mode => true) do
|
70
|
-
@buffer.store_previous([stub])
|
71
|
-
assert @buffer.samples.empty?
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|