Module: Anyway::Tracing
- Included in:
- Env, Loaders::Base
- Defined in:
- lib/anyway/tracing.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, **opts) ⇒ Object
- .trace_stack ⇒ Object
- .with_trace_source(src) ⇒ Object
Class Method Details
.capture ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/anyway/tracing.rb', line 131 def capture unless 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?
149 |
# File 'lib/anyway/tracing.rb', line 149 def current_trace() = trace_stack.last |
.current_trace_source ⇒ Object
157 158 159 |
# File 'lib/anyway/tracing.rb', line 157 def current_trace_source source_stack.last || accessor_source(caller_locations(2, 1).first) end |
.source_stack ⇒ Object
153 154 155 |
# File 'lib/anyway/tracing.rb', line 153 def source_stack (Thread.current[:__anyway__trace_source_stack__] ||= []) end |
.trace!(type, *path, **opts) ⇒ Object
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/anyway/tracing.rb', line 177 def trace!(type, *path, **opts) return yield unless Tracing.tracing? val = yield if val.is_a?(Hash) Tracing.current_trace.merge_values(val, type:, **opts) else Tracing.current_trace.record_value(val, *path, type:, **opts) end val end |
.trace_stack ⇒ Object
145 146 147 |
# File 'lib/anyway/tracing.rb', line 145 def trace_stack (Thread.current[:__anyway__trace_stack__] ||= []) end |
.with_trace_source(src) ⇒ Object
161 162 163 164 165 166 |
# File 'lib/anyway/tracing.rb', line 161 def with_trace_source(src) source_stack << src yield ensure source_stack.pop end |