Project

General

Profile

Feature #15287

New TracePoint events to support loading features

Added by ko1 (Koichi Sasada) 14 days ago. Updated 13 days ago.

Status:
Open
Priority:
Normal
Target version:
[ruby-core:89742]

Description

Abstract

I propose the following new TracePoint events:

  • loaded (invoked after require/load)
  • method_added (invoked after method definition)

Background

Sometimes we need to hook loading iseq. For example, checking loading files and so on.
Also we want to know what kind of methods are defined.

For both purpose, we can use some hook methods such as Module#method_added and so on.
However, defining methods we can override this features.
So that if we have two tools/libraries using this feature, they can be conflicted.

Proposal

Introduce new TracePoint events:

  • loaded (invoked after require/load)
  • method_added (invoked after method definition)

Also the following methods can be added:

  • Active only loaded event:
    • TracePoint#loaded_feature returns feature name.
    • TracePoint#loaded_iseq returns RubyVM::InstructionSequence object (MRI only, internal feature)

Optional proposal

Add class_added alias name for class event.

History

#1 [ruby-core:89744] Updated by shevegen (Robert A. Heiler) 13 days ago

I love introspection, so .. \o/

Also available in: Atom PDF