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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
7998725e
Commit
7998725e
authored
Apr 11, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'banzai-metrics' into 'master'
Instrument Banzai code See merge request !3659
parents
8b7ce2ad
935f9131
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
config/initializers/metrics.rb
config/initializers/metrics.rb
+23
-0
lib/banzai/renderer.rb
lib/banzai/renderer.rb
+12
-8
No files found.
config/initializers/metrics.rb
View file @
7998725e
...
@@ -75,6 +75,29 @@ if Gitlab::Metrics.enabled?
...
@@ -75,6 +75,29 @@ if Gitlab::Metrics.enabled?
config
.
instrument_methods
(
const
)
config
.
instrument_methods
(
const
)
config
.
instrument_instance_methods
(
const
)
config
.
instrument_instance_methods
(
const
)
end
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
end
GC
::
Profiler
.
enable
GC
::
Profiler
.
enable
...
...
lib/banzai/renderer.rb
View file @
7998725e
...
@@ -19,9 +19,11 @@ module Banzai
...
@@ -19,9 +19,11 @@ module Banzai
cache_key
=
full_cache_key
(
cache_key
,
context
[
:pipeline
])
cache_key
=
full_cache_key
(
cache_key
,
context
[
:pipeline
])
if
cache_key
if
cache_key
Gitlab
::
Metrics
.
measure
(
:banzai_cached_render
)
do
Rails
.
cache
.
fetch
(
cache_key
)
do
Rails
.
cache
.
fetch
(
cache_key
)
do
cacheless_render
(
text
,
context
)
cacheless_render
(
text
,
context
)
end
end
end
else
else
cacheless_render
(
text
,
context
)
cacheless_render
(
text
,
context
)
end
end
...
@@ -64,6 +66,7 @@ module Banzai
...
@@ -64,6 +66,7 @@ module Banzai
private
private
def
self
.
cacheless_render
(
text
,
context
=
{})
def
self
.
cacheless_render
(
text
,
context
=
{})
Gitlab
::
Metrics
.
measure
(
:banzai_cacheless_render
)
do
result
=
render_result
(
text
,
context
)
result
=
render_result
(
text
,
context
)
output
=
result
[
:output
]
output
=
result
[
:output
]
...
@@ -73,6 +76,7 @@ module Banzai
...
@@ -73,6 +76,7 @@ module Banzai
output
.
to_s
output
.
to_s
end
end
end
end
end
def
self
.
full_cache_key
(
cache_key
,
pipeline_name
)
def
self
.
full_cache_key
(
cache_key
,
pipeline_name
)
return
unless
cache_key
return
unless
cache_key
...
...
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