class Traces::Context

def self.parse(parent, state = nil, **options)

@parameter state [Array(String)] Any attached trace state.
@parameter parent [String] The parent trace context.
Parse a string representation of a distributed trace.
def self.parse(parent, state = nil, **options)
	version, trace_id, parent_id, flags = parent.split('-')
	
	if version == '00'
		flags = Integer(flags, 16)
		
		if state.is_a?(String)
			state = state.split(',')
		end
		
		if state
			state = state.map{|item| item.split('=')}.to_h
		end
		
		self.new(trace_id, parent_id, flags, state, **options)
	end
end