Class: OpenTracingTestTracer::Span
- Inherits:
-
Object
- Object
- OpenTracingTestTracer::Span
- Defined in:
- lib/opentracing_test_tracer/span.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
NOTE: These are not OT compliant.
-
#end_time ⇒ Object
readonly
NOTE: These are not OT compliant.
-
#logs ⇒ Object
readonly
NOTE: These are not OT compliant.
-
#operation_name ⇒ Object
Returns the value of attribute operation_name.
-
#references ⇒ Object
readonly
NOTE: These are not OT compliant.
-
#start_time ⇒ Object
readonly
NOTE: These are not OT compliant.
-
#tags ⇒ Object
readonly
NOTE: These are not OT compliant.
Instance Method Summary collapse
-
#finish(end_time: Time.now) ⇒ Object
Finish the Span.
-
#finished? ⇒ Boolean
NOTE: This is not OT compliant.
-
#get_baggage_item(_key) ⇒ Object
Get a baggage item.
-
#initialize(context:, operation_name:, start_time: Time.now, tags: {}, references: nil) ⇒ Span
constructor
A new instance of Span.
-
#log(*args) ⇒ Object
deprecated
Deprecated.
Use #log_kv instead.
-
#log_kv(timestamp: Time.now, **fields) ⇒ Object
Add a log entry to this span.
-
#set_baggage_item(_key, _value) ⇒ Object
Set a baggage item on the span.
-
#set_tag(key, value) ⇒ Object
Set a tag value on this span.
- #to_s ⇒ Object
Constructor Details
#initialize(context:, operation_name:, start_time: Time.now, tags: {}, references: nil) ⇒ Span
Returns a new instance of Span.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/opentracing_test_tracer/span.rb', line 10 def initialize( context:, operation_name:, start_time: Time.now, tags: {}, references: nil ) @context = context @operation_name = operation_name @start_time = start_time @tags = @logs = [] @references = references end |
Instance Attribute Details
#context ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def context @context end |
#end_time ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def end_time @end_time end |
#logs ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def logs @logs end |
#operation_name ⇒ Object
Returns the value of attribute operation_name.
5 6 7 |
# File 'lib/opentracing_test_tracer/span.rb', line 5 def operation_name @operation_name end |
#references ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def references @references end |
#start_time ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def start_time @start_time end |
#tags ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/opentracing_test_tracer/span.rb', line 8 def @tags end |
Instance Method Details
#finish(end_time: Time.now) ⇒ Object
Finish the OpenTracingTestTracer::Span
72 73 74 |
# File 'lib/opentracing_test_tracer/span.rb', line 72 def finish(end_time: Time.now) @end_time = end_time end |
#finished? ⇒ Boolean
NOTE: This is not OT compliant. This is meant only for testing.
86 87 88 |
# File 'lib/opentracing_test_tracer/span.rb', line 86 def finished? @end_time != nil end |
#get_baggage_item(_key) ⇒ Object
Get a baggage item
48 49 50 |
# File 'lib/opentracing_test_tracer/span.rb', line 48 def get_baggage_item(_key) nil end |
#log(*args) ⇒ Object
Use #log_kv instead.
Add a log entry to this span
55 56 57 58 |
# File 'lib/opentracing_test_tracer/span.rb', line 55 def log(*args) warn 'Span#log is deprecated. Please use Span#log_kv instead.' log_kv(*args) end |
#log_kv(timestamp: Time.now, **fields) ⇒ Object
Add a log entry to this span
64 65 66 67 |
# File 'lib/opentracing_test_tracer/span.rb', line 64 def log_kv(timestamp: Time.now, **fields) @logs << fields.merge(timestamp: ) nil end |
#set_baggage_item(_key, _value) ⇒ Object
Set a baggage item on the span
39 40 41 |
# File 'lib/opentracing_test_tracer/span.rb', line 39 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
30 31 32 33 |
# File 'lib/opentracing_test_tracer/span.rb', line 30 def set_tag(key, value) sanitized_value = valid_tag_value?(value) ? value : value.to_s @tags = @tags.merge(key.to_s => sanitized_value) end |
#to_s ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/opentracing_test_tracer/span.rb', line 76 def to_s "Span(operation_name=#{@operation_name}, " \ "tags=#{@tags}, " \ "logs=#{@logs}, " \ "start_time=#{@start_time}, " \ "end_time=#{@end_time}, " \ "context=#{@context})" end |