Class: Trace::TraceId

Inherits:
Object
  • Object
show all
Defined in:
lib/finagle-thrift/trace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace_id, parent_id, span_id, sampled, flags) ⇒ TraceId

Returns a new instance of TraceId.



64
65
66
67
68
69
70
# File 'lib/finagle-thrift/trace.rb', line 64

def initialize(trace_id, parent_id, span_id, sampled, flags)
  @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
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



62
63
64
# File 'lib/finagle-thrift/trace.rb', line 62

def flags
  @flags
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



62
63
64
# File 'lib/finagle-thrift/trace.rb', line 62

def parent_id
  @parent_id
end

#sampledObject (readonly)

Returns the value of attribute sampled.



62
63
64
# File 'lib/finagle-thrift/trace.rb', line 62

def sampled
  @sampled
end

#span_idObject (readonly)

Returns the value of attribute span_id.



62
63
64
# File 'lib/finagle-thrift/trace.rb', line 62

def span_id
  @span_id
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



62
63
64
# File 'lib/finagle-thrift/trace.rb', line 62

def trace_id
  @trace_id
end

Instance Method Details

#debug?Boolean

the debug flag is used to ensure the trace passes ALL samplers

Returns:

  • (Boolean)


77
78
79
# File 'lib/finagle-thrift/trace.rb', line 77

def debug?
  @flags & Flags::DEBUG == Flags::DEBUG
end

#next_idObject



72
73
74
# File 'lib/finagle-thrift/trace.rb', line 72

def next_id
  TraceId.new(@trace_id, @span_id, Trace.generate_id, @sampled, @flags)
end

#sampled?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/finagle-thrift/trace.rb', line 81

def sampled?
  debug? || @sampled
end

#to_sObject



85
86
87
# File 'lib/finagle-thrift/trace.rb', line 85

def to_s
  "TraceId(trace_id = #{@trace_id.to_s}, parent_id = #{@parent_id.to_s}, span_id = #{@span_id.to_s}, sampled = #{@sampled.to_s}, flags = #{@flags.to_s})"
end