Class: Zipkin::Span
- Inherits:
-
Object
- Object
- Zipkin::Span
- Defined in:
- lib/zipkin/span.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#operation_name ⇒ Object
Returns the value of attribute operation_name.
-
#references ⇒ Object
readonly
Returns the value of attribute references.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#finish(end_time: Time.now) ⇒ Object
Finish the Span.
-
#get_baggage_item(key) ⇒ Object
Get a baggage item.
-
#initialize(context, operation_name, collector, start_time: Time.now, tags: {}, references: nil) ⇒ Span
constructor
Creates a new 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.
Constructor Details
#initialize(context, operation_name, collector, start_time: Time.now, tags: {}, references: nil) ⇒ Span
Creates a new Zipkin::Span
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zipkin/span.rb', line 16 def initialize( context, operation_name, collector, start_time: Time.now, tags: {}, references: nil ) @context = context @operation_name = operation_name @collector = collector @start_time = start_time @tags = @logs = [] @references = references end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/zipkin/span.rb', line 7 def context @context end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
7 8 9 |
# File 'lib/zipkin/span.rb', line 7 def logs @logs end |
#operation_name ⇒ Object
Returns the value of attribute operation_name.
5 6 7 |
# File 'lib/zipkin/span.rb', line 5 def operation_name @operation_name end |
#references ⇒ Object (readonly)
Returns the value of attribute references.
7 8 9 |
# File 'lib/zipkin/span.rb', line 7 def references @references end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/zipkin/span.rb', line 7 def start_time @start_time end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
7 8 9 |
# File 'lib/zipkin/span.rb', line 7 def @tags end |
Instance Method Details
#finish(end_time: Time.now) ⇒ Object
Finish the Zipkin::Span
80 81 82 |
# File 'lib/zipkin/span.rb', line 80 def finish(end_time: Time.now) @collector.send_span(self, end_time) end |
#get_baggage_item(key) ⇒ Object
Get a baggage item
56 57 58 |
# File 'lib/zipkin/span.rb', line 56 def get_baggage_item(key) nil end |
#log(*args) ⇒ Object
Use #log_kv instead.
Add a log entry to this span
63 64 65 66 |
# File 'lib/zipkin/span.rb', line 63 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
72 73 74 75 |
# File 'lib/zipkin/span.rb', line 72 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
47 48 49 |
# File 'lib/zipkin/span.rb', line 47 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
38 39 40 41 |
# File 'lib/zipkin/span.rb', line 38 def set_tag(key, value) sanitized_value = valid_tag_value?(value) ? value : value.to_s @tags = @tags.merge(key.to_sym => sanitized_value) end |