blob: 5c76eb3ba50420c14c1f8b25e39adc9793be416d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require 'spec_helper'
describe Gitlab::Metrics::Subscribers::MethodCall do
let(:transaction) { Gitlab::Metrics::Transaction.new }
let(:subscriber) { described_class.new }
let(:event) do
double(:event, duration: 0.2, payload: { module: 'Foo', name: :foo })
end
before do
allow(subscriber).to receive(:current_transaction).and_return(transaction)
allow(Gitlab::Metrics).to receive(:last_relative_application_frame).
and_return(['app/models/foo.rb', 4])
end
describe '#instance_method' do
it 'tracks the execution of an instance method' do
values = { duration: 0.2, file: 'app/models/foo.rb', line: 4 }
expect(transaction).to receive(:add_metric).
with(described_class::SERIES, values, method: 'Foo#foo')
subscriber.instance_method(event)
end
end
describe '#class_method' do
it 'tracks the execution of a class method' do
values = { duration: 0.2, file: 'app/models/foo.rb', line: 4 }
expect(transaction).to receive(:add_metric).
with(described_class::SERIES, values, method: 'Foo.foo')
subscriber.class_method(event)
end
end
end
|