summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-07-01 11:16:48 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-07-01 12:34:28 +0200
commit521454831ee9e899e046ed288596865df55e8832 (patch)
treef3a4ebba6efe3b8020668c42b78589c1719554d5
parentab81ea1e8177742a0dfed2c7cf922bb03a8b6c51 (diff)
downloadgitlab-ce-18592-syntaxhighlighter-slow.tar.gz
Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab18592-syntaxhighlighter-slow
-rw-r--r--CHANGELOG1
-rw-r--r--config/initializers/metrics.rb3
-rw-r--r--lib/banzai/filter/syntax_highlight_filter.rb9
3 files changed, 11 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 4b754c2aba3..25611f173a2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@ v 8.10.0 (unreleased)
- Better caching of git calls on ProjectsController#show.
- Add API endpoint for a group issues !4520 (mahcsig)
- Add Bugzilla integration !4930 (iamtjg)
+ - Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
- Add basic system information like memory and disk usage to the admin panel
diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb
index 75f89d524e7..44601f2b2bd 100644
--- a/config/initializers/metrics.rb
+++ b/config/initializers/metrics.rb
@@ -132,6 +132,9 @@ if Gitlab::Metrics.enabled?
config.instrument_instance_methods(API::Helpers)
config.instrument_instance_methods(RepositoryCheck::SingleRepositoryWorker)
+
+ config.instrument_instance_methods(Rouge::Plugins::Redcarpet)
+ config.instrument_instance_methods(Rouge::Formatters::HTMLGitlab)
end
GC::Profiler.enable
diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb
index 62a79c62e20..536b478979f 100644
--- a/lib/banzai/filter/syntax_highlight_filter.rb
+++ b/lib/banzai/filter/syntax_highlight_filter.rb
@@ -27,12 +27,17 @@ module Banzai
highlighted = "<pre>#{code}</pre>"
end
- # Replace the parent `pre` element with the entire highlighted block
- node.parent.replace(highlighted)
+ # Extracted to a method to measure it
+ replace_parent_pre_element(node, highlighted)
end
private
+ def replace_parent_pre_element(node, highlighted)
+ # Replace the parent `pre` element with the entire highlighted block
+ node.parent.replace(highlighted)
+ end
+
# Override Rouge::Plugins::Redcarpet#rouge_formatter
def rouge_formatter(lexer)
Rouge::Formatters::HTMLGitlab.new(