Search in sources :

Example 16 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SlimeTraceSerializerTest method assertSerialize.

private void assertSerialize(TraceNode root) {
    Slime slime = new Slime();
    SlimeTraceSerializer serializer = new SlimeTraceSerializer(slime.setObject());
    root.accept(serializer);
    SlimeTraceDeserializer deserializer = new SlimeTraceDeserializer(slime.get());
    TraceNode deser = deserializer.deserialize();
    assertTraceEqual(deser, root);
}
Also used : Slime(com.yahoo.slime.Slime) TraceNode(com.yahoo.yolean.trace.TraceNode)

Example 17 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SyncDefaultRenderer method queryContext.

public void queryContext(XMLWriter writer, QueryContext queryContext, Query owner) throws IOException {
    try {
        if (owner.getTraceLevel() != 0) {
            XMLWriter xmlWriter = XMLWriter.from(writer);
            xmlWriter.openTag("meta").attribute("type", QueryContext.ID);
            TraceNode traceRoot = owner.getModel().getExecution().trace().traceNode().root();
            traceRoot.accept(new RenderingVisitor(xmlWriter, owner.getStartTime()));
            xmlWriter.closeTag();
        }
    } catch (Exception e) {
        handleException(e);
    }
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) XMLWriter(com.yahoo.text.XMLWriter) IOException(java.io.IOException)

Example 18 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class JsonRendererTestCase method testTracingOfNodesWithBothChildrenAndData.

@Test
public final void testTracingOfNodesWithBothChildrenAndData() throws IOException, InterruptedException, ExecutionException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"fields\": {\n" + "            \"totalCount\": 0\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    },\n" + "    \"trace\": {\n" + "        \"children\": [\n" + "            {\n" + "                \"message\": \"No query profile is used\"\n" + "            },\n" + "            {\n" + "                \"children\": [\n" + "                    {\n" + "                        \"message\": \"string payload\",\n" + "                        \"children\": [" + "                            {\n" + "                                \"message\": \"leafnode\"" + "                            }\n" + "                        ]\n" + "                    },\n" + "                    {\n" + "                        \"message\": \"something\"\n" + "                    }\n" + "                ]\n" + "            }\n" + "        ]\n" + "    }\n" + "}\n";
    Query q = new Query("/?query=a&tracelevel=1");
    Execution execution = new Execution(Execution.Context.createContextStub());
    Result r = new Result(q);
    execution.search(q);
    final TraceNode child = new TraceNode("string payload", 0L);
    child.add(new TraceNode("leafnode", 0L));
    execution.trace().traceNode().add(child);
    q.trace("something", 1);
    String summary = render(execution, r);
    assertEqualJson(expected, summary);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) JSONString(com.yahoo.prelude.hitfield.JSONString) TraceNode(com.yahoo.yolean.trace.TraceNode) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 19 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class JsonRendererTestCase method testTracingOfNodesWithBothChildrenAndDataAndEmptySubnode.

@Test
public final void testTracingOfNodesWithBothChildrenAndDataAndEmptySubnode() throws IOException, InterruptedException, ExecutionException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"fields\": {\n" + "            \"totalCount\": 0\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    },\n" + "    \"trace\": {\n" + "        \"children\": [\n" + "            {\n" + "                \"message\": \"No query profile is used\"\n" + "            },\n" + "            {\n" + "                \"children\": [\n" + "                    {\n" + "                        \"message\": \"string payload\"\n" + "                    },\n" + "                    {\n" + "                        \"message\": \"something\"\n" + "                    }\n" + "                ]\n" + "            }\n" + "        ]\n" + "    }\n" + "}\n";
    Query q = new Query("/?query=a&tracelevel=1");
    Execution execution = new Execution(Execution.Context.createContextStub());
    Result r = new Result(q);
    execution.search(q);
    final TraceNode child = new TraceNode("string payload", 0L);
    child.add(new TraceNode(null, 0L));
    execution.trace().traceNode().add(child);
    q.trace("something", 1);
    String summary = render(execution, r);
    assertEqualJson(expected, summary);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) JSONString(com.yahoo.prelude.hitfield.JSONString) TraceNode(com.yahoo.yolean.trace.TraceNode) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

TraceNode (com.yahoo.yolean.trace.TraceNode)19 Test (org.junit.Test)11 Query (com.yahoo.search.Query)4 Result (com.yahoo.search.Result)4 JSONString (com.yahoo.prelude.hitfield.JSONString)3 Execution (com.yahoo.search.searchchain.Execution)3 XMLWriter (com.yahoo.text.XMLWriter)3 Trace (com.yahoo.processing.execution.Execution.Trace)1 DefaultRenderer (com.yahoo.search.rendering.DefaultRenderer)1 ArrayTraverser (com.yahoo.slime.ArrayTraverser)1 Cursor (com.yahoo.slime.Cursor)1 Inspector (com.yahoo.slime.Inspector)1 Slime (com.yahoo.slime.Slime)1 TraceVisitor (com.yahoo.yolean.trace.TraceVisitor)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1