presto-main/src/main/java/io/prestosql/dispatcher/FailedDispatchQueryFactory.java/FailedDispatchQueryFactory/createFailedDispatchQuery
class FailedDispatchQueryFactory:    public FailedDispatchQuery createFailedDispatchQuery(Session session, String query, Optional<String> preparedQuery, Optional<ResourceGroupId> resourceGroup, Throwable throwable)
    {
        FailedDispatchQuery failedDispatchQuery = new FailedDispatchQuery(
                session,
                query,
                preparedQuery,
                locationFactory.createQueryLocation(session.getQueryId()),
                resourceGroup,
                throwable,
                executor);

        BasicQueryInfo queryInfo = failedDispatchQuery.getBasicQueryInfo();

        queryMonitor.queryCreatedEvent(queryInfo);
        queryMonitor.queryImmediateFailureEvent(queryInfo, toFailure(throwable));

        return failedDispatchQuery;
    }