Open semaperepelitsa opened 3 years ago
Patch:
module MiniProfilerExt
# The default label is "Object#method" instead of "Object method"
def profile_method(klass, method, type = :profile, &blk)
label = "#{klass.name}##{method}" # "Class#method"
blk ||= proc{ label }
super(klass, method, type, &blk)
end
# The default label is "Object.method" instead of "#<Class:Object> method"
# https://github.com/MiniProfiler/rack-mini-profiler/issues/483
def profile_singleton_method(klass, method, type = :profile, &blk)
label = "#{klass.name}.#{method}"
blk ||= proc{ label }
profile_method(klass.singleton_class, method, type, &blk)
end
end
Rack::MiniProfiler.extend(MiniProfilerExt)
@semaperepelitsa if you put this into a PR, it may be easier to review and get this great patch into the code.
(I am not part of the core of this project, so that is just a suggestion from a bystander)
Example:
It uses this label:
#<Class:SomeModule> lookup
But the label is not HTML-escaped, so it ends up looking like this:
Besides escaping, it could also generate a better label, e.g. "SomeModule.lookup" for class/module methods, and "SomeClass#lookup" for instance methods.