class Span
A span which validates tag assignment.
Definitions
def initialize(context, name, resource, attributes)
Initialize a new span.
Signature
-
parameter
context
Context
The context in which the span is recorded.
-
parameter
name
String
A useful name/annotation for the recorded span.
-
parameter
resource
String
The "resource" that the span is associated with.
-
parameter
attributes
Hash
Metadata for the recorded span.
Implementation
def initialize(context, name, resource, attributes)
@context = context
@name = name
@resource = resource
@attributes = attributes
end
def []= key, value
Assign some metadata to the span.
Signature
-
parameter
key
String
The metadata key.
-
parameter
value
Object
The metadata value. Should be coercable to a string.
Implementation
def []= key, value
@attributes[key] = value
end
def as_json
Convert the span to a JSON representation.
Implementation
def as_json
{
name: @name,
resource: @resource,
attributes: @attributes,
context: @context.as_json
}
end
def to_json(...)
Convert the span to a JSON string.
Implementation
def to_json(...)
as_json.to_json(...)
end