Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f7218671
Commit
f7218671
authored
May 12, 2021
by
Ethan Urie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add histogram and track latency
Added spec to ensure the latency was recorded.
parent
fcb3386b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
app/services/spam/spam_verdict_service.rb
app/services/spam/spam_verdict_service.rb
+6
-0
spec/services/spam/spam_verdict_service_spec.rb
spec/services/spam/spam_verdict_service_spec.rb
+13
-0
No files found.
app/services/spam/spam_verdict_service.rb
View file @
f7218671
...
@@ -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
spec/services/spam/spam_verdict_service_spec.rb
View file @
f7218671
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment