Module: Trailblazer::Developer::Trace
- Defined in:
- lib/trailblazer/developer/trace.rb,
lib/trailblazer/developer/trace/node.rb,
lib/trailblazer/developer/trace/stack.rb,
lib/trailblazer/developer/trace/present.rb,
lib/trailblazer/developer/trace/snapshot.rb,
lib/trailblazer/developer/trace/parent_map.rb,
lib/trailblazer/developer/trace/snapshot/value.rb,
lib/trailblazer/developer/trace/snapshot/versions.rb
Defined Under Namespace
Modules: ParentMap, Present Classes: Node, Snapshot, Stack
Constant Summary collapse
- TASK_WRAP_EXTENSION =
Insertions for the trace tasks that capture the arguments just before calling the task, and before the TaskWrap is finished.
Trailblazer::Activity::TaskWrap.Extension( [Trace.method(:capture_args), id: "task_wrap.capture_args", prepend: "task_wrap.call_task"], [Trace.method(:capture_return), id: "task_wrap.capture_return", append: nil], # append to the very end of tW. )
- Debugger =
FIXME: deprecate constant!
Trailblazer::Developer::Debugger
Instance Attribute Summary collapse
-
#value_snapshooter ⇒ Object
readonly
NOTE: this is semi-private.
Class Method Summary collapse
- .arguments_for_call(activity, options, original_flow_options, **original_circuit_options) ⇒ Object
-
.build_nodes(snapshots) ⇒ Object
Build array of Node from a snapshots stack.
-
.call(activity, ctx, flow_options, **circuit_options) ⇒ Object
(also: invoke)
Public entry point to run an activity with tracing.
-
.capture_args(wrap_config, original_args) ⇒ Object
It’s important to understand that :stack is mutated by design.
-
.capture_return(wrap_config, ctx, flow_options), circuit_options) ⇒ Object
taskWrap step to capture outgoing arguments from a step.
- .task_wrap_extensions ⇒ Object
Instance Attribute Details
#value_snapshooter ⇒ Object (readonly)
NOTE: this is semi-private.
38 39 40 |
# File 'lib/trailblazer/developer/trace.rb', line 38 def value_snapshooter @value_snapshooter end |
Class Method Details
.arguments_for_call(activity, options, original_flow_options, **original_circuit_options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/trailblazer/developer/trace.rb', line 17 def arguments_for_call(activity, (, ), **) = { stack: Trace::Stack.new, before_snapshooter: Snapshot.method(:before_snapshooter), after_snapshooter: Snapshot.method(:after_snapshooter), value_snapshooter: Trace.value_snapshooter } = {**, **Hash()} = { wrap_runtime: ::Hash.new(Trace.task_wrap_extensions), # DISCUSS: this overrides existing {:wrap_runtime}. } = {**, **} return activity, [, ], end |
.build_nodes(snapshots) ⇒ Object
Build array of Node from a snapshots stack.
6 7 8 9 10 11 12 |
# File 'lib/trailblazer/developer/trace/node.rb', line 6 def self.build_nodes(snapshots) instructions = [ [0, snapshots] ] _nodes = Node.process_instructions(instructions) end |
.call(activity, ctx, flow_options, **circuit_options) ⇒ Object Also known as: invoke
Public entry point to run an activity with tracing. It returns the accumulated stack of Snapshots, along with the original return values. Note that invoke does not do any rendering.
7 8 9 10 11 12 13 |
# File 'lib/trailblazer/developer/trace.rb', line 7 def call(activity, (ctx, ), **) activity, (ctx, ), = Trace.arguments_for_call(activity, [ctx, ], **) # only run once for the entire circuit! signal, (ctx, ) = Trailblazer::Activity::TaskWrap.invoke(activity, [ctx, ], **) return [:stack], signal, [ctx, ] end |
.capture_args(wrap_config, original_args) ⇒ Object
It’s important to understand that :stack is mutated by design. This is needed so in case of exceptions we still have a “global” trace - unfortunately Ruby doesn’t allow us a better way. taskWrap step to capture incoming arguments of a step.
Note that we save the created Trailblazer::Developer::Trace::Snapshot::Before in the wrap_ctx.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trailblazer/developer/trace.rb', line 56 def capture_args(wrap_config, original_args) = original_args[0][1] snapshot, new_versions = Snapshot::Before.([:before_snapshooter], wrap_config, original_args) # We try to be generic here in the taskWrap snapshooting code, where details happen in Snapshot::Before/After and Stack#add!. [:stack].add!(snapshot, new_versions) return wrap_config.merge(snapshot_before: snapshot), original_args end |
.capture_return(wrap_config, ctx, flow_options), circuit_options) ⇒ Object
taskWrap step to capture outgoing arguments from a step.
68 69 70 71 72 73 74 75 76 |
# File 'lib/trailblazer/developer/trace.rb', line 68 def capture_return(wrap_config, ((ctx, ), )) original_args = [[ctx, ], ] snapshot, new_versions = Snapshot::After.([:after_snapshooter], wrap_config, original_args) [:stack].add!(snapshot, new_versions) return wrap_config, original_args end |
.task_wrap_extensions ⇒ Object
43 44 45 |
# File 'lib/trailblazer/developer/trace.rb', line 43 def task_wrap_extensions TASK_WRAP_EXTENSION end |