public void attachContext(Query query) throws IllegalStateException {
        query.getTrace().setLevel(getTrace().getLevel());
        query.getTrace().setExplainLevel(getTrace().getExplainLevel());
        query.getTrace().setProfileDepth(getTrace().getProfileDepth());
        if (context == null) return;
        if (query.getContext(false) != null) {
            // If we added the other query's context info as a subnode in this
            // query's context tree, we would have to check for loops in the
            // context graph. If we simply created a new node without checking,
            // we might silently overwrite useful information.
            throw new IllegalStateException("Query to attach already has context information stored");
        }
        query.context = context;
    }
Set the context information for another query to be part of this query's
context information. This is to be used if creating fresh query objects as
part of a plug-in's execution. The query should be attached before it is
used, in case an exception causes premature termination. This is enforced
by an IllegalStateException. In other words, intended use is create the
new query, and attach the context to the invoking query as soon as the new
query is properly initialized.
<p>
This method will always set the argument query's context level to the context
level of this query.

@param query the query which should be traced as a part of this query
@throws IllegalStateException if the query given as argument already has context information
container-search/src/main/java/com/yahoo/search/Query.java