validate_span!

in spec/support/mock_intake.rb [159:188]


  def validate_span!(span)
    type, subtype, _action = span['type'].split('.')

    begin
      info = @span_types.fetch(type)
    rescue KeyError
      puts "Unknown span.type `#{type}'\nPossible types: #{@span_types.keys.join(', ')}"
      pp span
      raise
    end

    return unless (allowed_subtypes = info['subtypes'])

    if !info['optional_subtype'] && !subtype
      msg = "span.subtype missing when required for type `#{type}',\n" \
        "Possible subtypes: #{allowed_subtypes}"
      puts msg 
      pp span
      raise msg
    end

    allowed_subtypes.fetch(subtype)
  rescue KeyError => e
    puts "Unknown span.subtype `#{subtype.inspect}'\n" \
      "Possible subtypes: #{allowed_subtypes}"
    pp span
    puts e 
    raise
  end