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, instance, name, resource, attributes) ⇒ Span



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

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



32
33
34
# File 'lib/traces/backend/capture.rb', line 32

def attributes
  @attributes
end

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#instanceObject (readonly)

Returns the value of attribute instance.



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

def instance
  @instance
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#resourceObject (readonly)

Returns the value of attribute resource.



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

def resource
  @resource
end

Instance Method Details

#[]=(key, value) ⇒ Object

Assign some metadata to the span.



37
38
39
# File 'lib/traces/backend/capture.rb', line 37

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

#as_jsonObject



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

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

#to_jsonObject



50
51
52
# File 'lib/traces/backend/capture.rb', line 50

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