class Jaeger::Client::Span

Attributes

context[R]
logs[R]
operation_name[RW]
references[R]
start_time[R]
tags[R]

Public Class Methods

new(context, operation_name, collector, start_time: Time.now, references: [], tags: {}) click to toggle source

Creates a new {Span}

@param context [SpanContext] the context of the span @param operation_name [String] the operation name @param collector [Collector] span collector

@return [Span] a new Span

# File lib/jaeger/client/span.rb, line 20
def initialize(context, operation_name, collector, start_time: Time.now, references: [], tags: {})
  @context = context
  @operation_name = operation_name
  @collector = collector
  @start_time = start_time
  @references = references
  @tags = tags.map { |key, value| ThriftTagBuilder.build(key, value) }
  @logs = []
end

Public Instance Methods

finish(end_time: Time.now) click to toggle source

Finish the {Span}

@param end_time [Time] custom end time, if not now

# File lib/jaeger/client/span.rb, line 78
def finish(end_time: Time.now)
  @collector.send_span(self, end_time)
end
get_baggage_item(key) click to toggle source

Get a baggage item

@param key [String] the key of the baggage item

@return Value of the baggage item

# File lib/jaeger/client/span.rb, line 53
def get_baggage_item(key)
  nil
end
log(*args) click to toggle source

Add a log entry to this span

@deprecated Use {#log_kv} instead.

# File lib/jaeger/client/span.rb, line 60
def log(*args)
  warn 'Span#log is deprecated. Please use Span#log_kv instead.'
  log_kv(*args)
end
log_kv(timestamp: Time.now, **fields) click to toggle source

Add a log entry to this span

@param timestamp [Time] time of the log @param fields [Hash] Additional information to log

# File lib/jaeger/client/span.rb, line 69
def log_kv(timestamp: Time.now, **fields)
  # Using Thrift::Log to avoid unnecessary memory allocations
  @logs << ThriftLogBuilder.build(timestamp, fields)
  nil
end
set_baggage_item(key, value) click to toggle source

Set a baggage item on the span

@param key [String] the key of the baggage item @param value [String] the value of the baggage item

# File lib/jaeger/client/span.rb, line 44
def set_baggage_item(key, value)
  self
end
set_tag(key, value) click to toggle source

Set a tag value on this span

@param key [String] the key of the tag @param value [String, Numeric, Boolean] the value of the tag. If it's not a String, Numeric, or Boolean it will be encoded with to_s

# File lib/jaeger/client/span.rb, line 35
def set_tag(key, value)
  # Using Thrift::Tag to avoid unnecessary memory allocations
  @tags << ThriftTagBuilder.build(key, value)
end