summaryrefslogtreecommitdiff
path: root/lib/banzai/renderer.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-28 18:14:18 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-28 18:14:18 +0000
commitb267f3a3acf3fe4cf2a9bb254d7abeb3b2823b21 (patch)
treea1c30c9a460a1c990311d47aae72d00368e1a1c1 /lib/banzai/renderer.rb
parent03cd4f8da4f848c7dfd0c0b88b4c095f69e56bb0 (diff)
downloadgitlab-ce-b267f3a3acf3fe4cf2a9bb254d7abeb3b2823b21.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/banzai/renderer.rb')
-rw-r--r--lib/banzai/renderer.rb42
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb
index fbbd6135959..b16af78841a 100644
--- a/lib/banzai/renderer.rb
+++ b/lib/banzai/renderer.rb
@@ -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)