aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-05 11:41:12 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-03-05 12:17:04 +0000
commit885a066cfdddfd8c0c1edb23c754171f0d6e0ed6 (patch)
tree6360e1f7e5309b18e499b7a3068999a96b38147e
parent4ca57c3bc062bda152157a9286210509f9987af4 (diff)
Wire the trace object through.
-rw-r--r--searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp19
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.h5
3 files changed, 22 insertions, 5 deletions
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 <vespa/searchcore/proton/common/state_reporter_utils.h>
#include <vespa/vespalib/data/slime/cursor.h>
-#include <algorithm>
+#include <vespa/vespalib/data/smart_buffer.h>
+#include <vespa/vespalib/data/slime/binary_format.h>
+#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/log/log.h>
+
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<search::engine::SearchReply>();
- 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<ISearchHandler>::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));
}
diff --git a/searchlib/src/vespa/searchlib/engine/request.cpp b/searchlib/src/vespa/searchlib/engine/request.cpp
index 28cbbae64b8..fd4a46ccc43 100644
--- a/searchlib/src/vespa/searchlib/engine/request.cpp
+++ b/searchlib/src/vespa/searchlib/engine/request.cpp
@@ -14,7 +14,8 @@ Request::Request(const fastos::TimeStamp &start_time)
location(),
propertiesMap(),
stackItems(0),
- stackDump()
+ stackDump(),
+ _trace(start_time)
{
}
diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h
index 58c71cd8458..21087d4eff0 100644
--- a/searchlib/src/vespa/searchlib/engine/request.h
+++ b/searchlib/src/vespa/searchlib/engine/request.h
@@ -12,6 +12,8 @@ class Request
{
public:
Request(const fastos::TimeStamp &start_time);
+ Request(const Request &) = delete;
+ Request & operator =(const Request &) = delete;
virtual ~Request();
void setTimeout(const fastos::TimeStamp & timeout);
fastos::TimeStamp getStartTime() const { return _startTime; }
@@ -30,6 +32,7 @@ public:
uint32_t getTraceLevel() const { return _traceLevel; }
Request & setTraceLevel(uint32_t traceLevel) { _traceLevel = traceLevel; return *this; }
+ Trace & trace() { return _trace; }
private:
const fastos::TimeStamp _startTime;
fastos::TimeStamp _timeOfDoom;
@@ -42,6 +45,8 @@ public:
PropertiesMap propertiesMap;
uint32_t stackItems;
std::vector<char> stackDump;
+private:
+ mutable Trace _trace;
};
}