Module: Runger::Tracing
- Included in:
- Env, Loaders::Base
- Defined in:
- lib/runger/tracing.rb,
lib/runger_config.rb
Overview
Provides method to trace values association
Defined Under Namespace
Classes: Trace
Class Method Summary collapse
- .capture ⇒ Object
- .current_trace ⇒ Object (also: tracing?)
- .current_trace_source ⇒ Object
- .source_stack ⇒ Object
- .trace!(type, *path, **options) ⇒ Object
- .trace_stack ⇒ Object
- .with_trace_source(src) ⇒ Object
Class Method Details
.capture ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/runger/tracing.rb', line 138 def capture unless ::Runger::Settings.tracing_enabled yield return end trace = Trace.new trace_stack.push(trace) yield trace_stack.last ensure trace_stack.pop end |
.current_trace ⇒ Object Also known as: tracing?
156 |
# File 'lib/runger/tracing.rb', line 156 def current_trace = trace_stack.last |
.current_trace_source ⇒ Object
164 165 166 |
# File 'lib/runger/tracing.rb', line 164 def current_trace_source source_stack.last || accessor_source(caller_locations(2, 1).first) end |
.source_stack ⇒ Object
160 161 162 |
# File 'lib/runger/tracing.rb', line 160 def source_stack (Thread.current[:__runger__trace_source_stack__] ||= []) end |
.trace!(type, *path, **options) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/runger/tracing.rb', line 184 def trace!(type, *path, **) return yield unless ::Runger::Tracing.tracing? val = yield if val.is_a?(Hash) ::Runger::Tracing.current_trace.merge_values(val, type:, **) elsif !path.empty? ::Runger::Tracing.current_trace.record_value(val, *path, type:, **) end val end |
.trace_stack ⇒ Object
152 153 154 |
# File 'lib/runger/tracing.rb', line 152 def trace_stack (Thread.current[:__runger__trace_stack__] ||= []) end |
.with_trace_source(src) ⇒ Object
168 169 170 171 172 173 |
# File 'lib/runger/tracing.rb', line 168 def with_trace_source(src) source_stack << src yield ensure source_stack.pop end |