Class: Necropsy::Analyzers::Dynamic::TracePointCollector
- Inherits:
-
Object
- Object
- Necropsy::Analyzers::Dynamic::TracePointCollector
- Defined in:
- lib/necropsy/analyzers/dynamic/trace_point_collector.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root:, output:, sample_rate: 1.0) ⇒ TracePointCollector
constructor
A new instance of TracePointCollector.
- #record ⇒ Object
Constructor Details
#initialize(root:, output:, sample_rate: 1.0) ⇒ TracePointCollector
Returns a new instance of TracePointCollector.
15 16 17 18 19 20 21 22 |
# File 'lib/necropsy/analyzers/dynamic/trace_point_collector.rb', line 15 def initialize(root:, output:, sample_rate: 1.0) @root = File.(root) @output = output @sample_rate = sample_rate.to_f @nodes = {} @edges = {} @stack = [] end |
Class Method Details
.record(root:, output:, sample_rate: 1.0) ⇒ Object
11 12 13 |
# File 'lib/necropsy/analyzers/dynamic/trace_point_collector.rb', line 11 def self.record(root:, output:, sample_rate: 1.0, &) new(root: root, output: output, sample_rate: sample_rate).record(&) end |
Instance Method Details
#record ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/necropsy/analyzers/dynamic/trace_point_collector.rb', line 24 def record started_at = Time.now.utc tracer = TracePoint.new(:call, :return) { |event| capture(event) } tracer.enable yield ensure tracer&.disable write_payload(started_at: started_at, finished_at: Time.now.utc) end |