factorylabs-newrelic_rpm 2.10.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +354 -0
- data/LICENSE +37 -0
- data/README-2.10.2.2 +10 -0
- data/README.md +138 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic_cmd +4 -0
- data/cert/cacert.pem +34 -0
- data/install.rb +45 -0
- data/lib/new_relic/agent.rb +315 -0
- data/lib/new_relic/agent/agent.rb +647 -0
- data/lib/new_relic/agent/busy_calculator.rb +86 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/collection_helper.rb +66 -0
- data/lib/new_relic/agent/error_collector.rb +117 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +18 -0
- data/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb +91 -0
- data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +389 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +90 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +12 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +24 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +26 -0
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +8 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +199 -0
- data/lib/new_relic/agent/instrumentation/net.rb +21 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +20 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +109 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +59 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +27 -0
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +24 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +39 -0
- data/lib/new_relic/agent/method_tracer.rb +348 -0
- data/lib/new_relic/agent/patch_const_missing.rb +125 -0
- data/lib/new_relic/agent/sampler.rb +46 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +50 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +141 -0
- data/lib/new_relic/agent/samplers/mongrel_sampler.rb +23 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +24 -0
- data/lib/new_relic/agent/shim_agent.rb +21 -0
- data/lib/new_relic/agent/stats_engine.rb +22 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +116 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +74 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +154 -0
- data/lib/new_relic/agent/transaction_sampler.rb +315 -0
- data/lib/new_relic/agent/worker_loop.rb +118 -0
- data/lib/new_relic/commands/deployments.rb +145 -0
- data/lib/new_relic/commands/new_relic_commands.rb +30 -0
- data/lib/new_relic/control.rb +484 -0
- data/lib/new_relic/control/external.rb +13 -0
- data/lib/new_relic/control/merb.rb +24 -0
- data/lib/new_relic/control/rails.rb +151 -0
- data/lib/new_relic/control/ruby.rb +36 -0
- data/lib/new_relic/control/sinatra.rb +14 -0
- data/lib/new_relic/histogram.rb +89 -0
- data/lib/new_relic/local_environment.rb +299 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +42 -0
- data/lib/new_relic/metric_parser.rb +124 -0
- data/lib/new_relic/metric_parser/action_mailer.rb +9 -0
- data/lib/new_relic/metric_parser/active_merchant.rb +26 -0
- data/lib/new_relic/metric_parser/active_record.rb +25 -0
- data/lib/new_relic/metric_parser/controller.rb +54 -0
- data/lib/new_relic/metric_parser/controller_cpu.rb +38 -0
- data/lib/new_relic/metric_parser/errors.rb +6 -0
- data/lib/new_relic/metric_parser/external.rb +50 -0
- data/lib/new_relic/metric_parser/mem_cache.rb +12 -0
- data/lib/new_relic/metric_parser/other_transaction.rb +15 -0
- data/lib/new_relic/metric_parser/view.rb +61 -0
- data/lib/new_relic/metric_parser/web_frontend.rb +14 -0
- data/lib/new_relic/metric_parser/web_service.rb +9 -0
- data/lib/new_relic/metric_spec.rb +67 -0
- data/lib/new_relic/metrics.rb +7 -0
- data/lib/new_relic/noticed_error.rb +23 -0
- data/lib/new_relic/rack/metric_app.rb +56 -0
- data/lib/new_relic/rack/mongrel_rpm.ru +25 -0
- data/lib/new_relic/rack/newrelic.yml +26 -0
- data/lib/new_relic/rack_app.rb +5 -0
- data/lib/new_relic/recipes.rb +82 -0
- data/lib/new_relic/stats.rb +362 -0
- data/lib/new_relic/transaction_analysis.rb +121 -0
- data/lib/new_relic/transaction_sample.rb +671 -0
- data/lib/new_relic/version.rb +54 -0
- data/lib/new_relic_api.rb +276 -0
- data/lib/newrelic_rpm.rb +45 -0
- data/lib/tasks/all.rb +4 -0
- data/lib/tasks/install.rake +7 -0
- data/lib/tasks/tests.rake +15 -0
- data/newrelic.yml +227 -0
- data/newrelic_rpm.gemspec +214 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +55 -0
- data/test/config/newrelic.yml +46 -0
- data/test/config/test_control.rb +38 -0
- data/test/new_relic/agent/active_record_instrumentation_test.rb +268 -0
- data/test/new_relic/agent/agent_controller_test.rb +254 -0
- data/test/new_relic/agent/agent_test_controller.rb +78 -0
- data/test/new_relic/agent/busy_calculator_test.rb +79 -0
- data/test/new_relic/agent/classloader_patch_test.rb +56 -0
- data/test/new_relic/agent/collection_helper_test.rb +125 -0
- data/test/new_relic/agent/error_collector_test.rb +173 -0
- data/test/new_relic/agent/method_tracer_test.rb +340 -0
- data/test/new_relic/agent/metric_data_test.rb +56 -0
- data/test/new_relic/agent/mock_ar_connection.rb +40 -0
- data/test/new_relic/agent/mock_scope_listener.rb +23 -0
- data/test/new_relic/agent/net_instrumentation_test.rb +63 -0
- data/test/new_relic/agent/rpm_agent_test.rb +125 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +79 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +88 -0
- data/test/new_relic/agent/stats_engine/stats_engine_test.rb +184 -0
- data/test/new_relic/agent/task_instrumentation_test.rb +177 -0
- data/test/new_relic/agent/testable_agent.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +195 -0
- data/test/new_relic/agent/transaction_sample_test.rb +186 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +404 -0
- data/test/new_relic/agent/worker_loop_test.rb +103 -0
- data/test/new_relic/control_test.rb +110 -0
- data/test/new_relic/delayed_job_test.rb +108 -0
- data/test/new_relic/deployments_api_test.rb +68 -0
- data/test/new_relic/environment_test.rb +75 -0
- data/test/new_relic/metric_parser_test.rb +172 -0
- data/test/new_relic/metric_spec_test.rb +177 -0
- data/test/new_relic/shim_agent_test.rb +9 -0
- data/test/new_relic/stats_test.rb +291 -0
- data/test/new_relic/version_number_test.rb +76 -0
- data/test/test_helper.rb +53 -0
- data/test/ui/newrelic_controller_test.rb +14 -0
- data/test/ui/newrelic_helper_test.rb +53 -0
- data/ui/controllers/newrelic_controller.rb +220 -0
- data/ui/helpers/google_pie_chart.rb +49 -0
- data/ui/helpers/newrelic_helper.rb +320 -0
- data/ui/views/layouts/newrelic_default.rhtml +47 -0
- data/ui/views/newrelic/_explain_plans.rhtml +27 -0
- data/ui/views/newrelic/_sample.rhtml +19 -0
- data/ui/views/newrelic/_segment.rhtml +28 -0
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
- data/ui/views/newrelic/_segment_row.rhtml +14 -0
- data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_sql.rhtml +20 -0
- data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
- data/ui/views/newrelic/_sql_row.rhtml +11 -0
- data/ui/views/newrelic/_stack_trace.rhtml +30 -0
- data/ui/views/newrelic/_table.rhtml +12 -0
- data/ui/views/newrelic/explain_sql.rhtml +42 -0
- data/ui/views/newrelic/images/arrow-close.png +0 -0
- data/ui/views/newrelic/images/arrow-open.png +0 -0
- data/ui/views/newrelic/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/images/file_icon.png +0 -0
- data/ui/views/newrelic/images/gray_bar.gif +0 -0
- data/ui/views/newrelic/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/images/textmate.png +0 -0
- data/ui/views/newrelic/index.rhtml +57 -0
- data/ui/views/newrelic/javascript/prototype-scriptaculous.js +7288 -0
- data/ui/views/newrelic/javascript/transaction_sample.js +107 -0
- data/ui/views/newrelic/sample_not_found.rhtml +2 -0
- data/ui/views/newrelic/show_sample.rhtml +80 -0
- data/ui/views/newrelic/show_source.rhtml +3 -0
- data/ui/views/newrelic/stylesheets/style.css +484 -0
- data/ui/views/newrelic/threads.rhtml +52 -0
- metadata +238 -0
@@ -0,0 +1,320 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'new_relic/agent/collection_helper'
|
3
|
+
module NewrelicHelper
|
4
|
+
include NewRelic::Agent::CollectionHelper
|
5
|
+
|
6
|
+
# return the host that serves static content (css, metric documentation, images, etc)
|
7
|
+
# that supports the desktop edition.
|
8
|
+
def server
|
9
|
+
NewRelic::Control.instance['desktop_server'] || "http://rpm.newrelic.com"
|
10
|
+
end
|
11
|
+
|
12
|
+
# limit of how many detail/SQL rows we display - very large data sets (~10000+) crash browsers
|
13
|
+
def trace_row_display_limit
|
14
|
+
2000
|
15
|
+
end
|
16
|
+
|
17
|
+
def trace_row_display_limit_reached
|
18
|
+
(!@detail_segment_count.nil? && @detail_segment_count > trace_row_display_limit) || @sample.sql_segments.length > trace_row_display_limit
|
19
|
+
end
|
20
|
+
|
21
|
+
# return the sample but post processed to strip out segments that normally don't show
|
22
|
+
# up in production (after the first execution, at least) such as application code loading
|
23
|
+
def stripped_sample(sample = @sample)
|
24
|
+
sample.omit_segments_with('(Rails/Application Code Loading)|(Database/.*/.+ Columns)')
|
25
|
+
end
|
26
|
+
|
27
|
+
# return the highest level in the call stack for the trace that is not rails or
|
28
|
+
# newrelic agent code
|
29
|
+
def application_caller(trace)
|
30
|
+
trace = strip_nr_from_backtrace(trace) unless params[:show_nr]
|
31
|
+
trace.each do |trace_line|
|
32
|
+
file = file_and_line(trace_line).first
|
33
|
+
unless exclude_file_from_stack_trace?(file, false)
|
34
|
+
return trace_line
|
35
|
+
end
|
36
|
+
end
|
37
|
+
trace.last
|
38
|
+
end
|
39
|
+
|
40
|
+
def application_stack_trace(trace, include_rails = false)
|
41
|
+
trace = strip_nr_from_backtrace(trace) unless params[:show_nr]
|
42
|
+
trace.reject do |trace_line|
|
43
|
+
file = file_and_line(trace_line).first
|
44
|
+
exclude_file_from_stack_trace?(file, include_rails)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_backtrace
|
49
|
+
if @segment[:backtrace]
|
50
|
+
content_tag('h3', 'Application Stack Trace') +
|
51
|
+
render(:partial => agent_views_path('stack_trace'), :locals => {:segment => @segment})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def agent_views_path(path)
|
56
|
+
path
|
57
|
+
end
|
58
|
+
|
59
|
+
def url_for_metric_doc(metric_name)
|
60
|
+
"#{server}/metric_doc?metric=#{CGI::escape(metric_name)}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def url_for_source(trace_line)
|
64
|
+
file, line = file_and_line(trace_line)
|
65
|
+
|
66
|
+
begin
|
67
|
+
file = Pathname.new(file).realpath
|
68
|
+
rescue Errno::ENOENT
|
69
|
+
# we hit this exception when Pathame.realpath fails for some reason; attempt a link to
|
70
|
+
# the file without a real path. It may also fail, only when the user clicks on this specific
|
71
|
+
# entry in the stack trace
|
72
|
+
rescue
|
73
|
+
# catch all other exceptions. We're going to create an invalid link below, but that's okay.
|
74
|
+
end
|
75
|
+
|
76
|
+
if using_textmate?
|
77
|
+
"txmt://open?url=file://#{file}&line=#{line}"
|
78
|
+
else
|
79
|
+
url_for :action => 'show_source', :file => file, :line => line, :anchor => 'selected_line'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def dev_name(metric_name)
|
84
|
+
NewRelic::MetricParser.parse(metric_name).developer_name
|
85
|
+
end
|
86
|
+
|
87
|
+
# write the metric label for a segment metric in the detail view
|
88
|
+
def write_segment_label(segment)
|
89
|
+
if source_available && segment[:backtrace] && (source_url = url_for_source(application_caller(segment[:backtrace])))
|
90
|
+
link_to dev_name(segment.metric_name), source_url
|
91
|
+
else
|
92
|
+
h(dev_name(segment.metric_name))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def source_available
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
# write the metric label for a segment metric in the summary table of metrics
|
101
|
+
def write_summary_segment_label(segment)
|
102
|
+
dev_name(segment.metric_name)
|
103
|
+
end
|
104
|
+
|
105
|
+
def write_stack_trace_line(trace_line)
|
106
|
+
link_to h(trace_line), url_for_source(trace_line)
|
107
|
+
end
|
108
|
+
|
109
|
+
# write a link to the source for a trace
|
110
|
+
def link_to_source(trace)
|
111
|
+
image_url = url_for(:controller => :newrelic, :action => :file, :file => (using_textmate? ? "textmate.png" : "file_icon.png"))
|
112
|
+
|
113
|
+
link_to image_tag(image_url, :alt => (title = 'View Source'), :title => title), url_for_source(application_caller(trace))
|
114
|
+
end
|
115
|
+
|
116
|
+
# print the formatted timestamp for a segment
|
117
|
+
def timestamp(segment)
|
118
|
+
sprintf("%1.3f", segment.entry_timestamp)
|
119
|
+
end
|
120
|
+
|
121
|
+
def format_timestamp(time)
|
122
|
+
time.strftime("%H:%M:%S")
|
123
|
+
end
|
124
|
+
|
125
|
+
def colorize(value, yellow_threshold = 0.05, red_threshold = 0.15, s=to_ms(value))
|
126
|
+
if value > yellow_threshold
|
127
|
+
color = (value > red_threshold ? 'red' : 'orange')
|
128
|
+
"<font color=#{color}>#{s}</font>"
|
129
|
+
else
|
130
|
+
"#{s}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def expanded_image_path()
|
135
|
+
url_for(:controller => :newrelic, :action => :file, :file => 'arrow-open.png')
|
136
|
+
end
|
137
|
+
|
138
|
+
def collapsed_image_path()
|
139
|
+
url_for(:controller => :newrelic, :action => :file, :file => 'arrow-close.png')
|
140
|
+
end
|
141
|
+
|
142
|
+
def explain_sql_url(segment)
|
143
|
+
url_for(:action => :explain_sql,
|
144
|
+
:id => @sample.sample_id,
|
145
|
+
:segment => segment.segment_id)
|
146
|
+
end
|
147
|
+
|
148
|
+
def segment_duration_value(segment)
|
149
|
+
link_to colorize(segment.duration, 0.05, 0.15, "#{with_delimiter(to_ms(segment.duration))} ms"), explain_sql_url(segment)
|
150
|
+
end
|
151
|
+
|
152
|
+
def line_wrap_sql(sql)
|
153
|
+
h(sql.gsub(/\,/,', ').squeeze(' ')) if sql
|
154
|
+
end
|
155
|
+
|
156
|
+
def render_sample_details(sample)
|
157
|
+
@indentation_depth=0
|
158
|
+
# skip past the root segments to the first child, which is always the controller
|
159
|
+
first_segment = sample.root_segment.called_segments.first
|
160
|
+
|
161
|
+
# render the segments, then the css classes to indent them
|
162
|
+
render_segment_details(first_segment) + render_indentation_classes(@indentation_depth)
|
163
|
+
end
|
164
|
+
|
165
|
+
# the rows logger plugin disables the sql tracing functionality of the NewRelic agent -
|
166
|
+
# notify the user about this
|
167
|
+
def rows_logger_present?
|
168
|
+
File.exist?(File.join(File.dirname(__FILE__), "../../../rows_logger/init.rb"))
|
169
|
+
end
|
170
|
+
|
171
|
+
def expand_segment_image(segment, depth)
|
172
|
+
if depth > 0
|
173
|
+
if !segment.called_segments.empty?
|
174
|
+
row_class =segment_child_row_class(segment)
|
175
|
+
link_to_function(tag('img', :src => collapsed_image_path, :id => "image_#{row_class}",
|
176
|
+
:class_for_children => row_class,
|
177
|
+
:class => (!segment.called_segments.empty?) ? 'parent_segment_image' : 'child_segment_image'),
|
178
|
+
"toggle_row_class(this)")
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def segment_child_row_class(segment)
|
184
|
+
"segment#{segment.segment_id}"
|
185
|
+
end
|
186
|
+
|
187
|
+
def summary_pie_chart(sample, width, height)
|
188
|
+
pie_chart = GooglePieChart.new
|
189
|
+
pie_chart.color, pie_chart.width, pie_chart.height = '6688AA', width, height
|
190
|
+
|
191
|
+
chart_data = sample.breakdown_data(6)
|
192
|
+
chart_data.each { |s| pie_chart.add_data_point dev_name(s.metric_name), to_ms(s.exclusive_time) }
|
193
|
+
|
194
|
+
pie_chart.render
|
195
|
+
end
|
196
|
+
|
197
|
+
def segment_row_classes(segment, depth)
|
198
|
+
classes = []
|
199
|
+
|
200
|
+
classes << "segment#{segment.parent_segment.segment_id}" if depth > 1
|
201
|
+
|
202
|
+
classes << "view_segment" if segment.metric_name.index('View') == 0
|
203
|
+
classes << "summary_segment" if segment.is_a?(NewRelic::TransactionSample::CompositeSegment)
|
204
|
+
|
205
|
+
classes.join(' ')
|
206
|
+
end
|
207
|
+
|
208
|
+
# render_segment_details should be called before calling this method
|
209
|
+
def render_indentation_classes(depth)
|
210
|
+
styles = []
|
211
|
+
(1..depth).each do |d|
|
212
|
+
styles << ".segment_indent_level#{d} { display: inline-block; margin-left: #{(d-1)*20}px }"
|
213
|
+
end
|
214
|
+
content_tag("style", styles.join(' '))
|
215
|
+
end
|
216
|
+
|
217
|
+
def sql_link_mouseover_options(segment)
|
218
|
+
{ :onmouseover => "sql_mouse_over(#{segment.segment_id})", :onmouseout => "sql_mouse_out(#{segment.segment_id})"}
|
219
|
+
end
|
220
|
+
|
221
|
+
def explain_sql_link(segment, child_sql = false)
|
222
|
+
link_to 'SQL', explain_sql_url(segment), sql_link_mouseover_options(segment)
|
223
|
+
end
|
224
|
+
|
225
|
+
def explain_sql_links(segment)
|
226
|
+
if segment[:sql_obfuscated] || segment[:sql]
|
227
|
+
explain_sql_link segment
|
228
|
+
else
|
229
|
+
links = []
|
230
|
+
segment.called_segments.each do |child|
|
231
|
+
if child[:sql_obfuscated] || child[:sql]
|
232
|
+
links << explain_sql_link(child, true)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
links[0..1].join(', ') + (links.length > 2?', ...':'')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
private
|
240
|
+
def file_and_line(stack_trace_line)
|
241
|
+
stack_trace_line.match(/(.*):(\d+)/)[1..2]
|
242
|
+
end
|
243
|
+
|
244
|
+
def using_textmate?
|
245
|
+
NewRelic::Control.instance.use_textmate?
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
def render_segment_details(segment, depth=0)
|
250
|
+
@detail_segment_count ||= 0
|
251
|
+
@detail_segment_count += 1
|
252
|
+
|
253
|
+
return '' if @detail_segment_count > trace_row_display_limit
|
254
|
+
|
255
|
+
@indentation_depth = depth if depth > @indentation_depth
|
256
|
+
repeat = nil
|
257
|
+
if segment.is_a?(NewRelic::TransactionSample::CompositeSegment)
|
258
|
+
html = ''
|
259
|
+
else
|
260
|
+
repeat = segment.parent_segment.detail_segments.length if segment.parent_segment.is_a?(NewRelic::TransactionSample::CompositeSegment)
|
261
|
+
html = render(:partial => agent_views_path('segment'), :object => segment, :locals => {:indent => depth, :repeat => repeat})
|
262
|
+
depth += 1
|
263
|
+
end
|
264
|
+
|
265
|
+
segment.called_segments.each do |child|
|
266
|
+
html << render_segment_details(child, depth)
|
267
|
+
end
|
268
|
+
|
269
|
+
html
|
270
|
+
end
|
271
|
+
|
272
|
+
def exclude_file_from_stack_trace?(file, include_rails)
|
273
|
+
return false if include_rails
|
274
|
+
return true if file !~ /\.(rb|java)/
|
275
|
+
%w[/actionmailer/
|
276
|
+
/activerecord
|
277
|
+
/activeresource
|
278
|
+
/activesupport
|
279
|
+
/lib/mongrel
|
280
|
+
/actionpack
|
281
|
+
/passenger/
|
282
|
+
/railties
|
283
|
+
benchmark.rb].each { |s| return true if file.include? s }
|
284
|
+
false
|
285
|
+
end
|
286
|
+
|
287
|
+
def show_view_link(title, page_name)
|
288
|
+
link_to_function("[#{title}]", "show_view('#{page_name}')");
|
289
|
+
end
|
290
|
+
def mime_type_from_extension(extension)
|
291
|
+
extension = extension[/[^.]*$/].downcase
|
292
|
+
case extension
|
293
|
+
when 'png'; 'image/png'
|
294
|
+
when 'gif'; 'image/gif'
|
295
|
+
when 'jpg'; 'image/jpg'
|
296
|
+
when 'css'; 'text/css'
|
297
|
+
when 'js'; 'text/javascript'
|
298
|
+
else 'text/plain'
|
299
|
+
end
|
300
|
+
end
|
301
|
+
def to_ms(number)
|
302
|
+
(number*1000).round
|
303
|
+
end
|
304
|
+
def to_percentage(value)
|
305
|
+
(value * 100).round if value
|
306
|
+
end
|
307
|
+
def with_delimiter(val)
|
308
|
+
return '0' if val.nil?
|
309
|
+
parts = val.to_s.split('.')
|
310
|
+
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
|
311
|
+
parts.join '.'
|
312
|
+
end
|
313
|
+
|
314
|
+
def profile_table(profile)
|
315
|
+
out = StringIO.new
|
316
|
+
printer = RubyProf::GraphHtmlPrinter.new(profile)
|
317
|
+
printer.print(out, :min_percent=>0.5)
|
318
|
+
out.string[/<body>(.*)<\/body>/im, 0].gsub('<table>', '<table class=profile>')
|
319
|
+
end
|
320
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
2
|
+
xml:lang="en" lang="en">
|
3
|
+
<head>
|
4
|
+
<script type="text/javascript" src="<%= url_for(:controller => :newrelic, :action => :file, :file => 'prototype-scriptaculous.js') %>"></script>
|
5
|
+
<title>New Relic RPM Developer Mode</title>
|
6
|
+
<link href="<%= url_for(:controller => :newrelic, :action => :file, :file => 'style.css') %>"
|
7
|
+
media="screen" rel="stylesheet" type="text/css" />
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="header">
|
11
|
+
<img width="100%" height="4" src="<%= url_for(:controller => :newrelic, :action => :file, :file => 'blue_bar.gif') %>" alt="spacer"/>
|
12
|
+
<table width="100%" height="60">
|
13
|
+
<tr>
|
14
|
+
<td valign="middle">
|
15
|
+
<a href='/newrelic'><img src="<%= url_for(:controller => :newrelic, :action => :file, :file => 'new_relic_rpm_desktop.gif') %>" hspace="10" alt="New Relic RPM"/></a>
|
16
|
+
</td>
|
17
|
+
<td class="top_nav" valign="bottom">
|
18
|
+
<ul id="navlist">
|
19
|
+
<li>» <a href='/newrelic'>Home</a></li>
|
20
|
+
</ul>
|
21
|
+
</td>
|
22
|
+
</tr>
|
23
|
+
</table>
|
24
|
+
<div id="page_nav">
|
25
|
+
<table width="100%" height="100%" background="<%= url_for(:controller => :newrelic, :action => :file, :file => 'gray_bar.gif') %>">
|
26
|
+
<tr valign="middle">
|
27
|
+
<td>
|
28
|
+
<span class="application_title">Developer Mode</span>
|
29
|
+
</td>
|
30
|
+
<td class="title_bar_right">
|
31
|
+
Monitor your Rails Application in production. <%=link_to 'Learn more.', 'http://www.newrelic.com/dev-upgrade.html' %>
|
32
|
+
</td>
|
33
|
+
</tr>
|
34
|
+
</table>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id='content'>
|
38
|
+
<%= yield %>
|
39
|
+
</div>
|
40
|
+
<div id='footer'>
|
41
|
+
<img width="100%" height="4" src="<%= url_for(:controller => :newrelic, :action => :file, :file => 'blue_bar.gif', :content_type => 'image/gif') %>" alt="spacer"/>
|
42
|
+
<p>
|
43
|
+
<a href="/newrelic">Home</a> | <a href="mailto:support@newrelic.com?subject=Feedback" title="">Feedback</a><br />
|
44
|
+
Monitor your Rails Application in Production. <a href="http://www.newrelic.com/dev-upgrade.html">Learn more. »</a><br />
|
45
|
+
© 2008 - <%= Time.now.strftime('%Y') %> New Relic. All rights reserved.</p>
|
46
|
+
</div>
|
47
|
+
</body>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% if @row_headers %>
|
2
|
+
<% @row_headers.length.times do |r| %>
|
3
|
+
<% if @row_headers[r] %>
|
4
|
+
<tr>
|
5
|
+
<th align=right nowrap>
|
6
|
+
<%= @row_headers[r]%>
|
7
|
+
</th>
|
8
|
+
<% @explanation.each do |exp| %>
|
9
|
+
<td>
|
10
|
+
<%= exp[r]%>
|
11
|
+
</td>
|
12
|
+
<% end %>
|
13
|
+
</tr>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<% else %>
|
17
|
+
<tr>
|
18
|
+
<th align=right>Plan</th>
|
19
|
+
<td><p class="plan">
|
20
|
+
<% @explanation.each do |row| -%>
|
21
|
+
<% row.each do |col| -%>
|
22
|
+
<%= h(col) %>
|
23
|
+
<% end -%>
|
24
|
+
<% end -%>
|
25
|
+
</p></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<tr class="<%= cycle('even_row', 'odd_row') %>">
|
2
|
+
<td align=right nowrap=true>
|
3
|
+
<%= Time.at(stripped_sample(sample).timestamp).strftime "%H:%M:%S" %>
|
4
|
+
</td>
|
5
|
+
<td align=right nowrap=true>
|
6
|
+
<%= colorize(stripped_sample(sample).duration, 1, 2) %> ms
|
7
|
+
</td>
|
8
|
+
<td>
|
9
|
+
<%= link_to "#{sample.params[:uri]}", :action => :show_sample_summary, :id => sample.sample_id %>
|
10
|
+
</td>
|
11
|
+
<td>
|
12
|
+
<% if sample.profile %>
|
13
|
+
<%= link_to "[Profile]", :action => :show_sample_summary, :id => sample.sample_id %>
|
14
|
+
<% else %>
|
15
|
+
<%= link_to "[Detail]", :action => :show_sample_detail, :id => sample.sample_id %><br/>
|
16
|
+
<%= link_to "[SQL (#{sample.sql_segments.size})]", :action => :show_sample_sql, :id => sample.sample_id %>
|
17
|
+
<% end %>
|
18
|
+
</td>
|
19
|
+
</tr>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<tr style="<%= 'display:none' if indent > 1 %>" child_row_class="<%=segment_child_row_class(segment)%>" onmouseover="mouse_over_row(this)" onmouseout="mouse_out_row(this)" class='<%=segment_row_classes(segment, indent)%>'>
|
2
|
+
|
3
|
+
<td nowrap=true>
|
4
|
+
<div class="segment_indent_level<%=indent%> <%='leaf_segment' if segment.called_segments.empty?%>">
|
5
|
+
<div style="display:inline;">
|
6
|
+
<%= expand_segment_image(segment, indent) %>
|
7
|
+
</div>
|
8
|
+
<%= write_segment_label segment%>
|
9
|
+
<small><%= link_to '?', url_for_metric_doc(segment.metric_name)%></small>
|
10
|
+
</div>
|
11
|
+
</td>
|
12
|
+
|
13
|
+
<td nowrap=true align="right">
|
14
|
+
<%= timestamp(segment) %>
|
15
|
+
</td>
|
16
|
+
<td nowrap=true align="right">
|
17
|
+
<%= with_delimiter(to_ms(segment.duration)) %>
|
18
|
+
</td>
|
19
|
+
<td nowrap=true align="right">
|
20
|
+
<%= colorize(segment.exclusive_duration) %>
|
21
|
+
</td>
|
22
|
+
|
23
|
+
<td nowrap=true>
|
24
|
+
<small>
|
25
|
+
<%= explain_sql_links(segment) if indent > 0 %>
|
26
|
+
</small>
|
27
|
+
</td>
|
28
|
+
</tr>
|
@@ -0,0 +1 @@
|
|
1
|
+
This report is limited to <%= trace_row_display_limit %> rows.
|