Class: Watchforge::Span
- Inherits:
-
Object
- Object
- Watchforge::Span
- Defined in:
- lib/watchforge/tracing.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
-
#finish_timestamp ⇒ Object
Returns the value of attribute finish_timestamp.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#parent_span_id ⇒ Object
readonly
Returns the value of attribute parent_span_id.
-
#span_id ⇒ Object
readonly
Returns the value of attribute span_id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #finish(status = "ok", status_code: nil) ⇒ Object
-
#initialize(op, description = "", parent_span_id: nil, data: nil) ⇒ Span
constructor
A new instance of Span.
- #to_h ⇒ Object
Constructor Details
#initialize(op, description = "", parent_span_id: nil, data: nil) ⇒ Span
Returns a new instance of Span.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/watchforge/tracing.rb', line 11 def initialize(op, description = "", parent_span_id: nil, data: nil) @span_id = SecureRandom.uuid @op = op @description = description @parent_span_id = parent_span_id @data = data || {} @tags = {} @start_timestamp = (Time.now.to_f * 1000).to_i @status = "ok" end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def data @data end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def description @description end |
#duration_ms ⇒ Object
Returns the value of attribute duration_ms.
9 10 11 |
# File 'lib/watchforge/tracing.rb', line 9 def duration_ms @duration_ms end |
#finish_timestamp ⇒ Object
Returns the value of attribute finish_timestamp.
9 10 11 |
# File 'lib/watchforge/tracing.rb', line 9 def @finish_timestamp end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def op @op end |
#parent_span_id ⇒ Object (readonly)
Returns the value of attribute parent_span_id.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def parent_span_id @parent_span_id end |
#span_id ⇒ Object (readonly)
Returns the value of attribute span_id.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def span_id @span_id end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/watchforge/tracing.rb', line 9 def status @status end |
#status_code ⇒ Object
Returns the value of attribute status_code.
9 10 11 |
# File 'lib/watchforge/tracing.rb', line 9 def status_code @status_code end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
8 9 10 |
# File 'lib/watchforge/tracing.rb', line 8 def @tags end |
Instance Method Details
#finish(status = "ok", status_code: nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/watchforge/tracing.rb', line 22 def finish(status = "ok", status_code: nil) @status = status @status_code = status_code @finish_timestamp = (Time.now.to_f * 1000).to_i @duration_ms = @finish_timestamp - @start_timestamp end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/watchforge/tracing.rb', line 29 def to_h { span_id: span_id, parent_span_id: parent_span_id, op: op, description: description, start_timestamp: Time.at(@start_timestamp / 1000.0).utc.iso8601, finish_timestamp: ? Time.at( / 1000.0).utc.iso8601 : nil, duration_ms: duration_ms, status: status, status_code: status_code, data: data, tags: , timestamp: Time.at(@start_timestamp / 1000.0).utc.iso8601 } end |