BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
935f9131
Unverified
Commit
935f9131
authored
Apr 11, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instrument Banzai code
parent
15cbbd09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
metrics.rb
config/initializers/metrics.rb
+23
-0
renderer.rb
lib/banzai/renderer.rb
+12
-8
No files found.
config/initializers/metrics.rb
View file @
935f9131
...
...
@@ -75,6 +75,29 @@ if Gitlab::Metrics.enabled?
config
.
instrument_methods
(
const
)
config
.
instrument_instance_methods
(
const
)
end
# Instruments all Banzai filters
Dir
[
Rails
.
root
.
join
(
'lib'
,
'banzai'
,
'filter'
,
'*.rb'
)].
each
do
|
file
|
klass
=
File
.
basename
(
file
,
File
.
extname
(
file
)).
camelize
const
=
Banzai
::
Filter
.
const_get
(
klass
)
config
.
instrument_methods
(
const
)
config
.
instrument_instance_methods
(
const
)
end
config
.
instrument_methods
(
Banzai
::
ReferenceExtractor
)
config
.
instrument_instance_methods
(
Banzai
::
ReferenceExtractor
)
config
.
instrument_methods
(
Banzai
::
Renderer
)
config
.
instrument_methods
(
Banzai
::
Querying
)
[
Issuable
,
Mentionable
,
Participable
].
each
do
|
klass
|
config
.
instrument_instance_methods
(
klass
)
config
.
instrument_instance_methods
(
klass
::
ClassMethods
)
end
config
.
instrument_methods
(
Gitlab
::
ReferenceExtractor
)
config
.
instrument_instance_methods
(
Gitlab
::
ReferenceExtractor
)
end
GC
::
Profiler
.
enable
...
...
lib/banzai/renderer.rb
View file @
935f9131
...
...
@@ -19,8 +19,10 @@ module Banzai
cache_key
=
full_cache_key
(
cache_key
,
context
[
:pipeline
])
if
cache_key
Rails
.
cache
.
fetch
(
cache_key
)
do
cacheless_render
(
text
,
context
)
Gitlab
::
Metrics
.
measure
(
:banzai_cached_render
)
do
Rails
.
cache
.
fetch
(
cache_key
)
do
cacheless_render
(
text
,
context
)
end
end
else
cacheless_render
(
text
,
context
)
...
...
@@ -64,13 +66,15 @@ module Banzai
private
def
self
.
cacheless_render
(
text
,
context
=
{})
result
=
render_result
(
text
,
context
)
Gitlab
::
Metrics
.
measure
(
:banzai_cacheless_render
)
do
result
=
render_result
(
text
,
context
)
output
=
result
[
:output
]
if
output
.
respond_to?
(
:to_html
)
output
.
to_html
else
output
.
to_s
output
=
result
[
:output
]
if
output
.
respond_to?
(
:to_html
)
output
.
to_html
else
output
.
to_s
end
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