Skip to content

Commit

Permalink
[ML] Add explanation so far to file structure finder exceptions (#38337)
Browse files Browse the repository at this point in the history
The explanation so far can be invaluable for troubleshooting
as incorrect decisions made early on in the structure analysis
can result in seemingly crazy decisions or timeouts later on.

Relates elastic/kibana#29821
  • Loading branch information
droberts195 committed Feb 4, 2019
1 parent f5d1f04 commit f107ac6
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.unit.TimeValue;
Expand Down Expand Up @@ -148,6 +149,14 @@ public FileStructureFinder findFileStructure(List<String> explanation, int ideal
Math.max(MIN_SAMPLE_LINE_COUNT, idealSampleLineCount), timeoutChecker);

return makeBestStructureFinder(explanation, sampleInfo.v1(), charsetName, sampleInfo.v2(), overrides, timeoutChecker);
} catch (Exception e) {
// Add a dummy exception containing the explanation so far - this can be invaluable for troubleshooting as incorrect
// decisions made early on in the structure analysis can result in seemingly crazy decisions or timeouts later on
if (explanation.isEmpty() == false) {
e.addSuppressed(
new ElasticsearchException(explanation.stream().collect(Collectors.joining("]\n[", "Explanation so far:\n[", "]\n"))));
}
throw e;
}
}

Expand Down

0 comments on commit f107ac6

Please sign in to comment.