Class: Traces::Backend::Test::Span

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

Overview

A span which validates tag assignment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Span

Returns a new instance of Span.



19
20
21
# File 'lib/traces/backend/test.rb', line 19

def initialize(context)
	@context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



23
24
25
# File 'lib/traces/backend/test.rb', line 23

def context
  @context
end

Instance Method Details

#[]=(key, value) ⇒ Object

Assign some metadata to the span.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/traces/backend/test.rb', line 28

def []= key, value
	unless key.is_a?(String) || key.is_a?(Symbol)
		raise ArgumentError, "Invalid attribute key (must be String or Symbol): #{key.inspect}!"
	end
	
	begin
		String(value)
	rescue
		raise ArgumentError, "Invalid attribute value (must be convertible to String): #{value.inspect}!"
	end
end