Class: Logasm::Tracer::Span
- Inherits:
-
Object
- Object
- Logasm::Tracer::Span
- Defined in:
- lib/logasm/tracer/span.rb
Overview
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
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, logger, start_time: Time.now, tags: {}) ⇒ Span
constructor
A new instance of Span.
-
#log(event: nil, 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_h ⇒ Object
deprecated
Deprecated.
This is not in OpenTracing API. It will be removed soon.
Constructor Details
#initialize(context, operation_name, logger, start_time: Time.now, tags: {}) ⇒ Span
7 8 9 10 11 12 13 14 |
# File 'lib/logasm/tracer/span.rb', line 7 def initialize(context, operation_name, logger, start_time: Time.now, tags: {}) @context = context @operation_name = operation_name @logger = logger @start_time = start_time @tags = @logger.info "Span [#{@operation_name}] started", trace_information end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/logasm/tracer/span.rb', line 5 def context @context end |
Instance Method Details
#finish(end_time: Time.now) ⇒ Object
Finish the Logasm::Tracer::Span
54 55 56 57 58 |
# File 'lib/logasm/tracer/span.rb', line 54 def finish(end_time: Time.now) @logger.info "Span [#{@operation_name}] finished", trace_information( execution_time: end_time - @start_time ) end |
#get_baggage_item(key) ⇒ Object
Get a baggage item
38 39 40 |
# File 'lib/logasm/tracer/span.rb', line 38 def get_baggage_item(key) nil end |
#log(event: nil, timestamp: Time.now, **fields) ⇒ Object
Add a log entry to this span
47 48 49 |
# File 'lib/logasm/tracer/span.rb', line 47 def log(event: nil, timestamp: Time.now, **fields) @logger.info "Span [#{@operation_name}] #{event}", trace_information.merge(fields) end |
#set_baggage_item(key, value) ⇒ Object
Set a baggage item on the span
29 30 31 |
# File 'lib/logasm/tracer/span.rb', line 29 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
21 22 23 |
# File 'lib/logasm/tracer/span.rb', line 21 def set_tag(key, value) @tags = @tags.merge(key => value) end |
#to_h ⇒ Object
Deprecated.
This is not in OpenTracing API. It will be removed soon.
61 62 63 |
# File 'lib/logasm/tracer/span.rb', line 61 def to_h trace_information end |