From: "byroot (Jean Boussier)" <noreply@...> Date: 2022-11-11T00:23:52+00:00 Subject: [ruby-core:110701] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name Issue #19117 has been updated by byroot (Jean Boussier). @kjtsanaktsidis I understand what you are trying to do, but I think it's orthogonal to the current issue. I'll quickly answer here, but it's probably best to discuss that in your issue instead. I don't think `object_id` will cut it. They are incremental and lazy, which means they're unlikely to match across processes. (@Eregon see https://www.youtube.com/watch?v=xoGJPtNp074 for what they are trying to do, basically they want stable identifier across a large fleet of server) The only reasonable stable identification data I can think of (and that would be nice for other reasons) would be to display the source location, like for procs: ```ruby p ->() {} p Class.new ``` ``` #<Proc:0x000000010f87d970@/tmp/foo.rb:1 (lambda)> #<Class:0x000000010f87d740> ``` So that it would look like: ``` #<Proc:0x000000010f87d970@/tmp/foo.rb:1 (lambda)> #<Class:0x000000010f87d740@/tmp/foo.rb:2> ``` The problem with this is that it's not an information we have store right now, so it would be an overhead. So I really encourage you to open a dedicated issue on what a better default `Module#inspect` method could be. ---------------------------------------- Feature #19117: Include the method owner in backtraces, not just the method name https://bugs.ruby-lang.org/issues/19117#change-100043 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal ---------------------------------------- ``` module Foo class Bar def inspect 1 + '1' end end end p Foo::Bar.new ``` This code produce the following backtrace: ``` /tmp/foo.rb:4:in `+': String can't be coerced into Integer (TypeError) from /tmp/foo.rb:4:in `inspect' from /tmp/foo.rb:9:in `p' from /tmp/foo.rb:9:in `<main>' ``` This works, but on large codebases and large backtraces the method name isn't always all that revealing, most of the time you need to open many of the locations listed in the backtrace to really understand what is going on. I propose that we also include the owner name: ``` /tmp/foo.rb:4:in `Integer#+': String can't be coerced into Integer (TypeError) from /tmp/foo.rb:4:in `Foo::Bar#inspect' from /tmp/foo.rb:9:in `Kernel#p' from /tmp/foo.rb:9:in `<main>' ``` I believe that in many case it would allow to much better understand the backtrace without having to jump back and forth between it and the source code. This is inspired by @ivoanjo 's `backtracie` gem: https://github.com/ivoanjo/backtracie -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>