dolores_rpm 3.2.0.6 → 3.3.4.fork
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +32 -6
- data/dolores_rpm.gemspec +15 -11
- data/lib/new_relic/agent/agent.rb +28 -14
- data/lib/new_relic/agent/beacon_configuration.rb +11 -0
- data/lib/new_relic/agent/browser_monitoring.rb +53 -13
- data/lib/new_relic/agent/database.rb +34 -14
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +137 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +24 -5
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -36
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +24 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +88 -30
- data/lib/new_relic/agent/instrumentation/sinatra.rb +40 -20
- data/lib/new_relic/agent/samplers/memory_sampler.rb +5 -6
- data/lib/new_relic/agent/sql_sampler.rb +35 -16
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +1 -1
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -85
- data/lib/new_relic/agent/stats_engine.rb +1 -0
- data/lib/new_relic/agent/transaction_info.rb +74 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +17 -3
- data/lib/new_relic/agent/transaction_sampler.rb +86 -15
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +15 -2
- data/lib/new_relic/collection_helper.rb +8 -6
- data/lib/new_relic/command.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +1 -1
- data/lib/new_relic/control/configuration.rb +6 -2
- data/lib/new_relic/control/frameworks/merb.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +5 -5
- data/lib/new_relic/control/frameworks/rails3.rb +2 -2
- data/lib/new_relic/control/instance_methods.rb +3 -3
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/control/server_methods.rb +2 -2
- data/lib/new_relic/data_serialization.rb +10 -16
- data/lib/new_relic/delayed_job_injection.rb +6 -1
- data/lib/new_relic/language_support.rb +11 -7
- data/lib/new_relic/local_environment.rb +24 -10
- data/lib/new_relic/metric_spec.rb +7 -6
- data/lib/new_relic/noticed_error.rb +6 -1
- data/lib/new_relic/rack/browser_monitoring.rb +21 -13
- data/lib/new_relic/rack/developer_mode.rb +2 -2
- data/lib/new_relic/recipes.rb +8 -4
- data/lib/new_relic/stats.rb +0 -53
- data/lib/new_relic/transaction_sample/segment.rb +2 -0
- data/lib/new_relic/transaction_sample.rb +39 -23
- data/lib/new_relic/version.rb +3 -3
- data/test/active_record_fixtures.rb +3 -3
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/new_relic/agent/agent/connect_test.rb +4 -11
- data/test/new_relic/agent/agent_test.rb +1 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +20 -1
- data/test/new_relic/agent/beacon_configuration_test.rb +10 -7
- data/test/new_relic/agent/browser_monitoring_test.rb +90 -45
- data/test/new_relic/agent/database_test.rb +34 -47
- data/test/new_relic/agent/error_collector_test.rb +32 -15
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +56 -18
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +0 -2
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +6 -11
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +2 -2
- data/test/new_relic/agent/rpm_agent_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +48 -16
- data/test/new_relic/agent/stats_engine_test.rb +41 -6
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +19 -3
- data/test/new_relic/agent/transaction_sampler_test.rb +49 -37
- data/test/new_relic/agent/worker_loop_test.rb +1 -1
- data/test/new_relic/agent_test.rb +12 -0
- data/test/new_relic/control/configuration_test.rb +12 -0
- data/test/new_relic/control_test.rb +2 -0
- data/test/new_relic/data_serialization_test.rb +12 -12
- data/test/new_relic/local_environment_test.rb +14 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +81 -23
- data/test/new_relic/rack/developer_mode_test.rb +31 -0
- data/test/new_relic/stats_test.rb +0 -15
- data/test/new_relic/transaction_sample_test.rb +13 -0
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +94 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/test_helper.rb +1 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +5 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +17 -4
- metadata +25 -19
- data/dolores_rpm-3.2.0.2.gem +0 -0
- data/dolores_rpm-3.2.0.5.gem +0 -0
- data/dolores_rpm-3.3.4.fork.gem +0 -0
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +0 -115
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +0 -122
data/test/script/ci.sh
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Script to run test suites in CI or in development mode. This script handles
|
4
|
+
# checking out test dependencies (currently rpm_test_app and it's dependencies)
|
5
|
+
# and executing them.
|
6
|
+
#
|
7
|
+
# It relies on 3 environment variables:
|
8
|
+
#
|
9
|
+
# RUBY - The rvm ruby you want to use (e.g. 1.8.7, ree, jruby)
|
10
|
+
#
|
11
|
+
# BRANCH - The rpm_test_app branch you want to use (e.g. rails20, rails31)
|
12
|
+
#
|
13
|
+
# RPM_TEST_APP_CLONE_URL - where to clone the test app from (e.g.
|
14
|
+
# git://github.com/newrelic/rpm_test_app.git, /path/in/my/filesystem)
|
15
|
+
#
|
16
|
+
# Example usage:
|
17
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
18
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
19
|
+
#
|
20
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
21
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
22
|
+
#
|
23
|
+
# RPM_TEST_APP_CLONE_URL=~/dev/rpm_test_app/ \
|
24
|
+
# RUBY=jruby BRANCH=rails22 test/script/ci.sh
|
25
|
+
|
26
|
+
echo "Executing $0"
|
27
|
+
echo "Running in $(pwd)"
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# print commands in this script as they're invoked
|
32
|
+
# set -x
|
33
|
+
# fail if any command fails
|
34
|
+
set -e
|
35
|
+
|
36
|
+
# check for require environment variables
|
37
|
+
if [ "x$RUBY" == "x" ]; then
|
38
|
+
echo '$RUBY is undefined'
|
39
|
+
exit 1
|
40
|
+
fi
|
41
|
+
if [ "x$BRANCH" == "x" ]; then
|
42
|
+
echo '$BRANCH is undefined'
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
if [ "x$RPM_TEST_APP_CLONE_URL" == "x" ]; then
|
46
|
+
echo '$RPM_TEST_APP_CLONE_URL is undefined'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
. "$HOME/.rvm/scripts/rvm"
|
51
|
+
rvm use $RUBY || rvm install $RUBY
|
52
|
+
echo `which ruby`
|
53
|
+
|
54
|
+
# make sure that we're in the project root
|
55
|
+
script_dirname=`dirname $0`
|
56
|
+
cd "$script_dirname/../../"
|
57
|
+
pwd
|
58
|
+
|
59
|
+
rm -rf tmp
|
60
|
+
mkdir -p tmp
|
61
|
+
cd tmp
|
62
|
+
git clone --depth=1 $RPM_TEST_APP_CLONE_URL rpm_test_app
|
63
|
+
cd rpm_test_app
|
64
|
+
git checkout -t origin/$BRANCH || git checkout $BRANCH
|
65
|
+
mkdir -p log
|
66
|
+
mkdir -p tmp
|
67
|
+
if [ "x$BRANCH" == "xrails20" ]; then
|
68
|
+
printf "\e[0;31;49mWarning:\e[0m "
|
69
|
+
echo "Testing against the rails20 branch requires your changes to be committed. Uncommitted changes will not be used."
|
70
|
+
mkdir -p vendor/plugins
|
71
|
+
git clone ../.. vendor/plugins/newrelic_rpm
|
72
|
+
else
|
73
|
+
perl -p -i'.bak' -e 's#gem .newrelic_rpm.*$#gem "newrelic_rpm", :path => "\.\.\/\.\.\/"#' Gemfile
|
74
|
+
fi
|
75
|
+
|
76
|
+
rvm --force gemset delete ruby_agent_tests_$BRANCH
|
77
|
+
rvm gemset create ruby_agent_tests_$BRANCH
|
78
|
+
rvm gemset use ruby_agent_tests_$BRANCH
|
79
|
+
|
80
|
+
if [ "x$RUBY" == "x1.8.6" ]; then
|
81
|
+
# Bundler 1.1 dropped support for ruby 1.8.6
|
82
|
+
gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
|
83
|
+
else
|
84
|
+
gem install bundler --no-rdoc --no-ri
|
85
|
+
fi
|
86
|
+
|
87
|
+
|
88
|
+
export RAILS_ENV=test
|
89
|
+
bundle
|
90
|
+
bundle exec rake --trace db:create:all ci:setup:testunit test:newrelic
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Script to benchmark the ruby agent under various versions of ruby in ci.
|
4
|
+
|
5
|
+
echo "Executing $0"
|
6
|
+
echo "Running in $(pwd)"
|
7
|
+
|
8
|
+
# print commands in this script as they're invoked
|
9
|
+
# set -x
|
10
|
+
# fail if any command fails
|
11
|
+
set -e
|
12
|
+
|
13
|
+
# check for require environment variables
|
14
|
+
if [ "x$RUBY" == "x" ]; then
|
15
|
+
echo '$RUBY is undefined'
|
16
|
+
exit 1
|
17
|
+
fi
|
18
|
+
|
19
|
+
|
20
|
+
. "$HOME/.rvm/scripts/rvm"
|
21
|
+
rvm use $RUBY || rvm install $RUBY
|
22
|
+
echo `which ruby`
|
23
|
+
|
24
|
+
# make sure that we're in the project root
|
25
|
+
script_dirname=`dirname $0`
|
26
|
+
cd "$script_dirname/../../"
|
27
|
+
pwd
|
28
|
+
|
29
|
+
rm -rf tmp
|
30
|
+
mkdir -p tmp
|
31
|
+
cd tmp
|
32
|
+
git clone --depth=1 git@github.com:newrelic/agent_prof.git agent_prof
|
33
|
+
cd agent_prof
|
34
|
+
|
35
|
+
perl -p -i'.bak' -e 's#gem +.newrelic_rpm.*$#gem "newrelic_rpm", :path => "\.\.\/\.\.\/"#' Gemfile
|
36
|
+
|
37
|
+
rvm --force gemset delete ruby_bench_$RUBY
|
38
|
+
rvm gemset create ruby_bench_$RUBY
|
39
|
+
rvm gemset use ruby_bench_$RUBY
|
40
|
+
|
41
|
+
if [ "x$RUBY" == "x1.8.6" ]; then
|
42
|
+
# Bundler 1.1 dropped support for ruby 1.8.6
|
43
|
+
gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
|
44
|
+
else
|
45
|
+
gem install bundler --no-rdoc --no-ri
|
46
|
+
fi
|
47
|
+
|
48
|
+
bundle
|
49
|
+
script/run
|
50
|
+
bundle exec script/post_log_to_dashboard
|
51
|
+
|
52
|
+
|
data/test/test_helper.rb
CHANGED
@@ -8,12 +8,22 @@ module NewRelic
|
|
8
8
|
# Load in the parsers classes in the plugin:
|
9
9
|
Dir[File.join(File.dirname(__FILE__), "metric_parser", "*.rb")].each { | file | require file }
|
10
10
|
|
11
|
+
def self.category_is_constant(category)
|
12
|
+
@string_constants ||= (
|
13
|
+
NewRelic::MetricParser.constants.inject({}){|memo, const| memo[const.to_s] = true; memo}
|
14
|
+
)
|
15
|
+
@string_constants[category]
|
16
|
+
end
|
11
17
|
# return a string that is parsable via the Metric parser APIs
|
12
18
|
def self.for_metric_named(s)
|
13
19
|
category = (s =~ /^([^\/]*)/) && $1
|
14
20
|
parser_class = self
|
15
|
-
if category
|
16
|
-
|
21
|
+
if category_is_constant(category)
|
22
|
+
begin
|
23
|
+
parser_class = NewRelic::MetricParser.const_get(category)
|
24
|
+
rescue
|
25
|
+
nil
|
26
|
+
end
|
17
27
|
end
|
18
28
|
parser_class.new s
|
19
29
|
end
|
@@ -71,9 +81,12 @@ module NewRelic
|
|
71
81
|
segments[0]
|
72
82
|
end
|
73
83
|
|
84
|
+
|
85
|
+
EMPTY_SEGMENTS_HASH = [].freeze
|
86
|
+
SEGMENTS_CACHE = {}
|
74
87
|
def segments
|
75
|
-
|
76
|
-
|
88
|
+
name || (return EMPTY_SEGMENTS_HASH)
|
89
|
+
SEGMENTS_CACHE[name] ||= name.split(SEPARATOR).freeze
|
77
90
|
end
|
78
91
|
|
79
92
|
# --
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolores_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -101810583
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
version: 3.
|
8
|
+
- 3
|
9
|
+
- 4
|
10
|
+
- fork
|
11
|
+
version: 3.3.4.fork
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Bill Kayser
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-
|
22
|
+
date: 2012-04-27 00:00:00 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: jeweler
|
@@ -71,8 +71,8 @@ description: |
|
|
71
71
|
email: support@newrelic.com
|
72
72
|
executables:
|
73
73
|
- mongrel_rpm
|
74
|
-
- newrelic_cmd
|
75
74
|
- newrelic
|
75
|
+
- newrelic_cmd
|
76
76
|
extensions: []
|
77
77
|
|
78
78
|
extra_rdoc_files:
|
@@ -90,10 +90,6 @@ files:
|
|
90
90
|
- cert/cacert.pem
|
91
91
|
- cert/oldsite.pem
|
92
92
|
- cert/site.pem
|
93
|
-
- dolores_rpm-3.2.0.2.gem
|
94
|
-
- dolores_rpm-3.2.0.5.gem
|
95
|
-
- dolores_rpm-3.3.4.fork.gem
|
96
|
-
- dolores_rpm.gemspec
|
97
93
|
- install.rb
|
98
94
|
- lib/conditional_vendored_dependency_detection.rb
|
99
95
|
- lib/conditional_vendored_metric_parser.rb
|
@@ -107,6 +103,7 @@ files:
|
|
107
103
|
- lib/new_relic/agent/error_collector.rb
|
108
104
|
- lib/new_relic/agent/instrumentation.rb
|
109
105
|
- lib/new_relic/agent/instrumentation/active_merchant.rb
|
106
|
+
- lib/new_relic/agent/instrumentation/active_record.rb
|
110
107
|
- lib/new_relic/agent/instrumentation/acts_as_solr.rb
|
111
108
|
- lib/new_relic/agent/instrumentation/authlogic.rb
|
112
109
|
- lib/new_relic/agent/instrumentation/controller_instrumentation.rb
|
@@ -123,10 +120,8 @@ files:
|
|
123
120
|
- lib/new_relic/agent/instrumentation/rack.rb
|
124
121
|
- lib/new_relic/agent/instrumentation/rails/action_controller.rb
|
125
122
|
- lib/new_relic/agent/instrumentation/rails/action_web_service.rb
|
126
|
-
- lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb
|
127
123
|
- lib/new_relic/agent/instrumentation/rails/errors.rb
|
128
124
|
- lib/new_relic/agent/instrumentation/rails3/action_controller.rb
|
129
|
-
- lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb
|
130
125
|
- lib/new_relic/agent/instrumentation/rails3/errors.rb
|
131
126
|
- lib/new_relic/agent/instrumentation/sinatra.rb
|
132
127
|
- lib/new_relic/agent/instrumentation/sunspot.rb
|
@@ -140,9 +135,11 @@ files:
|
|
140
135
|
- lib/new_relic/agent/shim_agent.rb
|
141
136
|
- lib/new_relic/agent/sql_sampler.rb
|
142
137
|
- lib/new_relic/agent/stats_engine.rb
|
138
|
+
- lib/new_relic/agent/stats_engine/gc_profiler.rb
|
143
139
|
- lib/new_relic/agent/stats_engine/metric_stats.rb
|
144
140
|
- lib/new_relic/agent/stats_engine/samplers.rb
|
145
141
|
- lib/new_relic/agent/stats_engine/transactions.rb
|
142
|
+
- lib/new_relic/agent/transaction_info.rb
|
146
143
|
- lib/new_relic/agent/transaction_sample_builder.rb
|
147
144
|
- lib/new_relic/agent/transaction_sampler.rb
|
148
145
|
- lib/new_relic/agent/worker_loop.rb
|
@@ -193,10 +190,12 @@ files:
|
|
193
190
|
- lib/tasks/install.rake
|
194
191
|
- lib/tasks/tests.rake
|
195
192
|
- newrelic.yml
|
193
|
+
- dolores_rpm.gemspec
|
196
194
|
- recipes/newrelic.rb
|
197
195
|
- test/active_record_fixtures.rb
|
198
196
|
- test/config/newrelic.yml
|
199
197
|
- test/config/test_control.rb
|
198
|
+
- test/fixtures/proc_cpuinfo.txt
|
200
199
|
- test/new_relic/agent/agent/connect_test.rb
|
201
200
|
- test/new_relic/agent/agent/start_test.rb
|
202
201
|
- test/new_relic/agent/agent/start_worker_thread_test.rb
|
@@ -232,6 +231,7 @@ files:
|
|
232
231
|
- test/new_relic/agent/stats_engine/metric_stats_test.rb
|
233
232
|
- test/new_relic/agent/stats_engine/samplers_test.rb
|
234
233
|
- test/new_relic/agent/stats_engine_test.rb
|
234
|
+
- test/new_relic/agent/transaction_info_test.rb
|
235
235
|
- test/new_relic/agent/transaction_sample_builder_test.rb
|
236
236
|
- test/new_relic/agent/transaction_sampler_test.rb
|
237
237
|
- test/new_relic/agent/worker_loop_test.rb
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- test/new_relic/delayed_job_injection_test.rb
|
247
247
|
- test/new_relic/local_environment_test.rb
|
248
248
|
- test/new_relic/metric_data_test.rb
|
249
|
+
- test/new_relic/metric_parser/metric_parser_test.rb
|
249
250
|
- test/new_relic/metric_spec_test.rb
|
250
251
|
- test/new_relic/rack/all_test.rb
|
251
252
|
- test/new_relic/rack/browser_monitoring_test.rb
|
@@ -261,6 +262,9 @@ files:
|
|
261
262
|
- test/new_relic/transaction_sample_subtest_test.rb
|
262
263
|
- test/new_relic/transaction_sample_test.rb
|
263
264
|
- test/new_relic/version_number_test.rb
|
265
|
+
- test/script/build_test_gem.sh
|
266
|
+
- test/script/ci.sh
|
267
|
+
- test/script/ci_bench.sh
|
264
268
|
- test/test_contexts.rb
|
265
269
|
- test/test_helper.rb
|
266
270
|
- ui/helpers/developer_mode_helper.rb
|
@@ -362,7 +366,7 @@ post_install_message: |
|
|
362
366
|
|
363
367
|
Please see http://github.com/newrelic/rpm/blob/master/CHANGELOG
|
364
368
|
for a complete description of the features and enhancements available
|
365
|
-
in version 3.
|
369
|
+
in version 3.3 of the Ruby Agent.
|
366
370
|
|
367
371
|
|
368
372
|
rdoc_options:
|
@@ -384,12 +388,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
384
388
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
385
389
|
none: false
|
386
390
|
requirements:
|
387
|
-
- - "
|
391
|
+
- - ">"
|
388
392
|
- !ruby/object:Gem::Version
|
389
|
-
hash:
|
393
|
+
hash: 25
|
390
394
|
segments:
|
391
|
-
-
|
392
|
-
|
395
|
+
- 1
|
396
|
+
- 3
|
397
|
+
- 1
|
398
|
+
version: 1.3.1
|
393
399
|
requirements: []
|
394
400
|
|
395
401
|
rubyforge_project:
|
data/dolores_rpm-3.2.0.2.gem
DELETED
Binary file
|
data/dolores_rpm-3.2.0.5.gem
DELETED
Binary file
|
data/dolores_rpm-3.3.4.fork.gem
DELETED
Binary file
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module NewRelic
|
2
|
-
module Agent
|
3
|
-
module Instrumentation
|
4
|
-
module ActiveRecordInstrumentation
|
5
|
-
|
6
|
-
def self.included(instrumented_class)
|
7
|
-
instrumented_class.class_eval do
|
8
|
-
alias_method :log_without_newrelic_instrumentation, :log
|
9
|
-
alias_method :log, :log_with_newrelic_instrumentation
|
10
|
-
protected :log
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def log_with_newrelic_instrumentation(sql, name, &block)
|
15
|
-
|
16
|
-
return log_without_newrelic_instrumentation(sql, name, &block) unless NewRelic::Agent.is_execution_traced?
|
17
|
-
|
18
|
-
# Capture db config if we are going to try to get the explain plans
|
19
|
-
if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
|
20
|
-
(defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && self.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)) ||
|
21
|
-
(defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
|
22
|
-
supported_config = @config
|
23
|
-
end
|
24
|
-
if name && (parts = name.split " ") && parts.size == 2
|
25
|
-
model = parts.first
|
26
|
-
operation = parts.last.downcase
|
27
|
-
metric_name = case operation
|
28
|
-
when 'load' then 'find'
|
29
|
-
when 'indexes', 'columns' then nil # fall back to DirectSQL
|
30
|
-
when 'destroy', 'find', 'save', 'create' then operation
|
31
|
-
when 'update' then 'save'
|
32
|
-
else
|
33
|
-
if model == 'Join'
|
34
|
-
operation
|
35
|
-
end
|
36
|
-
end
|
37
|
-
metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
|
38
|
-
end
|
39
|
-
|
40
|
-
if metric.nil?
|
41
|
-
metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
|
42
|
-
if metric.nil?
|
43
|
-
if sql =~ /^(select|update|insert|delete|show)/i
|
44
|
-
# Could not determine the model/operation so let's find a better
|
45
|
-
# metric. If it doesn't match the regex, it's probably a show
|
46
|
-
# command or some DDL which we'll ignore.
|
47
|
-
metric = "Database/SQL/#{$1.downcase}"
|
48
|
-
else
|
49
|
-
metric = "Database/SQL/other"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if !metric
|
55
|
-
log_without_newrelic_instrumentation(sql, name, &block)
|
56
|
-
else
|
57
|
-
metrics = [metric, "ActiveRecord/all"]
|
58
|
-
metrics << "ActiveRecord/#{metric_name}" if metric_name
|
59
|
-
self.class.trace_execution_scoped(metrics) do
|
60
|
-
t0 = Time.now
|
61
|
-
begin
|
62
|
-
log_without_newrelic_instrumentation(sql, name, &block)
|
63
|
-
ensure
|
64
|
-
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, supported_config, (Time.now - t0).to_f)
|
65
|
-
NewRelic::Agent.instance.sql_sampler.notice_sql(sql, metric, supported_config, (Time.now - t0).to_f)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
DependencyDetection.defer do
|
77
|
-
@name = :rails2_active_record
|
78
|
-
|
79
|
-
depends_on do
|
80
|
-
defined?(ActiveRecord) && defined?(ActiveRecord::Base)
|
81
|
-
end
|
82
|
-
|
83
|
-
depends_on do
|
84
|
-
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 2
|
85
|
-
end
|
86
|
-
|
87
|
-
depends_on do
|
88
|
-
!NewRelic::Control.instance['skip_ar_instrumentation']
|
89
|
-
end
|
90
|
-
|
91
|
-
depends_on do
|
92
|
-
!NewRelic::Control.instance['disable_activerecord_instrumentation']
|
93
|
-
end
|
94
|
-
|
95
|
-
executes do
|
96
|
-
NewRelic::Agent.logger.debug 'Installing Rails 2 ActiveRecord instrumentation'
|
97
|
-
end
|
98
|
-
|
99
|
-
executes do
|
100
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
101
|
-
include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
executes do
|
106
|
-
ActiveRecord::Base.class_eval do
|
107
|
-
class << self
|
108
|
-
add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
|
109
|
-
add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
DependencyDetection.detect!
|
@@ -1,122 +0,0 @@
|
|
1
|
-
module NewRelic
|
2
|
-
module Agent
|
3
|
-
module Instrumentation
|
4
|
-
module ActiveRecordInstrumentation
|
5
|
-
|
6
|
-
def self.included(instrumented_class)
|
7
|
-
instrumented_class.class_eval do
|
8
|
-
unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
|
9
|
-
alias_method :log_without_newrelic_instrumentation, :log
|
10
|
-
alias_method :log, :log_with_newrelic_instrumentation
|
11
|
-
protected :log
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def log_with_newrelic_instrumentation(*args, &block)
|
17
|
-
|
18
|
-
return log_without_newrelic_instrumentation(*args, &block) unless NewRelic::Agent.is_execution_traced?
|
19
|
-
|
20
|
-
sql, name, binds = args
|
21
|
-
|
22
|
-
# Capture db config if we are going to try to get the explain plans
|
23
|
-
if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
|
24
|
-
(defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && self.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)) ||
|
25
|
-
(defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
|
26
|
-
supported_config = @config
|
27
|
-
end
|
28
|
-
if name && (parts = name.split " ") && parts.size == 2
|
29
|
-
model = parts.first
|
30
|
-
operation = parts.last.downcase
|
31
|
-
metric_name = case operation
|
32
|
-
when 'load', 'count', 'exists' then 'find'
|
33
|
-
when 'indexes', 'columns' then nil # fall back to DirectSQL
|
34
|
-
when 'destroy', 'find', 'save', 'create' then operation
|
35
|
-
when 'update' then 'save'
|
36
|
-
else
|
37
|
-
if model == 'Join'
|
38
|
-
operation
|
39
|
-
end
|
40
|
-
end
|
41
|
-
metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
|
42
|
-
end
|
43
|
-
|
44
|
-
if metric.nil?
|
45
|
-
metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
|
46
|
-
if metric.nil?
|
47
|
-
if sql =~ /^(select|update|insert|delete|show)/i
|
48
|
-
# Could not determine the model/operation so let's find a better
|
49
|
-
# metric. If it doesn't match the regex, it's probably a show
|
50
|
-
# command or some DDL which we'll ignore.
|
51
|
-
metric = "Database/SQL/#{$1.downcase}"
|
52
|
-
else
|
53
|
-
metric = "Database/SQL/other"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
if !metric
|
59
|
-
log_without_newrelic_instrumentation(*args, &block)
|
60
|
-
else
|
61
|
-
metrics = [metric, "ActiveRecord/all"]
|
62
|
-
metrics << "ActiveRecord/#{metric_name}" if metric_name
|
63
|
-
self.class.trace_execution_scoped(metrics) do
|
64
|
-
sql, name, binds = args
|
65
|
-
t0 = Time.now
|
66
|
-
begin
|
67
|
-
log_without_newrelic_instrumentation(*args, &block)
|
68
|
-
ensure
|
69
|
-
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, supported_config, (Time.now - t0).to_f)
|
70
|
-
NewRelic::Agent.instance.sql_sampler.notice_sql(sql, metric, supported_config, (Time.now - t0).to_f)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
DependencyDetection.defer do
|
82
|
-
@name = :rails3_active_record
|
83
|
-
|
84
|
-
depends_on do
|
85
|
-
defined?(ActiveRecord) && defined?(ActiveRecord::Base)
|
86
|
-
end
|
87
|
-
|
88
|
-
depends_on do
|
89
|
-
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
90
|
-
end
|
91
|
-
|
92
|
-
depends_on do
|
93
|
-
!NewRelic::Control.instance['skip_ar_instrumentation']
|
94
|
-
end
|
95
|
-
|
96
|
-
depends_on do
|
97
|
-
!NewRelic::Control.instance['disable_activerecord_instrumentation']
|
98
|
-
end
|
99
|
-
|
100
|
-
executes do
|
101
|
-
NewRelic::Agent.logger.debug 'Installing Rails 3 ActiveRecord instrumentation'
|
102
|
-
end
|
103
|
-
|
104
|
-
executes do
|
105
|
-
Rails.configuration.after_initialize do
|
106
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
107
|
-
include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
executes do
|
113
|
-
Rails.configuration.after_initialize do
|
114
|
-
ActiveRecord::Base.class_eval do
|
115
|
-
class << self
|
116
|
-
add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
|
117
|
-
add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|