diff options
Diffstat (limited to 'lib/gitlab/middleware/speedscope.rb')
-rw-r--r-- | lib/gitlab/middleware/speedscope.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/gitlab/middleware/speedscope.rb b/lib/gitlab/middleware/speedscope.rb index 74f334d9ab3..6992ac9b720 100644 --- a/lib/gitlab/middleware/speedscope.rb +++ b/lib/gitlab/middleware/speedscope.rb @@ -19,11 +19,12 @@ module Gitlab require 'stackprof' begin + mode = stackprof_mode(request) flamegraph = ::StackProf.run( - mode: :wall, + mode: mode, raw: true, aggregate: false, - interval: ::Gitlab::StackProf::DEFAULT_INTERVAL_US + interval: ::Gitlab::StackProf.interval(mode) ) do _, _, body = @app.call(env) end @@ -64,7 +65,7 @@ module Gitlab var iframe = document.createElement('IFRAME'); iframe.setAttribute('id', 'speedscope-iframe'); document.body.appendChild(iframe); - var iframeUrl = '#{speedscope_path}#profileURL=' + objUrl + '&title=' + 'Flamegraph for #{CGI.escape(path)}'; + var iframeUrl = '#{speedscope_path}#profileURL=' + objUrl + '&title=' + 'Flamegraph for #{CGI.escape(path)} in #{stackprof_mode(request)} mode'; iframe.setAttribute('src', iframeUrl); </script> </body> @@ -73,6 +74,17 @@ module Gitlab [200, headers, [html]] end + + def stackprof_mode(request) + case request.params['stackprof_mode']&.to_sym + when :cpu + :cpu + when :object + :object + else + :wall + end + end end end end |