Class: Jaeger::Span
- Inherits:
-
Object
- Object
- Jaeger::Span
- Defined in:
- lib/jaeger/span.rb,
lib/jaeger/span/thrift_log_builder.rb,
lib/jaeger/span/thrift_tag_builder.rb
Defined Under Namespace
Classes: ThriftLogBuilder, ThriftTagBuilder
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#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, reporter, start_time: Time.now, references: [], tags: {}) ⇒ 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, reporter, start_time: Time.now, references: [], tags: {}) ⇒ Span
Creates a new Jaeger::Span
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jaeger/span.rb', line 19 def initialize(context, operation_name, reporter, start_time: Time.now, references: [], tags: {}) @context = context @operation_name = operation_name @reporter = reporter @start_time = start_time @references = references @tags = [] @logs = [] .each { |key, value| set_tag(key, value) } end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def context @context end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def end_time @end_time end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def logs @logs end |
#operation_name ⇒ Object
Returns the value of attribute operation_name.
8 9 10 |
# File 'lib/jaeger/span.rb', line 8 def operation_name @operation_name end |
#references ⇒ Object (readonly)
Returns the value of attribute references.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def references @references end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def start_time @start_time end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
10 11 12 |
# File 'lib/jaeger/span.rb', line 10 def @tags end |
Instance Method Details
#finish(end_time: Time.now) ⇒ Object
Finish the Jaeger::Span
93 94 95 96 |
# File 'lib/jaeger/span.rb', line 93 def finish(end_time: Time.now) @end_time = end_time @reporter.report(self) end |
#get_baggage_item(key) ⇒ Object
Get a baggage item
68 69 70 |
# File 'lib/jaeger/span.rb', line 68 def get_baggage_item(key) @context.get_baggage_item(key) end |
#log(*args) ⇒ Object
Use #log_kv instead.
Add a log entry to this span
75 76 77 78 |
# File 'lib/jaeger/span.rb', line 75 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
84 85 86 87 88 |
# File 'lib/jaeger/span.rb', line 84 def log_kv(timestamp: Time.now, **fields) # Using Thrift::Log to avoid unnecessary memory allocations @logs << ThriftLogBuilder.build(, fields) nil end |
#set_baggage_item(key, value) ⇒ Object
Set a baggage item on the span
58 59 60 61 |
# File 'lib/jaeger/span.rb', line 58 def set_baggage_item(key, value) @context.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 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jaeger/span.rb', line 36 def set_tag(key, value) if key == 'sampling.priority' if value.to_i > 0 return self if @context.debug? @context.flags = @context.flags | SpanContext::Flags::SAMPLED | SpanContext::Flags::DEBUG else @context.flags = @context.flags & ~SpanContext::Flags::SAMPLED end return self end # Using Thrift::Tag to avoid unnecessary memory allocations @tags << ThriftTagBuilder.build(key, value) self end |