Class: Skywalking::Tracing::Span
- Inherits:
-
Object
- Object
- Skywalking::Tracing::Span
- Defined in:
- lib/skywalking/tracing/span.rb
Instance Attribute Summary collapse
-
#component ⇒ Object
Returns the value of attribute component.
-
#context ⇒ Object
Returns the value of attribute context.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#error_occurred ⇒ Object
Returns the value of attribute error_occurred.
-
#inherit ⇒ Object
Returns the value of attribute inherit.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#layer ⇒ Object
Returns the value of attribute layer.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#peer ⇒ Object
Returns the value of attribute peer.
-
#refs ⇒ Object
readonly
Returns the value of attribute refs.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#stack_depth ⇒ Object
readonly
Returns the value of attribute stack_depth.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #extract(carrier) ⇒ Object
- #finish?(segment) ⇒ Boolean
-
#initialize(context:, span_id: -1,, parent_id: -1,, operation: nil, peer: nil, kind: nil, component: nil, layer: nil) ⇒ Span
constructor
A new instance of Span.
- #inject ⇒ Object
- #start ⇒ Object
- #stop? ⇒ Boolean
- #tag(tag) ⇒ Object
- #tags_item ⇒ Object
Constructor Details
#initialize(context:, span_id: -1,, parent_id: -1,, operation: nil, peer: nil, kind: nil, component: nil, layer: nil) ⇒ Span
Returns a new instance of Span.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/skywalking/tracing/span.rb', line 29 def initialize( context:, span_id: -1, parent_id: -1, operation: nil, peer: nil, kind: nil, component: nil, layer: nil ) @context = context @operation = operation @span_id = span_id @parent_id = parent_id @peer = peer @layer = layer || Layer::Unknown @kind = kind || nil @component = component || Component::Unknown @stack_depth = 0 @inherit = Component::Unknown = Hash.new { |hash, key| hash[key] = [] } @logs = [] @refs = [] @start_time = 0 @end_time = 0 @error_occurred = false end |
Instance Attribute Details
#component ⇒ Object
Returns the value of attribute component.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def component @component end |
#context ⇒ Object
Returns the value of attribute context.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def context @context end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def end_time @end_time end |
#error_occurred ⇒ Object
Returns the value of attribute error_occurred.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def error_occurred @error_occurred end |
#inherit ⇒ Object
Returns the value of attribute inherit.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def inherit @inherit end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def kind @kind end |
#layer ⇒ Object
Returns the value of attribute layer.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def layer @layer end |
#operation ⇒ Object
Returns the value of attribute operation.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def operation @operation end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def parent_id @parent_id end |
#peer ⇒ Object
Returns the value of attribute peer.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def peer @peer end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def refs @refs end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def span_id @span_id end |
#stack_depth ⇒ Object (readonly)
Returns the value of attribute stack_depth.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def stack_depth @stack_depth end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
26 27 28 |
# File 'lib/skywalking/tracing/span.rb', line 26 def start_time @start_time end |
#tags ⇒ Object
Returns the value of attribute tags.
23 24 25 |
# File 'lib/skywalking/tracing/span.rb', line 23 def end |
Instance Method Details
#extract(carrier) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/skywalking/tracing/span.rb', line 97 def extract(carrier) return self if carrier.nil? @context.segment.relate(carrier.trace_id) @context.correlation = carrier.correlation_carrier.correlation return self unless carrier.valid? ref = SegmentRef.new(carrier) @refs << ref unless @refs.include?(ref) self end |
#finish?(segment) ⇒ Boolean
73 74 75 76 77 78 |
# File 'lib/skywalking/tracing/span.rb', line 73 def finish?(segment) @end_time = (Process.clock_gettime(Process::CLOCK_REALTIME) * 1000).to_i segment.archive(self) true end |
#inject ⇒ Object
92 93 94 95 |
# File 'lib/skywalking/tracing/span.rb', line 92 def inject raise 'can only inject context carrier into ExitSpan, this may be a potential bug in the agent, ' \ 'please report this in https://github.com/apache/skywalking/issues if you encounter this. ' end |
#start ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/skywalking/tracing/span.rb', line 58 def start @stack_depth += 1 return if @stack_depth != 1 @start_time = (Process.clock_gettime(Process::CLOCK_REALTIME) * 1000).to_i @context.start(self) end |
#stop? ⇒ Boolean
66 67 68 69 70 71 |
# File 'lib/skywalking/tracing/span.rb', line 66 def stop? @stack_depth -= 1 return false unless @stack_depth.zero? @context.stop?(self) end |
#tag(tag) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/skywalking/tracing/span.rb', line 80 def tag(tag) if tag.insert [tag.key] = tag else [tag.key] << tag end end |
#tags_item ⇒ Object
88 89 90 |
# File 'lib/skywalking/tracing/span.rb', line 88 def .values.map { |tag| KeyStringValuePair.new(key: tag.key, value: tag.val) } end |