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
19484c77
Commit
19484c77
authored
Jun 08, 2021
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a new metric for total highlighting attempts
parent
79d47ab2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
lib/gitlab/highlight.rb
lib/gitlab/highlight.rb
+17
-0
spec/lib/gitlab/highlight_spec.rb
spec/lib/gitlab/highlight_spec.rb
+14
-0
No files found.
lib/gitlab/highlight.rb
View file @
19484c77
...
...
@@ -32,8 +32,12 @@ module Gitlab
def
highlight
(
text
,
continue:
false
,
plain:
false
,
context:
{})
@context
=
context
add_highlight_attempt_metric
plain
||=
self
.
class
.
too_large?
(
text
.
length
)
highlight_timeout
.
increment
(
source:
Gitlab
::
Runtime
.
sidekiq?
?
"background"
:
"foreground"
)
highlighted_text
=
highlight_text
(
text
,
continue:
continue
,
plain:
plain
)
highlighted_text
=
link_dependencies
(
text
,
highlighted_text
)
if
blob_name
highlighted_text
...
...
@@ -90,12 +94,25 @@ module Gitlab
Gitlab
::
DependencyLinker
.
link
(
blob_name
,
text
,
highlighted_text
)
end
def
add_highlight_attempt_metric
return
unless
Feature
.
enabled?
(
:track_highlight_timeouts
)
highlighting_attempt
.
increment
(
source:
@language
||
"undefined"
)
end
def
add_highlight_timeout_metric
return
unless
Feature
.
enabled?
(
:track_highlight_timeouts
)
highlight_timeout
.
increment
(
source:
Gitlab
::
Runtime
.
sidekiq?
?
"background"
:
"foreground"
)
end
def
highlighting_attempt
@highlight_timeout
||=
Gitlab
::
Metrics
.
counter
(
:file_highlighting_attempt
,
'Counts the times highlighting has been attempted on a file'
)
end
def
highlight_timeout
@highlight_timeout
||=
Gitlab
::
Metrics
.
counter
(
:highlight_timeout
,
...
...
spec/lib/gitlab/highlight_spec.rb
View file @
19484c77
...
...
@@ -143,6 +143,14 @@ RSpec.describe Gitlab::Highlight do
end
describe
'highlight timeouts'
do
context
'when there is an attempt'
do
let
(
:result
)
{
described_class
.
highlight
(
file_name
,
content
)
}
it
"increments the foreground counter if it's in the foreground"
do
expect
{
result
}.
to
change
{
highlight_attempt_total
(
"undefined"
)
}
end
end
context
'when there is a timeout error while highlighting'
do
let
(
:result
)
{
described_class
.
highlight
(
file_name
,
content
)
}
...
...
@@ -177,6 +185,12 @@ RSpec.describe Gitlab::Highlight do
.
get
(
source:
source
)
end
def
highlight_attempt_total
(
source
)
Gitlab
::
Metrics
.
counter
(
:file_highlighting_attempt
,
'Counts the times highlighting has been attempted on a file'
)
.
get
(
source:
source
)
end
def
over_highlight_size_limit
(
source
)
Gitlab
::
Metrics
.
counter
(
:over_highlight_size_limit
,
...
...
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