Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect flamegraph_mode in query string #623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mini_profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def call(env)

mode_match_data = action_parameters(env)['flamegraph_mode']

if mode_match_data && [:cpu, :wall, :object, :custom].include?(mode_match_data[1].to_sym)
mode = mode_match_data[1].to_sym
if mode_match_data && [:cpu, :wall, :object, :custom].include?(mode_match_data.to_sym)
mode = mode_match_data.to_sym
else
mode = config.flamegraph_mode
end
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/profiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,13 @@ def self.bar(baz, boo)
ensure
Rack::MiniProfiler.config.enable_advanced_debugging_tools = original_enable_advanced_debugging_tools
end

it 'passes flamegraph_mode parameter to StackProf.run' do
stackprof = double
stub_const('StackProf', stackprof)
expect(stackprof).to receive(:respond_to?).with(:run).and_return(true)
expect(stackprof).to receive(:run).with(hash_including(mode: :cpu)).and_return({})
profiler.call({ "PATH_INFO" => "/", "QUERY_STRING" => "pp=flamegraph&flamegraph_mode=cpu" })
end
end
end