Class: AppMap::Hook::RecordAround::Context
- Defined in:
- lib/appmap/hook/record_around.rb
Overview
Context for a recording.
Instance Attribute Summary collapse
-
#hook_method ⇒ Object
readonly
Returns the value of attribute hook_method.
Instance Method Summary collapse
-
#finish ⇒ Object
Finish recording the AppMap by collecting the events and classMap and writing the output file.
-
#initialize(hook_method) ⇒ Context
constructor
A new instance of Context.
Constructor Details
Instance Attribute Details
#hook_method ⇒ Object (readonly)
Returns the value of attribute hook_method.
9 10 11 |
# File 'lib/appmap/hook/record_around.rb', line 9 def hook_method @hook_method end |
Instance Method Details
#finish ⇒ Object
Finish recording the AppMap by collecting the events and classMap and writing the output file. rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/appmap/hook/record_around.rb', line 20 def finish return unless @tracer tracer = @tracer @tracer = nil AppMap.tracing.delete(tracer) events = tracer.events.map(&:to_h) = DateTime.now appmap_name = "#{hook_method.name} (#{Thread.current.object_id}) - #{.strftime("%T.%L")}" appmap_file_name = AppMap::Util.scenario_filename([.to_f, hook_method.name, Thread.current.object_id].join("_")) = AppMap..tap do || [:name] = appmap_name [:source_location] = hook_method.source_location [:recorder] = { name: "command", type: "requests" } end appmap = { version: AppMap::APPMAP_FORMAT_VERSION, classMap: AppMap.class_map(tracer.event_methods), metadata: , events: events } AppMap::Util.write_appmap(File.join(APPMAP_OUTPUT_DIR, appmap_file_name), appmap) end |