From 885a066cfdddfd8c0c1edb23c754171f0d6e0ed6 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 5 Mar 2019 11:41:12 +0000 Subject: Wire the trace object through. --- .../searchcore/proton/matchengine/matchengine.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp index 8fcb30a4143..0cb50fb00b0 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp @@ -2,9 +2,12 @@ #include "matchengine.h" #include #include -#include +#include +#include +#include #include + LOG_SETUP(".proton.matchengine.matchengine"); namespace { @@ -113,9 +116,9 @@ void MatchEngine::performSearch(search::engine::SearchRequest::Source req, search::engine::SearchClient &client) { - search::engine::SearchReply::UP ret(new search::engine::SearchReply); + auto ret = std::make_unique(); - if (req.get() != NULL) { + if (req.get()) { ISearchHandler::SP searchHandler; vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain(); { // try to find the match handler corresponding to the specified search doc type @@ -123,7 +126,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, DocTypeName docTypeName(*req.get()); searchHandler = _handlers.getHandler(docTypeName); } - if (searchHandler.get() != NULL) { + if (searchHandler) { ret = searchHandler->match(searchHandler, *req.get(), *threadBundle); } else { HandlerMap::Snapshot::UP snapshot; @@ -140,6 +143,14 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, } ret->request = req.release(); ret->setDistributionKey(_distributionKey); + if (ret->request->getTraceLevel() > 0) { + vespalib::asciistream os; + os << "trace-" << _distributionKey; + search::fef::Properties & trace = ret->propertiesMap.lookupCreate(os.str()); + vespalib::SmartBuffer output(4096); + vespalib::slime::BinaryFormat::encode(ret->request->trace().getRoot(), output); + trace.add("slime", output.obtain().make_stringref()); + } client.searchDone(std::move(ret)); } -- cgit v1.2.3