Skip to content

Commit

Permalink
Merge pull request #33046 from vespa-engine/arnej/add-tag-to-event
Browse files Browse the repository at this point in the history
tag start/end events
  • Loading branch information
geirst authored Dec 17, 2024
2 parents 4f339ac + e40266d commit 70128c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions searchlib/src/vespa/searchlib/engine/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions searchlib/src/vespa/searchlib/engine/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 70128c0

Please sign in to comment.