2018-07-23 09:13:11 -04:00
|
|
|
module StubMetrics
|
|
|
|
def authentication_metrics
|
|
|
|
Gitlab::Auth::Activity
|
|
|
|
end
|
|
|
|
|
|
|
|
def stub_authentication_activity_metrics(debug: false)
|
|
|
|
authentication_metrics.each_counter do |name, metric, description|
|
2018-07-31 03:24:19 -04:00
|
|
|
allow(authentication_metrics).to receive(name)
|
|
|
|
.and_return(double("#{metric} - #{description}"))
|
2018-07-23 11:20:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
debug_authentication_activity_metrics if debug
|
|
|
|
end
|
|
|
|
|
|
|
|
def debug_authentication_activity_metrics
|
|
|
|
authentication_metrics.tap do |metrics|
|
|
|
|
metrics.each_counter do |name, metric|
|
|
|
|
"#{name}_increment!".tap do |incrementer|
|
|
|
|
allow(metrics).to receive(incrementer).and_wrap_original do |method|
|
|
|
|
puts "Authentication activity metric incremented: #{name}"
|
|
|
|
method.call
|
|
|
|
end
|
|
|
|
end
|
2018-07-23 09:13:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|