mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-17 16:46:06 +10:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user