Skip to content

Commit 355c341

Browse files
author
Yorick Peterse
committed
Stop tracking call stacks for instrumented views
Where a vew is called from doesn't matter as much. We already know what action they belong to and this is more than enough information. By removing the file/line number from the list of tags we should also be able to reduce the number of series stored in InfluxDB.
1 parent 587f850 commit 355c341

File tree

4 files changed

+2
-40
lines changed

4 files changed

+2
-40
lines changed

lib/gitlab/metrics.rb

-14
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,6 @@ def self.pool
3636
@pool
3737
end
3838

39-
# Returns a relative path and line number based on the last application call
40-
# frame.
41-
def self.last_relative_application_frame
42-
frame = caller_locations.find do |l|
43-
l.path.start_with?(RAILS_ROOT) && !l.path.start_with?(METRICS_ROOT)
44-
end
45-
46-
if frame
47-
return frame.path.sub(PATH_REGEX, ''), frame.lineno
48-
else
49-
return nil, nil
50-
end
51-
end
52-
5339
def self.submit_metrics(metrics)
5440
prepared = prepare_metrics(metrics)
5541

lib/gitlab/metrics/subscribers/action_view.rb

+1-9
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,8 @@ def values_for(event)
3333

3434
def tags_for(event)
3535
path = relative_path(event.payload[:identifier])
36-
tags = { view: path }
3736

38-
file, line = Metrics.last_relative_application_frame
39-
40-
if file and line
41-
tags[:file] = file
42-
tags[:line] = line
43-
end
44-
45-
tags
37+
{ view: path }
4638
end
4739

4840
def current_transaction

spec/lib/gitlab/metrics/subscribers/action_view_spec.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,12 @@
1414

1515
before do
1616
allow(subscriber).to receive(:current_transaction).and_return(transaction)
17-
18-
allow(Gitlab::Metrics).to receive(:last_relative_application_frame).
19-
and_return(['app/views/x.html.haml', 4])
2017
end
2118

2219
describe '#render_template' do
2320
it 'tracks rendering of a template' do
2421
values = { duration: 2.1 }
25-
tags = {
26-
view: 'app/views/x.html.haml',
27-
file: 'app/views/x.html.haml',
28-
line: 4
29-
}
22+
tags = { view: 'app/views/x.html.haml' }
3023

3124
expect(transaction).to receive(:increment).
3225
with(:view_duration, 2.1)

spec/lib/gitlab/metrics_spec.rb

-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
end
1414
end
1515

16-
describe '.last_relative_application_frame' do
17-
it 'returns an Array containing a file path and line number' do
18-
file, line = described_class.last_relative_application_frame
19-
20-
expect(line).to eq(__LINE__ - 2)
21-
expect(file).to eq('spec/lib/gitlab/metrics_spec.rb')
22-
end
23-
end
24-
2516
describe '#submit_metrics' do
2617
it 'prepares and writes the metrics to InfluxDB' do
2718
connection = double(:connection)

0 commit comments

Comments
 (0)