Commit 7549102b authored by Yorick Peterse's avatar Yorick Peterse

Store SQL/view timings in milliseconds

Transaction timings are also already stored in milliseconds, this keeps
things consistent.
parent 8b39b8cd
......@@ -19,7 +19,7 @@ module Gitlab
values = values_for(event)
tags = tags_for(event)
current_transaction.increment(:view_duration, event.duration)
current_transaction.increment(:view_duration, duration(event))
current_transaction.add_metric(SERIES, values, tags)
end
......@@ -28,7 +28,7 @@ module Gitlab
end
def values_for(event)
{ duration: event.duration }
{ duration: duration(event) }
end
def tags_for(event)
......@@ -48,6 +48,10 @@ module Gitlab
def current_transaction
Transaction.current
end
def duration(event)
event.duration * 1000.0
end
end
end
end
......
......@@ -8,7 +8,7 @@ module Gitlab
def sql(event)
return unless current_transaction
current_transaction.increment(:sql_duration, event.duration)
current_transaction.increment(:sql_duration, duration(event))
end
private
......@@ -16,6 +16,10 @@ module Gitlab
def current_transaction
Transaction.current
end
def duration(event)
event.duration * 1000.0
end
end
end
end
......
......@@ -21,7 +21,7 @@ describe Gitlab::Metrics::Subscribers::ActionView do
describe '#render_template' do
it 'tracks rendering of a template' do
values = { duration: 2.1 }
values = { duration: 2100 }
tags = {
view: 'app/views/x.html.haml',
file: 'app/views/x.html.haml',
......@@ -29,7 +29,7 @@ describe Gitlab::Metrics::Subscribers::ActionView do
}
expect(transaction).to receive(:increment).
with(:view_duration, 2.1)
with(:view_duration, 2100)
expect(transaction).to receive(:add_metric).
with(described_class::SERIES, values, tags)
......
......@@ -26,7 +26,7 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
and_return(transaction)
expect(transaction).to receive(:increment).
with(:sql_duration, 0.2)
with(:sql_duration, 200)
subscriber.sql(event)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment