ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "byroot (Jean Boussier)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110701] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name
Date: Fri, 11 Nov 2022 00:23:52 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-100043.20221111002352.7941@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19117.20221110121311.7941@ruby-lang.org

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/

  parent reply	other threads:[~2022-11-11  0:24 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 12:13 [ruby-core:110683] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name byroot (Jean Boussier)
2022-11-10 12:28 ` [ruby-core:110685] " zverok (Victor Shepelev)
2022-11-10 13:08 ` [ruby-core:110686] " Eregon (Benoit Daloze)
2022-11-10 13:11 ` [ruby-core:110687] " Eregon (Benoit Daloze)
2022-11-10 13:29 ` [ruby-core:110688] " byroot (Jean Boussier)
2022-11-10 13:50 ` [ruby-core:110691] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-10 16:41 ` [ruby-core:110696] " Eregon (Benoit Daloze)
2022-11-11  0:23 ` byroot (Jean Boussier) [this message]
2022-11-11 10:01 ` [ruby-core:110702] " Eregon (Benoit Daloze)
2022-11-11 23:37 ` [ruby-core:110712] " byroot (Jean Boussier)
2022-11-12  2:08 ` [ruby-core:110717] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-12  2:24 ` [ruby-core:110719] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-12  3:30 ` [ruby-core:110720] " byroot (Jean Boussier)
2022-11-12 12:24 ` [ruby-core:110724] " Eregon (Benoit Daloze)
2022-11-14  8:03 ` [ruby-core:110745] " mame (Yusuke Endoh)
2022-11-16 16:20 ` [ruby-core:110778] " ivoanjo (Ivo Anjo)
2022-11-16 16:25 ` [ruby-core:110779] " Dan0042 (Daniel DeLorme)
2022-11-16 16:40 ` [ruby-core:110780] " byroot (Jean Boussier)
2022-11-16 16:57 ` [ruby-core:110782] " Eregon (Benoit Daloze)
2022-11-16 17:01 ` [ruby-core:110783] " Eregon (Benoit Daloze)
2022-11-16 18:32 ` [ruby-core:110784] " Dan0042 (Daniel DeLorme)
2022-12-02  2:33 ` [ruby-core:111140] " mame (Yusuke Endoh)
2023-11-30  7:01 ` [ruby-core:115539] " mame (Yusuke Endoh) via ruby-core
2023-11-30  7:27 ` [ruby-core:115541] " byroot (Jean Boussier) via ruby-core
2023-11-30 12:32 ` [ruby-core:115546] " Eregon (Benoit Daloze) via ruby-core
2024-01-19  5:39 ` [ruby-core:116312] " mame (Yusuke Endoh) via ruby-core
2024-01-19  9:11 ` [ruby-core:116320] " byroot (Jean Boussier) via ruby-core
2024-01-19  9:37 ` [ruby-core:116321] " byroot (Jean Boussier) via ruby-core
2024-01-19 15:02 ` [ruby-core:116334] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 15:25 ` [ruby-core:116335] " byroot (Jean Boussier) via ruby-core
2024-01-19 15:36 ` [ruby-core:116337] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 15:42 ` [ruby-core:116338] " byroot (Jean Boussier) via ruby-core
2024-01-19 19:38 ` [ruby-core:116339] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 19:48 ` [ruby-core:116340] " byroot (Jean Boussier) via ruby-core
2024-01-20  0:58 ` [ruby-core:116343] " mame (Yusuke Endoh) via ruby-core
2024-01-20 11:04 ` [ruby-core:116346] " byroot (Jean Boussier) via ruby-core
2024-01-20 16:50 ` [ruby-core:116348] " Dan0042 (Daniel DeLorme) via ruby-core
2024-02-13  9:42 ` [ruby-core:116693] " ko1 (Koichi Sasada) via ruby-core
2024-02-13 10:28 ` [ruby-core:116694] " byroot (Jean Boussier) via ruby-core
2024-02-13 10:58 ` [ruby-core:116695] " Eregon (Benoit Daloze) via ruby-core
2024-02-13 18:02 ` [ruby-core:116705] " ko1 (Koichi Sasada) via ruby-core
2024-02-13 18:14 ` [ruby-core:116706] " Eregon (Benoit Daloze) via ruby-core
2024-02-14  5:10 ` [ruby-core:116729] " matz (Yukihiro Matsumoto) via ruby-core
2024-02-16  8:39 ` [ruby-core:116793] " byroot (Jean Boussier) via ruby-core
2024-02-16 11:34 ` [ruby-core:116796] " mame (Yusuke Endoh) via ruby-core
2024-02-16 11:38 ` [ruby-core:116797] " byroot (Jean Boussier) via ruby-core
2024-02-16 20:31 ` [ruby-core:116807] " Eregon (Benoit Daloze) via ruby-core
2024-02-16 21:45 ` [ruby-core:116809] " Dan0042 (Daniel DeLorme) via ruby-core
2024-02-17  3:50 ` [ruby-core:116812] " mame (Yusuke Endoh) via ruby-core
2024-02-17 10:33 ` [ruby-core:116818] " Eregon (Benoit Daloze) via ruby-core
2024-02-17 10:48 ` [ruby-core:116821] " Eregon (Benoit Daloze) via ruby-core
2024-03-21 20:08 ` [ruby-core:117285] " Eregon (Benoit Daloze) via ruby-core
2024-03-21 20:08 ` [ruby-core:117286] " Eregon (Benoit Daloze) via ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-100043.20221111002352.7941@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-core@neon.ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).