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
2cd5861f
Commit
2cd5861f
authored
May 06, 2021
by
Gary Holtz
Committed by
Max Woolf
May 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial highlight timeout metrics behind a feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent
a1eb1f4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
0 deletions
+57
-0
config/feature_flags/development/track_highlight_timeouts.yml
...ig/feature_flags/development/track_highlight_timeouts.yml
+8
-0
lib/gitlab/highlight.rb
lib/gitlab/highlight.rb
+15
-0
spec/lib/gitlab/highlight_spec.rb
spec/lib/gitlab/highlight_spec.rb
+34
-0
No files found.
config/feature_flags/development/track_highlight_timeouts.yml
0 → 100644
View file @
2cd5861f
---
name
:
track_highlight_timeouts
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60956
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/329909
milestone
:
'
13.12'
type
:
development
group
:
group::code review
default_enabled
:
false
lib/gitlab/highlight.rb
View file @
2cd5861f
...
...
@@ -64,6 +64,8 @@ module Gitlab
tokens
=
lexer
.
lex
(
text
,
continue:
continue
)
Timeout
.
timeout
(
timeout_time
)
{
@formatter
.
format
(
tokens
,
context
.
merge
(
tag:
tag
)).
html_safe
}
rescue
Timeout
::
Error
=>
e
add_highlight_timeout_metric
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
e
)
highlight_plain
(
text
)
rescue
StandardError
...
...
@@ -81,5 +83,18 @@ module Gitlab
def
maximum_text_highlight_size
Gitlab
.
config
.
extra
[
'maximum_text_highlight_size_kilobytes'
]
end
def
add_highlight_timeout_metric
return
unless
Feature
.
enabled?
(
:track_highlight_timeouts
)
highlight_timeout
.
increment
(
source:
Gitlab
::
Runtime
.
sidekiq?
?
"background"
:
"foreground"
)
end
def
highlight_timeout
@highlight_timeout
||=
Gitlab
::
Metrics
.
counter
(
:highlight_timeout
,
'Counts the times highlights have timed out'
)
end
end
end
spec/lib/gitlab/highlight_spec.rb
View file @
2cd5861f
...
...
@@ -133,5 +133,39 @@ RSpec.describe Gitlab::Highlight do
subject
.
highlight
(
"Content"
)
end
end
describe
'highlight timeouts'
do
context
'when there is a timeout error while highlighting'
do
let
(
:result
)
{
described_class
.
highlight
(
file_name
,
content
)
}
before
do
allow
(
Timeout
).
to
receive
(
:timeout
).
twice
.
and_raise
(
Timeout
::
Error
)
# This is done twice because it's rescued first and then
# calls the original exception
end
it
"increments the foreground counter if it's in the foreground"
do
expect
{
result
}
.
to
raise_error
(
Timeout
::
Error
)
.
and
change
{
highlight_timeout_total
(
'foreground'
)
}.
by
(
1
)
.
and
not_change
{
highlight_timeout_total
(
'background'
)
}
end
it
"increments the background counter if it's in the background"
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:sidekiq?
).
and_return
(
true
)
expect
{
result
}
.
to
raise_error
(
Timeout
::
Error
)
.
and
change
{
highlight_timeout_total
(
'background'
)
}.
by
(
1
)
.
and
not_change
{
highlight_timeout_total
(
'foreground'
)
}
end
end
end
end
def
highlight_timeout_total
(
source
)
Gitlab
::
Metrics
.
counter
(
:highlight_timeout
,
'Counts the times highlights have timed out'
)
.
get
(
source:
source
)
end
end
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