Commit f7218671 authored by Ethan Urie's avatar Ethan Urie

Add histogram and track latency

Added spec to ensure the latency was recorded.
parent fcb3386b
......@@ -21,6 +21,8 @@ module Spam
spamcheck_result, spamcheck_attribs = spamcheck_verdict
end
histogram.observe( {}, external_spam_check_round_trip_time )
# assign result to a var and log it before reassigning to nil when monitorMode is true
original_spamcheck_result = spamcheck_result
......@@ -95,5 +97,9 @@ module Spam
def logger
@logger ||= Gitlab::AppJsonLogger.build
end
def histogram
@histogram ||= Gitlab::Metrics.histogram(:spamcheck_latency_seconds, 'Latency to the Spamcheck service')
end
end
end
......@@ -114,6 +114,19 @@ RSpec.describe Spam::SpamVerdictService do
end
end
end
context 'records metrics' do
let(:histogram) { double('histogram') }
before do
expect(Gitlab::Metrics).to receive(:histogram).with(:spamcheck_latency_seconds, anything).and_return(histogram)
end
it 'records latency' do
expect(histogram).to receive(:observe)
subject
end
end
end
describe '#akismet_verdict' 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