Class: Skywalking::Tracing::Carrier
- Inherits:
-
CarrierItem
- Object
- CarrierItem
- Skywalking::Tracing::Carrier
- Defined in:
- lib/skywalking/tracing/carrier.rb
Instance Attribute Summary collapse
-
#correlation_carrier ⇒ Object
readonly
Returns the value of attribute correlation_carrier.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#iter_index ⇒ Object
readonly
Returns the value of attribute iter_index.
-
#peer ⇒ Object
readonly
Returns the value of attribute peer.
-
#segment_id ⇒ Object
readonly
Returns the value of attribute segment_id.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#service_instance ⇒ Object
readonly
Returns the value of attribute service_instance.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
Attributes inherited from CarrierItem
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(trace_id: '', segment_id: '', span_id: '', service: '', service_instance: '', endpoint: '', peer: '', correlation: nil) ⇒ Carrier
constructor
A new instance of Carrier.
- #suppressed? ⇒ Boolean
- #valid? ⇒ Boolean
- #value ⇒ Object
- #value=(val) ⇒ Object
Constructor Details
#initialize(trace_id: '', segment_id: '', span_id: '', service: '', service_instance: '', endpoint: '', peer: '', correlation: nil) ⇒ Carrier
Returns a new instance of Carrier.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/skywalking/tracing/carrier.rb', line 26 def initialize( trace_id: '', segment_id: '', span_id: '', service: '', service_instance: '', endpoint: '', peer: '', correlation: nil ) super(key: 'sw8') @trace_id = trace_id @segment_id = segment_id @span_id = span_id @service = service @service_instance = service_instance @endpoint = endpoint @peer = peer @correlation_carrier = SW8CorrelationCarrier.new @items = [@correlation_carrier, self] @iter_index = 0 @correlation_carrier.correlation = correlation unless correlation.nil? end |
Instance Attribute Details
#correlation_carrier ⇒ Object (readonly)
Returns the value of attribute correlation_carrier.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def correlation_carrier @correlation_carrier end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def endpoint @endpoint end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def items @items end |
#iter_index ⇒ Object (readonly)
Returns the value of attribute iter_index.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def iter_index @iter_index end |
#peer ⇒ Object (readonly)
Returns the value of attribute peer.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def peer @peer end |
#segment_id ⇒ Object (readonly)
Returns the value of attribute segment_id.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def segment_id @segment_id end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def service @service end |
#service_instance ⇒ Object (readonly)
Returns the value of attribute service_instance.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def service_instance @service_instance end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def span_id @span_id end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
22 23 24 |
# File 'lib/skywalking/tracing/carrier.rb', line 22 def trace_id @trace_id end |
Instance Method Details
#each ⇒ Object
90 91 92 |
# File 'lib/skywalking/tracing/carrier.rb', line 90 def each @items.each { |item| yield item } end |
#suppressed? ⇒ Boolean
86 87 88 |
# File 'lib/skywalking/tracing/carrier.rb', line 86 def suppressed? @val && !valid? end |
#valid? ⇒ Boolean
80 81 82 83 84 |
# File 'lib/skywalking/tracing/carrier.rb', line 80 def valid? !@trace_id.empty? && !@segment_id.empty? && !@service.empty? && !@service_instance.empty? && !@endpoint.empty? && !@peer.empty? && @span_id.match?(/^\d+$/) end |
#value ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/skywalking/tracing/carrier.rb', line 51 def value [ '1', Base64.strict_encode64(@trace_id), Base64.strict_encode64(@segment_id), @span_id, Base64.strict_encode64(@service), Base64.strict_encode64(@service_instance), Base64.strict_encode64(@endpoint), Base64.strict_encode64(@peer) ].join('-') end |
#value=(val) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/skywalking/tracing/carrier.rb', line 64 def value=(val) @val = val return if val.nil? || val.empty? parts = val.split('-') return if parts.size != 8 @trace_id = Base64.strict_decode64(parts[1]) @segment_id = Base64.strict_decode64(parts[2]) @span_id = parts[3] @service = Base64.strict_decode64(parts[4]) @service_instance = Base64.strict_decode64(parts[5]) @endpoint = Base64.strict_decode64(parts[6]) @peer = Base64.strict_decode64(parts[7]) end |