Class: Trace::TraceId
- Inherits:
-
Object
- Object
- Trace::TraceId
- Defined in:
- lib/zipkin-tracer/trace.rb
Overview
A TraceId contains all the information of a given trace id
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#sampled ⇒ Object
readonly
Returns the value of attribute sampled.
-
#shared ⇒ Object
readonly
Returns the value of attribute shared.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
Instance Method Summary collapse
-
#debug? ⇒ Boolean
the debug flag is used to ensure the trace passes ALL samplers.
-
#initialize(trace_id, parent_id, span_id, sampled, flags, shared = false) ⇒ TraceId
constructor
A new instance of TraceId.
- #next_id ⇒ Object
- #sampled? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(trace_id, parent_id, span_id, sampled, flags, shared = false) ⇒ TraceId
Returns a new instance of TraceId.
108 109 110 111 112 113 114 115 |
# File 'lib/zipkin-tracer/trace.rb', line 108 def initialize(trace_id, parent_id, span_id, sampled, flags, shared = false) @trace_id = Trace.trace_id_128bit ? TraceId128Bit.from_value(trace_id) : SpanId.from_value(trace_id) @parent_id = parent_id.nil? ? nil : SpanId.from_value(parent_id) @span_id = SpanId.from_value(span_id) @sampled = sampled @flags = flags @shared = shared end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def flags @flags end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def parent_id @parent_id end |
#sampled ⇒ Object (readonly)
Returns the value of attribute sampled.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def sampled @sampled end |
#shared ⇒ Object (readonly)
Returns the value of attribute shared.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def shared @shared end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def span_id @span_id end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 106 def trace_id @trace_id end |
Instance Method Details
#debug? ⇒ Boolean
the debug flag is used to ensure the trace passes ALL samplers
122 123 124 |
# File 'lib/zipkin-tracer/trace.rb', line 122 def debug? flags & Flags::DEBUG == Flags::DEBUG end |
#next_id ⇒ Object
117 118 119 |
# File 'lib/zipkin-tracer/trace.rb', line 117 def next_id TraceId.new(trace_id, span_id, ZipkinTracer::TraceGenerator.new.generate_id, sampled, flags) end |
#sampled? ⇒ Boolean
126 127 128 |
# File 'lib/zipkin-tracer/trace.rb', line 126 def sampled? debug? || %w[1 true].include?(sampled) end |
#to_s ⇒ Object
130 131 132 133 |
# File 'lib/zipkin-tracer/trace.rb', line 130 def to_s "TraceId(trace_id = #{trace_id}, parent_id = #{parent_id}, span_id = #{span_id}," \ " sampled = #{sampled}, flags = #{flags}, shared = #{shared})" end |