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 ...@@ -21,6 +21,8 @@ module Spam
spamcheck_result, spamcheck_attribs = spamcheck_verdict spamcheck_result, spamcheck_attribs = spamcheck_verdict
end 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 # assign result to a var and log it before reassigning to nil when monitorMode is true
original_spamcheck_result = spamcheck_result original_spamcheck_result = spamcheck_result
...@@ -95,5 +97,9 @@ module Spam ...@@ -95,5 +97,9 @@ module Spam
def logger def logger
@logger ||= Gitlab::AppJsonLogger.build @logger ||= Gitlab::AppJsonLogger.build
end end
def histogram
@histogram ||= Gitlab::Metrics.histogram(:spamcheck_latency_seconds, 'Latency to the Spamcheck service')
end
end end
end end
...@@ -114,6 +114,19 @@ RSpec.describe Spam::SpamVerdictService do ...@@ -114,6 +114,19 @@ RSpec.describe Spam::SpamVerdictService do
end end
end 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 end
describe '#akismet_verdict' do 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