Class: OpenTracing::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/opentracing/span.rb

Overview

Span represents an OpenTracing Span

See www.opentracing.io for more information.

Constant Summary collapse

NOOP_INSTANCE =
Span.new.freeze

Instance Method Summary collapse

Instance Method Details

#contextSpanContext

Span Context

Returns:



16
17
18
# File 'lib/opentracing/span.rb', line 16

def context
  SpanContext::NOOP_INSTANCE
end

#finish(end_time: Time.now) ⇒ Object

Finish the OpenTracing::Span

Parameters:

  • end_time (Time) (defaults to: Time.now)

    custom end time, if not now



64
65
66
# File 'lib/opentracing/span.rb', line 64

def finish(end_time: Time.now)
  nil
end

#get_baggage_item(key) ⇒ String

Get a baggage item

Parameters:

  • key (String)

    the key of the baggage item

Returns:

  • (String)

    value of the baggage item



38
39
40
# File 'lib/opentracing/span.rb', line 38

def get_baggage_item(key)
  nil
end

#log(event: nil, timestamp: Time.now, **fields) ⇒ Object

Deprecated.

Use #log_kv instead.

Reason: event is an optional standard log field defined in spec and not required. Also, method name #log_kv is more consistent with other language implementations such as Python and Go.

Add a log entry to this span

Parameters:

  • event (String) (defaults to: nil)

    event name for the log

  • timestamp (Time) (defaults to: Time.now)

    time of the log

  • fields (Hash)

    Additional information to log



50
51
52
53
# File 'lib/opentracing/span.rb', line 50

def log(event: nil, timestamp: Time.now, **fields)
  warn 'Span#log is deprecated.  Please use Span#log_kv instead.'
  nil
end

#log_kv(timestamp: Time.now, **fields) ⇒ Object

Add a log entry to this span

Parameters:

  • timestamp (Time) (defaults to: Time.now)

    time of the log

  • fields (Hash)

    Additional information to log



58
59
60
# File 'lib/opentracing/span.rb', line 58

def log_kv(timestamp: Time.now, **fields)
  nil
end

#operation_name=(name) ⇒ Object

Set the name of the operation

Parameters:

  • name (String)


11
# File 'lib/opentracing/span.rb', line 11

def operation_name=(name); end

#set_baggage_item(key, value) ⇒ Object

Set a baggage item on the span

Parameters:

  • key (String)

    the key of the baggage item

  • value (String)

    the value of the baggage item



31
32
33
# File 'lib/opentracing/span.rb', line 31

def set_baggage_item(key, value)
  self
end

#set_tag(key, value) ⇒ Object

Set a tag value on this span a String, Numeric, or Boolean it will be encoded with to_s

Parameters:

  • key (String)

    the key of the tag

  • value (String, Numeric, Boolean)

    the value of the tag. If it’s not



24
25
26
# File 'lib/opentracing/span.rb', line 24

def set_tag(key, value)
  self
end