From e40266d8358ead5c29b7617a1399b9290935c3e4 Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Tue, 17 Dec 2024 09:12:50 +0000 Subject: [PATCH] tag start/end events --- .../searchcore/proton/matchengine/matchengine.cpp | 7 +++++-- searchlib/src/vespa/searchlib/engine/trace.cpp | 10 ++++++++++ searchlib/src/vespa/searchlib/engine/trace.h | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp index 55cc84107f16..97c94926f238 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp @@ -138,7 +138,9 @@ MatchEngine::doSearch(const SearchRequest & searchRequest) { searchRequest.maxhits, searchRequest.offset, searchRequest.sortSpec.empty() ? "" : " (with sorting)", - searchRequest.groupSpec.empty() ? "" : " (with grouping)")); + searchRequest.groupSpec.empty() ? "" : " (with grouping)"), + "query_start"); + ISearchHandler::SP searchHandler; auto threadBundle = _threadBundlePool.getBundle(); { // try to find the match handler corresponding to the specified search doc type @@ -164,7 +166,8 @@ MatchEngine::doSearch(const SearchRequest & searchRequest) { } searchRequest.trace().addEvent(4, vespalib::make_string("returning %zu hits from total %" PRIu64, - ret->hits.size(), ret->totalHitCount)); + ret->hits.size(), ret->totalHitCount), + "query_reply"); return ret; } diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index 134245fb2c0f..8d3ecd2980ce 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -126,6 +126,16 @@ Trace::addEvent(uint32_t level, std::string_view event) { trace.setString("event", event); } +void +Trace::addEvent(uint32_t level, std::string_view event, std::string_view tag) { + if (!shouldTrace(level)) { return; } + + Cursor & trace = traces().addObject(); + addTimeStamp(trace); + trace.setString("event", event); + trace.setString("tag", tag); +} + void Trace::addTimeStamp(Cursor & trace) { trace.setDouble("timestamp_ms", vespalib::count_ns(_relativeTime.timeSinceDawn())/1000000.0); diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h index 6a2ab148fc99..6c88731d5d64 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.h +++ b/searchlib/src/vespa/searchlib/engine/trace.h @@ -101,6 +101,11 @@ class Trace */ void addEvent(uint32_t level, std::string_view event); + /** + * Will add an 'event' string, with timestamp and tag + */ + void addEvent(uint32_t level, std::string_view event, std::string_view tag); + /** * Will compute and and a final duration timing. */