[ruby-core:113751] [Ruby master Feature#19056] Introduce `Fiber.annotation` for attaching messages to fibers.

Issue #19056 has been updated by ioquatix (Samuel Williams). I came back to this issue.
I don't see the convenience of `Fiber.annotate`. Convince me.
- Logging what the current fiber is doing. - Recording what the current fiber is doing when an error or exception occurs. - Real time debugger output (e.g. as shown in the screenshot).
Users need to understand how to use Fiber#annotation wisely. Need documents.
Yes, I am happy to include documentation about it.
The state should be stacked, not overridden. How do you think?
What about: ```ruby Fiber.annotate "x" do Fiber.annotation # "x" Fiber.annotate "y" do Fiber.annotation # "y" end Fiber.annotation # "x" end ```
I have a bit of performance concern. Is it OK?
It's a single pointer assignment so it should be minimal. Compared to "blocking operations" it should be irrelevant. In order to try this out more generally, I created a gem. You can see the proposed implementation here: https://github.com/ioquatix/fiber-annotate/blob/main/lib/fiber/annotate.rb The reason to make this a core interface, is so that default gems can use it. ---------------------------------------- Feature #19056: Introduce `Fiber.annotation` for attaching messages to fibers. https://bugs.ruby-lang.org/issues/19056#change-103398 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) ---------------------------------------- It's useful to know what a fiber is doing especially when they have a temporal execution (i.e. sockets connecting vs connected, binding vs accepting, queue popping, etc) Let's introduce `Fiber.annotate` and `Fiber#annotation` for logging a short message attached to Fibers. ```ruby Fiber.annotate "Counting to 10" 10.times{|I| puts I} # Fiber.current.annotation => "Counting to 10" ``` Pull Request: https://github.com/ruby/ruby/pull/6554 ---Files-------------------------------- clipboard-202210160132-n7lzp.png (865 KB) -- https://bugs.ruby-lang.org/
participants (1)
-
ioquatix (Samuel Williams)