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
b5edb275
Commit
b5edb275
authored
Oct 28, 2021
by
John Hope
Committed by
Douglas Barbosa Alexandre
Oct 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update histogram buckets for Banzai cacheless_render metrics
parent
c228e5bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
11 deletions
+52
-11
lib/banzai/renderer.rb
lib/banzai/renderer.rb
+33
-9
spec/lib/banzai/renderer_spec.rb
spec/lib/banzai/renderer_spec.rb
+18
-0
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+1
-2
No files found.
lib/banzai/renderer.rb
View file @
b5edb275
...
...
@@ -160,16 +160,40 @@ module Banzai
def
self
.
cacheless_render
(
text
,
context
=
{})
return
text
.
to_s
unless
text
.
present?
Gitlab
::
Metrics
.
measure
(
:banzai_cacheless_render
)
do
result
=
render_result
(
text
,
context
)
real_start
=
Gitlab
::
Metrics
::
System
.
monotonic_time
cpu_start
=
Gitlab
::
Metrics
::
System
.
cpu_time
output
=
result
[
:output
]
if
output
.
respond_to?
(
:to_html
)
output
.
to_html
else
output
.
to_s
end
end
result
=
render_result
(
text
,
context
)
output
=
result
[
:output
]
rendered
=
if
output
.
respond_to?
(
:to_html
)
output
.
to_html
else
output
.
to_s
end
cpu_duration_histogram
.
observe
({},
Gitlab
::
Metrics
::
System
.
cpu_time
-
cpu_start
)
real_duration_histogram
.
observe
({},
Gitlab
::
Metrics
::
System
.
monotonic_time
-
real_start
)
rendered
end
def
self
.
real_duration_histogram
Gitlab
::
Metrics
.
histogram
(
:gitlab_banzai_cacheless_render_real_duration_seconds
,
'Duration of Banzai pipeline rendering in real time'
,
{},
[
0.01
,
0.01
,
0.05
,
0.1
,
0.5
,
1
,
2
,
5
,
10.0
,
50
,
100
]
)
end
def
self
.
cpu_duration_histogram
Gitlab
::
Metrics
.
histogram
(
:gitlab_banzai_cacheless_render_cpu_duration_seconds
,
'Duration of Banzai pipeline rendering in cpu time'
,
{},
Gitlab
::
Metrics
::
EXECUTION_MEASUREMENT_BUCKETS
)
end
def
self
.
full_cache_key
(
cache_key
,
pipeline_name
)
...
...
spec/lib/banzai/renderer_spec.rb
View file @
b5edb275
...
...
@@ -84,6 +84,24 @@ RSpec.describe Banzai::Renderer do
end
end
describe
'#cacheless_render'
do
context
'without cache'
do
let
(
:object
)
{
fake_object
(
fresh:
false
)
}
let
(
:histogram
)
{
double
(
'prometheus histogram'
)
}
it
'returns cacheless render field'
do
allow
(
renderer
).
to
receive
(
:render_result
).
and_return
(
output:
'test'
)
allow
(
renderer
).
to
receive
(
:real_duration_histogram
).
and_return
(
histogram
)
allow
(
renderer
).
to
receive
(
:cpu_duration_histogram
).
and_return
(
histogram
)
expect
(
renderer
).
to
receive
(
:render_result
).
with
(
'test'
,
{})
expect
(
histogram
).
to
receive
(
:observe
).
twice
renderer
.
cacheless_render
(
'test'
)
end
end
end
describe
'#post_process'
do
let
(
:context_options
)
{
{}
}
let
(
:html
)
{
'Consequatur aperiam et nesciunt modi aut assumenda quo id. '
}
...
...
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
View file @
b5edb275
...
...
@@ -280,7 +280,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importer do
end
context
'metrics'
do
let
(
:histogram
)
{
double
(
:histogram
)
}
let
(
:histogram
)
{
double
(
:histogram
)
.
as_null_object
}
let
(
:counter
)
{
double
(
'counter'
,
increment:
true
)
}
before
do
...
...
@@ -315,7 +315,6 @@ RSpec.describe Gitlab::BitbucketServerImport::Importer do
)
expect
(
counter
).
to
receive
(
:increment
)
allow
(
histogram
).
to
receive
(
:observe
).
with
({
importer: :bitbucket_server_importer
},
anything
)
subject
.
execute
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