Class: OpenTracingTestTracer::Span
- Inherits:
-
Object
- Object
- OpenTracingTestTracer::Span
- Defined in:
- lib/signalfx_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, tracer: 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.
-
#record_exception(exception, record_error = true) ⇒ Object
Record an exception on 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
- #tracer ⇒ Object
Constructor Details
#initialize(context:, operation_name:, start_time: Time.now, tags: {}, references: nil, tracer: nil) ⇒ Span
Returns a new instance of Span.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/signalfx_test_tracer/span.rb', line 10 def initialize( context:, operation_name:, start_time: Time.now, tags: {}, references: nil, tracer: nil ) @context = context @operation_name = operation_name @start_time = start_time = @logs = [] @references = references @tracer = tracer end |
Instance Attribute Details
#context ⇒ Object (readonly)
NOTE: These are not OT compliant. These are meant only for testing.
8 9 10 |
# File 'lib/signalfx_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/signalfx_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/signalfx_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/signalfx_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/signalfx_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/signalfx_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/signalfx_test_tracer/span.rb', line 8 def end |
Instance Method Details
#finish(end_time: Time.now) ⇒ Object
Finish the OpenTracingTestTracer::Span
88 89 90 |
# File 'lib/signalfx_test_tracer/span.rb', line 88 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.
102 103 104 |
# File 'lib/signalfx_test_tracer/span.rb', line 102 def finished? @end_time != nil end |
#get_baggage_item(_key) ⇒ Object
Get a baggage item
54 55 56 |
# File 'lib/signalfx_test_tracer/span.rb', line 54 def get_baggage_item(_key) nil end |
#log(*args) ⇒ Object
Use #log_kv instead.
Add a log entry to this span
61 62 63 64 |
# File 'lib/signalfx_test_tracer/span.rb', line 61 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
70 71 72 73 |
# File 'lib/signalfx_test_tracer/span.rb', line 70 def log_kv(timestamp: Time.now, **fields) @logs << fields.merge(timestamp: ) nil end |
#record_exception(exception, record_error = true) ⇒ Object
Record an exception on this span
76 77 78 79 80 81 82 83 |
# File 'lib/signalfx_test_tracer/span.rb', line 76 def record_exception(exception, record_error=true) set_tag(:error, true) if record_error set_tag(:'sfx.error.kind', exception.class.to_s) set_tag(:'sfx.error.message', exception.) if not exception.backtrace.nil? set_tag(:'sfx.error.stack', exception.backtrace.join('\n')) end end |
#set_baggage_item(_key, _value) ⇒ Object
Set a baggage item on the span
45 46 47 |
# File 'lib/signalfx_test_tracer/span.rb', line 45 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
36 37 38 39 |
# File 'lib/signalfx_test_tracer/span.rb', line 36 def set_tag(key, value) sanitized_value = valid_tag_value?(value) ? value : value.to_s = .merge(key.to_s => sanitized_value) end |
#to_s ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/signalfx_test_tracer/span.rb', line 92 def to_s "Span(operation_name=#{@operation_name}, " \ "tags=#{@tags}, " \ "logs=#{@logs}, " \ "start_time=#{@start_time}, " \ "end_time=#{@end_time}, " \ "context=#{@context})" end |
#tracer ⇒ Object
27 28 29 |
# File 'lib/signalfx_test_tracer/span.rb', line 27 def tracer @tracer end |