Class: MetrixWire::Span
- Inherits:
-
Object
- Object
- MetrixWire::Span
- Defined in:
- lib/metrixwire/span.rb
Overview
A single unit of work within a trace (db_query | http_call | custom). Users never build these by hand — instrumentation creates them.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, description:, started_at:, duration_ms:, source_location: nil, meta: nil) ⇒ Span
constructor
A new instance of Span.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, description:, started_at:, duration_ms:, source_location: nil, meta: nil) ⇒ Span
Returns a new instance of Span.
12 13 14 15 16 17 18 19 |
# File 'lib/metrixwire/span.rb', line 12 def initialize(type:, description:, started_at:, duration_ms:, source_location: nil, meta: nil) @type = type @description = description @started_at = started_at @duration_ms = duration_ms @source_location = source_location @meta = end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def description @description end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def duration_ms @duration_ms end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def @meta end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def source_location @source_location end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def started_at @started_at end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/metrixwire/span.rb', line 7 def type @type end |
Instance Method Details
#to_h ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/metrixwire/span.rb', line 21 def to_h out = { type: @type, description: @description, startedAt: @started_at, durationMs: @duration_ms } out[:sourceLocation] = @source_location if @source_location out[:meta] = @meta if @meta && !@meta.empty? out end |