Added Instrumentation.configure

This makes it easier to instrument multiple modules without having to
type the full namespace over and over again.
This commit is contained in:
Yorick Peterse
2015-12-17 17:25:48 +01:00
parent 5dbcb635a1
commit f43f3b89a6
2 changed files with 13 additions and 1 deletions
+4
View File
@@ -11,6 +11,10 @@ module Gitlab
module Instrumentation
SERIES = 'method_calls'
def self.configure
yield self
end
# Instruments a class method.
#
# mod - The module to instrument as a Module/Class.
@@ -17,12 +17,20 @@ describe Gitlab::Metrics::Instrumentation do
allow(@dummy).to receive(:name).and_return('Dummy')
end
describe '.configure' do
it 'yields self' do
described_class.configure do |c|
expect(c).to eq(described_class)
end
end
end
describe '.instrument_method' do
describe 'with metrics enabled' do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
Gitlab::Metrics::Instrumentation.instrument_method(@dummy, :foo)
described_class.instrument_method(@dummy, :foo)
end
it 'renames the original method' do