Class: Datadog::Tracing::SpanLink
- Inherits:
-
Object
- Object
- Datadog::Tracing::SpanLink
- Defined in:
- lib/datadog/tracing/span_link.rb
Overview
SpanLink represents a causal link between two spans.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#dropped_attributes ⇒ Object
readonly
Returns the value of attribute dropped_attributes.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#trace_flags ⇒ Object
readonly
Returns the value of attribute trace_flags.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
-
#trace_state ⇒ Object
readonly
Returns the value of attribute trace_state.
Instance Method Summary collapse
-
#initialize(digest, attributes: nil) ⇒ SpanLink
constructor
A new instance of SpanLink.
- #to_hash ⇒ Object
Constructor Details
#initialize(digest, attributes: nil) ⇒ SpanLink
Returns a new instance of SpanLink.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/datadog/tracing/span_link.rb', line 43 def initialize( digest, attributes: nil ) @span_id = digest.span_id @trace_id = digest.trace_id @trace_flags = if digest.trace_sampling_priority.nil? nil elsif digest.trace_sampling_priority > 0 1 else 0 end @trace_state = digest.trace_state && digest.trace_state.dup @dropped_attributes = 0 @attributes = (attributes && attributes.dup) || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
21 22 23 |
# File 'lib/datadog/tracing/span_link.rb', line 21 def attributes @attributes end |
#dropped_attributes ⇒ Object (readonly)
Returns the value of attribute dropped_attributes.
41 42 43 |
# File 'lib/datadog/tracing/span_link.rb', line 41 def dropped_attributes @dropped_attributes end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
11 12 13 |
# File 'lib/datadog/tracing/span_link.rb', line 11 def span_id @span_id end |
#trace_flags ⇒ Object (readonly)
Returns the value of attribute trace_flags.
27 28 29 |
# File 'lib/datadog/tracing/span_link.rb', line 27 def trace_flags @trace_flags end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
16 17 18 |
# File 'lib/datadog/tracing/span_link.rb', line 16 def trace_id @trace_id end |
#trace_state ⇒ Object (readonly)
Returns the value of attribute trace_state.
36 37 38 |
# File 'lib/datadog/tracing/span_link.rb', line 36 def trace_state @trace_state end |
Instance Method Details
#to_hash ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/datadog/tracing/span_link.rb', line 61 def to_hash h = { span_id: @span_id || 0, trace_id: Tracing::Utils::TraceId.to_low_order(@trace_id) || 0, } # Optimization: Hash non empty attributes if @trace_id.to_i > Tracing::Utils::EXTERNAL_MAX_ID h[:trace_id_high] = Tracing::Utils::TraceId.to_high_order(@trace_id) end unless @attributes&.empty? h[:attributes] = {} @attributes.each do |k1, v1| Tracing::Utils.serialize_attribute(k1, v1).each do |new_k1, value| h[:attributes][new_k1] = value.to_s end end end h[:dropped_attributes_count] = @dropped_attributes if @dropped_attributes > 0 h[:tracestate] = @trace_state if @trace_state # If traceflags set, the high bit (bit 31) should be set to 1 (uint32). # This helps us distinguish between when the sample decision is zero or not set h[:flags] = if @trace_flags.nil? 0 else @trace_flags | (1 << 31) end h end |