newrelic_rpm 2.14.1 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +8 -0
- data/README.rdoc +2 -0
- data/install.rb +2 -2
- data/lib/new_relic/agent.rb +34 -1
- data/lib/new_relic/agent/agent.rb +34 -25
- data/lib/new_relic/agent/browser_monitoring.rb +111 -0
- data/lib/new_relic/agent/error_collector.rb +4 -4
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -7
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +8 -8
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +26 -26
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +15 -15
- data/lib/new_relic/agent/shim_agent.rb +2 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +3 -3
- data/lib/new_relic/agent/stats_engine/samplers.rb +2 -2
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
- data/lib/new_relic/agent/transaction_sampler.rb +299 -251
- data/lib/new_relic/control.rb +2 -2
- data/lib/new_relic/control/class_methods.rb +0 -5
- data/lib/new_relic/control/configuration.rb +4 -3
- data/lib/new_relic/control/frameworks/rails.rb +9 -12
- data/lib/new_relic/control/instance_methods.rb +2 -2
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/control/server_methods.rb +2 -2
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/local_environment.rb +7 -7
- data/lib/new_relic/rack/browser_monitoring.rb +61 -0
- data/lib/new_relic/stats.rb +6 -6
- data/lib/new_relic/version.rb +4 -4
- data/newrelic.yml +19 -0
- data/newrelic_rpm.gemspec +9 -4
- data/test/active_record_fixtures.rb +5 -5
- data/test/config/test_control.rb +3 -3
- data/test/new_relic/agent/agent/connect_test.rb +27 -6
- data/test/new_relic/agent/agent/start_test.rb +13 -13
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +8 -8
- data/test/new_relic/agent/agent_test.rb +85 -0
- data/test/new_relic/agent/agent_test_controller.rb +9 -9
- data/test/new_relic/agent/agent_test_controller_test.rb +37 -37
- data/test/new_relic/agent/browser_monitoring_test.rb +124 -0
- data/test/new_relic/agent/busy_calculator_test.rb +7 -7
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -9
- data/test/new_relic/agent/error_collector_test.rb +54 -54
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +69 -69
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +11 -11
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +38 -35
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +18 -18
- data/test/new_relic/agent/memcache_instrumentation_test.rb +12 -12
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +16 -15
- data/test/new_relic/agent/method_tracer_test.rb +60 -60
- data/test/new_relic/agent/mock_scope_listener.rb +8 -8
- data/test/new_relic/agent/rpm_agent_test.rb +26 -26
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +17 -17
- data/test/new_relic/agent/stats_engine/samplers_test.rb +4 -4
- data/test/new_relic/agent/stats_engine/stats_engine_test.rb +51 -51
- data/test/new_relic/agent/transaction_sample_builder_test.rb +36 -36
- data/test/new_relic/agent/transaction_sampler_test.rb +727 -178
- data/test/new_relic/agent/worker_loop_test.rb +4 -4
- data/test/new_relic/collection_helper_test.rb +15 -15
- data/test/new_relic/command/deployments_test.rb +5 -5
- data/test/new_relic/control_test.rb +25 -25
- data/test/new_relic/local_environment_test.rb +11 -11
- data/test/new_relic/metric_spec_test.rb +21 -21
- data/test/new_relic/rack/episodes_test.rb +35 -35
- data/test/new_relic/stats_test.rb +61 -43
- data/test/new_relic/transaction_sample_subtest_test.rb +15 -15
- data/test/new_relic/transaction_sample_test.rb +25 -25
- data/test/new_relic/version_number_test.rb +11 -11
- data/test/test_contexts.rb +7 -7
- data/test/test_helper.rb +6 -6
- data/ui/helpers/developer_mode_helper.rb +67 -67
- data/ui/helpers/google_pie_chart.rb +4 -4
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +7 -7
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +9 -9
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +9 -9
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +4 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +21 -21
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +6 -6
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +8 -8
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +3 -3
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +5 -5
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +20 -20
- metadata +15 -9
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -109
@@ -3,15 +3,15 @@ module NewRelic
|
|
3
3
|
module MetricParser
|
4
4
|
class StrutsAction < NewRelic::MetricParser::MetricParser
|
5
5
|
include NewRelic::MetricParser::JavaParser
|
6
|
-
|
6
|
+
|
7
7
|
def method_name
|
8
8
|
"execute"
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def full_class_name
|
12
12
|
segment_1
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def call_rate_suffix
|
16
16
|
'cpm'
|
17
17
|
end
|
@@ -3,15 +3,15 @@ module NewRelic
|
|
3
3
|
module MetricParser
|
4
4
|
class StrutsResult < NewRelic::MetricParser::MetricParser
|
5
5
|
include JavaParser
|
6
|
-
|
6
|
+
|
7
7
|
def method_name
|
8
8
|
"execute"
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def full_class_name
|
12
12
|
segment_1
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def call_rate_suffix
|
16
16
|
'cpm'
|
17
17
|
end
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
"#{file_name(segments[-2])} Partial"
|
19
19
|
when ".rhtml Processing"
|
20
20
|
"ERB compilation"
|
21
|
-
else
|
21
|
+
else
|
22
22
|
segments[1..-1]
|
23
23
|
end
|
24
24
|
end
|
@@ -30,15 +30,15 @@ module NewRelic
|
|
30
30
|
"#{file_name(segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR))} Partial"
|
31
31
|
when ".rhtml Processing"
|
32
32
|
"ERB compilation"
|
33
|
-
else
|
33
|
+
else
|
34
34
|
segments[1..-1].join("/")
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def short_name
|
39
39
|
segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def controller_name
|
43
43
|
template_label
|
44
44
|
end
|
@@ -51,7 +51,7 @@ module NewRelic
|
|
51
51
|
def developer_name
|
52
52
|
template_label
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def url
|
56
56
|
'/' + file_name(segments[1..-2].join('/'))
|
57
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricParser
|
2
|
-
|
2
|
+
|
3
3
|
def is_web_transaction?; true; end
|
4
4
|
def is_transaction?; true; end
|
5
5
|
|
@@ -9,13 +9,13 @@ class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricPar
|
|
9
9
|
# class name. If it begins with a capital letter, assume it's already a class name
|
10
10
|
def controller_name
|
11
11
|
path = segments[2..-2].join('/')
|
12
|
-
path < 'a' ? path : camelize(path)+"Controller"
|
12
|
+
path < 'a' ? path : camelize(path)+"Controller"
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def action_name
|
16
16
|
segments[-1]
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def developer_name
|
20
20
|
if action_name
|
21
21
|
"#{controller_name}##{action_name}"
|
@@ -25,7 +25,7 @@ class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricPar
|
|
25
25
|
end
|
26
26
|
def short_name
|
27
27
|
developer_name
|
28
|
-
|
28
|
+
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -44,32 +44,32 @@ class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricPar
|
|
44
44
|
def action_name; segments[3]; end
|
45
45
|
def controller_name; segments[2]; end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
module Rack
|
49
49
|
include Task
|
50
50
|
|
51
51
|
def is_web_transaction?; true; end
|
52
52
|
def category; 'Rack App'; end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
module Spring
|
56
56
|
def category; 'Spring Transaction'; end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
module SpringView
|
60
60
|
def is_web_transaction?; true; end
|
61
61
|
def category; 'Spring View'; end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
module SpringController
|
65
65
|
def is_web_transaction?; true; end
|
66
66
|
def category; 'Spring Controller'; end
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
module Solr
|
70
70
|
def category; 'Solr Request'; end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
module CXF
|
74
74
|
def category; 'CXF Transaction'; end
|
75
75
|
end
|
@@ -86,24 +86,24 @@ class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricPar
|
|
86
86
|
pattern
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
module Sinatra
|
91
91
|
include Pattern
|
92
92
|
def is_web_transaction?; true; end
|
93
93
|
def category; 'Sinatra'; end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
def initialize(name)
|
97
97
|
super
|
98
98
|
if %w[Sinatra Spring SpringController SpringView Solr CXF Task Pattern Rack Controller].include?(segment_1)
|
99
99
|
self.extend NewRelic::MetricParser::WebTransaction.const_get(segment_1)
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def developer_name
|
104
104
|
url
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def short_name
|
108
108
|
if segments.length > 2
|
109
109
|
developer_name
|
@@ -111,21 +111,21 @@ class NewRelic::MetricParser::WebTransaction < NewRelic::MetricParser::MetricPar
|
|
111
111
|
'All Web Transactions'
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def url
|
116
116
|
'/' + segments[2..-1].join('/')
|
117
117
|
end
|
118
|
-
|
119
|
-
# this is used to match transaction traces to controller actions.
|
118
|
+
|
119
|
+
# this is used to match transaction traces to controller actions.
|
120
120
|
# TT's don't have a preceding slash :P
|
121
121
|
def tt_path
|
122
122
|
segments[2..-1].join('/')
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
def call_rate_suffix
|
126
126
|
'rpm'
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
# default to v2 Web Transactions tab
|
130
130
|
def drilldown_url(metric_id)
|
131
131
|
{:controller => '/v2/transactions', :action => 'index', :anchor => "id=#{metric_id}"}
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -1848230019
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- beta1
|
11
|
+
version: 3.0.0.beta1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Bill Kayser
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2011-
|
20
|
+
date: 2011-04-29 00:00:00 -07:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- lib/conditional_vendored_metric_parser.rb
|
97
98
|
- lib/new_relic/agent.rb
|
98
99
|
- lib/new_relic/agent/agent.rb
|
100
|
+
- lib/new_relic/agent/browser_monitoring.rb
|
99
101
|
- lib/new_relic/agent/busy_calculator.rb
|
100
102
|
- lib/new_relic/agent/chained_call.rb
|
101
103
|
- lib/new_relic/agent/error_collector.rb
|
@@ -120,7 +122,6 @@ files:
|
|
120
122
|
- lib/new_relic/agent/instrumentation/rails3/action_controller.rb
|
121
123
|
- lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb
|
122
124
|
- lib/new_relic/agent/instrumentation/rails3/errors.rb
|
123
|
-
- lib/new_relic/agent/instrumentation/sequel.rb
|
124
125
|
- lib/new_relic/agent/instrumentation/sinatra.rb
|
125
126
|
- lib/new_relic/agent/instrumentation/sunspot.rb
|
126
127
|
- lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- lib/new_relic/agent/stats_engine/metric_stats.rb
|
136
137
|
- lib/new_relic/agent/stats_engine/samplers.rb
|
137
138
|
- lib/new_relic/agent/stats_engine/transactions.rb
|
139
|
+
- lib/new_relic/agent/transaction_sample_builder.rb
|
138
140
|
- lib/new_relic/agent/transaction_sampler.rb
|
139
141
|
- lib/new_relic/agent/worker_loop.rb
|
140
142
|
- lib/new_relic/collection_helper.rb
|
@@ -163,6 +165,7 @@ files:
|
|
163
165
|
- lib/new_relic/metric_spec.rb
|
164
166
|
- lib/new_relic/metrics.rb
|
165
167
|
- lib/new_relic/noticed_error.rb
|
168
|
+
- lib/new_relic/rack/browser_monitoring.rb
|
166
169
|
- lib/new_relic/rack/developer_mode.rb
|
167
170
|
- lib/new_relic/rack/metric_app.rb
|
168
171
|
- lib/new_relic/rack/mongrel_rpm.ru
|
@@ -188,13 +191,16 @@ files:
|
|
188
191
|
- test/new_relic/agent/agent/connect_test.rb
|
189
192
|
- test/new_relic/agent/agent/start_test.rb
|
190
193
|
- test/new_relic/agent/agent/start_worker_thread_test.rb
|
194
|
+
- test/new_relic/agent/agent_test.rb
|
191
195
|
- test/new_relic/agent/agent_test_controller.rb
|
192
196
|
- test/new_relic/agent/agent_test_controller_test.rb
|
193
197
|
- test/new_relic/agent/apdex_from_server_test.rb
|
198
|
+
- test/new_relic/agent/browser_monitoring_test.rb
|
194
199
|
- test/new_relic/agent/busy_calculator_test.rb
|
195
200
|
- test/new_relic/agent/error_collector/notice_error_test.rb
|
196
201
|
- test/new_relic/agent/error_collector_test.rb
|
197
202
|
- test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb
|
203
|
+
- test/new_relic/agent/instrumentation/controller_instrumentation_test.rb
|
198
204
|
- test/new_relic/agent/instrumentation/instrumentation_test.rb
|
199
205
|
- test/new_relic/agent/instrumentation/metric_frame_test.rb
|
200
206
|
- test/new_relic/agent/instrumentation/net_instrumentation_test.rb
|
@@ -327,7 +333,7 @@ post_install_message: |+
|
|
327
333
|
|
328
334
|
Please see http://support.newrelic.com/faqs/docs/ruby-agent-release-notes
|
329
335
|
for a complete description of the features and enhancements available
|
330
|
-
in version
|
336
|
+
in version 3.0 of the Ruby Agent.
|
331
337
|
|
332
338
|
For details on this specific release, refer to the CHANGELOG file.
|
333
339
|
|
@@ -1,109 +0,0 @@
|
|
1
|
-
## NewRelic instrumentation for Sequel
|
2
|
-
#
|
3
|
-
# This is based heavily on the DataMapper instrumentation.
|
4
|
-
# See data_mapper.rb for major differences compared to the ActiveRecord instrumentation.
|
5
|
-
#
|
6
|
-
|
7
|
-
DependencyDetection.defer do
|
8
|
-
depends_on do
|
9
|
-
defined?(::Sequel)
|
10
|
-
end
|
11
|
-
|
12
|
-
executes do
|
13
|
-
# Sequel::Model class methods
|
14
|
-
::Sequel::Model::ClassMethods.class_eval do
|
15
|
-
|
16
|
-
add_method_tracer :[], 'ActiveRecord/#{self.name}/find'
|
17
|
-
|
18
|
-
add_method_tracer :all, 'ActiveRecord/#{self.name}/find'
|
19
|
-
add_method_tracer :each, 'ActiveRecord/#{self.name}/find'
|
20
|
-
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
21
|
-
add_method_tracer :insert, 'ActiveRecord/#{self.name}/create'
|
22
|
-
add_method_tracer :insert_multiple, 'ActiveRecord/#{self.name}/create'
|
23
|
-
add_method_tracer :import, 'ActiveRecord/#{self.name}/create'
|
24
|
-
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
25
|
-
add_method_tracer :delete, 'ActiveRecord/#{self.name}/delete'
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
# Sequel's Model instance methods
|
30
|
-
::Sequel::Model::InstanceMethods.class_eval do
|
31
|
-
|
32
|
-
add_method_tracer :_insert, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/create'
|
33
|
-
add_method_tracer :_update, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
|
34
|
-
add_method_tracer :_delete, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
# Sequel's Dataset instance methods
|
39
|
-
::Sequel::Dataset.class_eval do
|
40
|
-
|
41
|
-
add_method_tracer :execute, 'ActiveRecord/#{model ? model.name : "Dataset#{first_source}"}/find'
|
42
|
-
add_method_tracer :execute_insert, 'ActiveRecord/#{model ? model.name : "Dataset#{first_source}"}/create'
|
43
|
-
add_method_tracer :execute_dui, 'ActiveRecord/#{model ? model.name : "Dataset#{first_source}"}/update'
|
44
|
-
add_method_tracer :execute_ddl, 'ActiveRecord/#{model ? model.name : "Dataset#{first_source}"}/all'
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
# Sequel's Database methods
|
49
|
-
::Sequel::Database.class_eval do
|
50
|
-
|
51
|
-
add_method_tracer :execute, 'ActiveRecord/Database/find'
|
52
|
-
add_method_tracer :execute_insert, 'ActiveRecord/Database/create'
|
53
|
-
add_method_tracer :execute_dui, 'ActiveRecord/Database/update'
|
54
|
-
add_method_tracer :execute_ddl, 'ActiveRecord/Database/all'
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
module NewRelic
|
62
|
-
module Agent
|
63
|
-
module Instrumentation
|
64
|
-
module SequelInstrumentation
|
65
|
-
def self.included(klass)
|
66
|
-
klass.class_eval do
|
67
|
-
alias_method :log_duration_without_newrelic_instrumentation, :log_duration
|
68
|
-
alias_method :log_duration, :log_duration_with_newrelic_instrumentation
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def log_duration_with_newrelic_instrumentation(duration, sql)
|
73
|
-
return unless NewRelic::Agent.is_execution_traced?
|
74
|
-
return unless operation = case sql
|
75
|
-
when /^\s*select/i then 'find'
|
76
|
-
when /^\s*(update|insert)/i then 'save'
|
77
|
-
when /^\s*delete/i then 'destroy'
|
78
|
-
else nil
|
79
|
-
end
|
80
|
-
|
81
|
-
# Attach SQL to current segment/scope.
|
82
|
-
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, nil, duration)
|
83
|
-
|
84
|
-
# Record query duration associated with each of the desired metrics.
|
85
|
-
metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
|
86
|
-
metrics.each do |metric|
|
87
|
-
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
|
88
|
-
end
|
89
|
-
ensure
|
90
|
-
log_duration_without_newrelic_instrumentation(duration, sql)
|
91
|
-
end
|
92
|
-
|
93
|
-
end # SequelInstrumentation
|
94
|
-
end # Instrumentation
|
95
|
-
end # Agent
|
96
|
-
end # NewRelic
|
97
|
-
|
98
|
-
DependencyDetection.defer do
|
99
|
-
depends_on do
|
100
|
-
defined?(::Sequel) && defined?(::Sequel::Database)
|
101
|
-
end
|
102
|
-
|
103
|
-
executes do
|
104
|
-
::Sequel::Database.class_eval do
|
105
|
-
include ::NewRelic::Agent::Instrumentation::SequelInstrumentation
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|