Class: Traces::Backend::Capture::Span
- Inherits:
-
Object
- Object
- Traces::Backend::Capture::Span
- Defined in:
- lib/traces/backend/capture.rb
Overview
A span which validates tag assignment.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
Assign some metadata to the span.
-
#as_json ⇒ Object
Convert the span to a JSON representation.
-
#initialize(context, name, attributes) ⇒ Span
constructor
Initialize a new span.
-
#to_json ⇒ Object
Convert the span to a JSON string.
Constructor Details
#initialize(context, name, attributes) ⇒ Span
Initialize a new span.
23 24 25 26 27 |
# File 'lib/traces/backend/capture.rb', line 23 def initialize(context, name, attributes) @context = context @name = name @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
31 32 33 |
# File 'lib/traces/backend/capture.rb', line 31 def attributes @attributes end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
29 30 31 |
# File 'lib/traces/backend/capture.rb', line 29 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/traces/backend/capture.rb', line 30 def name @name end |
Instance Method Details
#[]=(key, value) ⇒ Object
Assign some metadata to the span.
36 37 38 |
# File 'lib/traces/backend/capture.rb', line 36 def []= key, value @attributes[key] = value end |
#as_json ⇒ Object
Convert the span to a JSON representation.
41 42 43 44 45 46 47 |
# File 'lib/traces/backend/capture.rb', line 41 def as_json { name: @name, attributes: @attributes, context: @context.as_json } end |
#to_json ⇒ Object
Convert the span to a JSON string.
50 51 52 |
# File 'lib/traces/backend/capture.rb', line 50 def to_json(...) as_json.to_json(...) end |