Class: Traces::Backend::Capture::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/traces/backend/capture.rb

Overview

A span which validates tag assignment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, name, resource, attributes) ⇒ Span

Returns a new instance of Span.



20
21
22
23
24
25
# File 'lib/traces/backend/capture.rb', line 20

def initialize(context, name, resource, attributes)
	@context = context
	@name = name
	@resource = resource
	@attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



30
31
32
# File 'lib/traces/backend/capture.rb', line 30

def attributes
  @attributes
end

#contextObject (readonly)

Returns the value of attribute context.



27
28
29
# File 'lib/traces/backend/capture.rb', line 27

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/traces/backend/capture.rb', line 28

def name
  @name
end

#resourceObject (readonly)

Returns the value of attribute resource.



29
30
31
# File 'lib/traces/backend/capture.rb', line 29

def resource
  @resource
end

Instance Method Details

#[]=(key, value) ⇒ Object

Assign some metadata to the span.



35
36
37
# File 'lib/traces/backend/capture.rb', line 35

def []= key, value
	@attributes[key] = value
end

#as_jsonObject



39
40
41
42
43
44
45
46
# File 'lib/traces/backend/capture.rb', line 39

def as_json
	{
		name: @name,
		resource: @resource,
		attributes: @attributes,
		context: @context.as_json
	}
end

#to_jsonObject



48
49
50
# File 'lib/traces/backend/capture.rb', line 48

def to_json(...)
	as_json.to_json(...)
end