Class: Skywalking::Tracing::ContextManager
- Inherits:
-
Object
- Object
- Skywalking::Tracing::ContextManager
- Defined in:
- lib/skywalking/tracing/span_context.rb
Class Method Summary collapse
- .current_context ⇒ Object
- .new_entry_span(operation:, carrier: nil, inherit: nil, &block) ⇒ Object
- .new_exit_span(operation:, peer: nil, component: nil, inherit: nil, &block) ⇒ Object
- .new_local_span(operation:, &block) ⇒ Object
- .reset_spans ⇒ Object
- .spans ⇒ Object
- .spans_dup ⇒ Object
Class Method Details
.current_context ⇒ Object
195 196 197 198 199 200 201 202 |
# File 'lib/skywalking/tracing/span_context.rb', line 195 def current_context spans_ret = spans if spans_ret.any? spans.last.context else SpanContext.new end end |
.new_entry_span(operation:, carrier: nil, inherit: nil, &block) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/skywalking/tracing/span_context.rb', line 216 def new_entry_span(operation:, carrier: nil, inherit: nil, &block) context = current_context span = context.new_entry_span(operation, carrier: carrier, inherit: inherit) span&.start begin yield span if block_given? ensure span&.stop? end end |
.new_exit_span(operation:, peer: nil, component: nil, inherit: nil, &block) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/skywalking/tracing/span_context.rb', line 204 def new_exit_span(operation:, peer: nil, component: nil, inherit: nil, &block) context = current_context span = context.new_exit_span(operation, peer, component: component, inherit: inherit) span&.start begin yield span if block_given? ensure span&.stop? end end |
.new_local_span(operation:, &block) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/skywalking/tracing/span_context.rb', line 228 def new_local_span(operation:, &block) context = current_context span = context.new_local_span(operation) span&.start begin yield span if block_given? ensure span&.stop? end end |
.reset_spans ⇒ Object
191 192 193 |
# File 'lib/skywalking/tracing/span_context.rb', line 191 def reset_spans Thread.current[:spans] = [] end |
.spans ⇒ Object
180 181 182 |
# File 'lib/skywalking/tracing/span_context.rb', line 180 def spans Thread.current[:spans] ||= [] end |
.spans_dup ⇒ Object
184 185 186 187 188 189 |
# File 'lib/skywalking/tracing/span_context.rb', line 184 def spans_dup spans_dup = spans.dup Thread.current[:spans] = spans_dup spans_dup end |