Last active
February 11, 2023 11:01
-
-
Save igaiga/838d8e5617c41461d14add0388ab7f2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/st0012/ruby_tracer | |
Tracer.new(:exception) {} | |
Tracer.new(:exception).trace {} | |
Tracer.new(:exception).config(a: true, b: 1, ...).trace {} | |
Tracer.new(:exception, config_a: true, config_b: 1, ...).trace {} | |
# The method name "trace" is nice, but maybe a better name? | |
# "Tracer#trace" seems redundant. | |
Tracer.new(:call) {} | |
Tracer.new(:line) {} | |
tracer = Tracer.new(:call) | |
tracer.enable or start | |
... | |
tracer.disable or finish or suspend | |
They are similar to TracePoint. | |
https://docs.ruby-lang.org/ja/latest/class/TracePoint.html#S_NEW |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IMO, the Tracer API should NOT look like
TracePoint
's, because they're used in different ways:TracePoint
: usually to implement something that'll stay (e.g. a tracer).Tracer
: usually to be removed/added frequently, likeputs
. So it should be short and easy to remember.And given its frequent-editing need, I'm favoring methods
Tracer.trace_call
over instancesTracer.new(:call)
because the former can be autocompleted in editor or IRB.