diff --git a/meta_request/lib/meta_request/app_notifications.rb b/meta_request/lib/meta_request/app_notifications.rb index 2eb0f49..2769917 100644 --- a/meta_request/lib/meta_request/app_notifications.rb +++ b/meta_request/lib/meta_request/app_notifications.rb @@ -49,7 +49,9 @@ class AppNotifications VIEW_BLOCK = proc { |*args| name, start, ending, transaction_id, payload = args - payload[:identifier] = MetaRequest::Utils.sub_source_path(payload[:identifier]) + identifier = payload[:identifier] + payload[:identifier] = MetaRequest::Utils.sub_source_path(identifier) + payload[:relative_identifier] = MetaRequest::Utils.relative_path(identifier) Event.new(name, start, ending, transaction_id, payload) } diff --git a/meta_request/lib/meta_request/utils.rb b/meta_request/lib/meta_request/utils.rb index 2f4bd8f..41d3897 100644 --- a/meta_request/lib/meta_request/utils.rb +++ b/meta_request/lib/meta_request/utils.rb @@ -12,6 +12,7 @@ def dev_callsite(caller) { filename: sub_source_path(filename), + relative_filename: relative_path(filename), line: line.to_i, method: method } @@ -22,7 +23,11 @@ def sub_source_path(path) source_path = MetaRequest.config.source_path return path if rails_root == source_path - path.sub(rails_root, source_path) + path.sub(%r{\A#{rails_root}}, source_path) + end + + def relative_path(path) + path.sub(%r{\A#{MetaRequest.rails_root}/?}, '') end end end diff --git a/meta_request/spec/meta_request/utils_spec.rb b/meta_request/spec/meta_request/utils_spec.rb index 48077e7..ab39431 100644 --- a/meta_request/spec/meta_request/utils_spec.rb +++ b/meta_request/spec/meta_request/utils_spec.rb @@ -15,7 +15,8 @@ ] expect(MetaRequest::Utils.dev_callsite(stacktrace)).to eq( - filename: filename, line: line, method: method + filename: filename, relative_filename: 'test_file.rb', + line: line, method: method ) end @@ -39,7 +40,8 @@ ] expect(MetaRequest::Utils.dev_callsite(stacktrace)).to eq( - filename: '/Users/foo/bar/test_file.rb', line: line, method: method + filename: '/Users/foo/bar/test_file.rb', + relative_filename: 'test_file.rb', line: line, method: method ) # revert configuration diff --git a/rails_panel/panel.html b/rails_panel/panel.html index 60253bc..eb5e47d 100644 --- a/rails_panel/panel.html +++ b/rails_panel/panel.html @@ -160,7 +160,10 @@ - {{sql.payload.filename | normalizePath}}:{{sql.payload.line}} + + {{ sql.payload.filename | normalizePath}}:{{sql.payload.line}} + {{ sql.payload.relative_filename}}:{{sql.payload.line}} + {{sql.payload.name}} @@ -185,7 +188,10 @@ - {{view.payload.identifier | normalizePath}} + + {{view.payload.identifier | normalizePath}} + {{view.payload.relative_identifier}} + within {{view.payload.layout}} {{view.duration | number:0}} ms @@ -209,7 +215,10 @@ - {{cache.payload.filename | normalizePath}}:{{cache.payload.line}} + + {{cache.payload.filename | normalizePath}}:{{cache.payload.line}} + {{cache.payload.relative_filename}}:{{cache.payload.line}} + {{cache.payload.type}} @@ -231,7 +240,10 @@ - {{log.payload.filename | normalizePath}}:{{log.payload.line}} + + {{log.payload.filename | normalizePath}}:{{log.payload.line}} + {{log.payload.relative_filename}}:{{log.payload.line}} +