Commit f43f3b89 authored by Yorick Peterse's avatar Yorick Peterse

Added Instrumentation.configure

This makes it easier to instrument multiple modules without having to
type the full namespace over and over again.
parent 5dbcb635
...@@ -11,6 +11,10 @@ module Gitlab ...@@ -11,6 +11,10 @@ module Gitlab
module Instrumentation module Instrumentation
SERIES = 'method_calls' SERIES = 'method_calls'
def self.configure
yield self
end
# Instruments a class method. # Instruments a class method.
# #
# mod - The module to instrument as a Module/Class. # mod - The module to instrument as a Module/Class.
......
...@@ -17,12 +17,20 @@ describe Gitlab::Metrics::Instrumentation do ...@@ -17,12 +17,20 @@ describe Gitlab::Metrics::Instrumentation do
allow(@dummy).to receive(:name).and_return('Dummy') allow(@dummy).to receive(:name).and_return('Dummy')
end 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 '.instrument_method' do
describe 'with metrics enabled' do describe 'with metrics enabled' do
before do before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true) allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
Gitlab::Metrics::Instrumentation.instrument_method(@dummy, :foo) described_class.instrument_method(@dummy, :foo)
end end
it 'renames the original method' do it 'renames the original method' do
......
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