use of org.opengrok.indexer.web.SearchHelper in project OpenGrok by OpenGrok.
the class StatisticsFilter method measure.
private void measure(HttpServletResponse httpResponse, HttpServletRequest httpReq, Duration duration, PageConfig config) {
String category;
category = getCategory(httpReq, config);
Timer categoryTimer = Timer.builder("requests.latency").tags("category", category, "code", String.valueOf(httpResponse.getStatus())).register(Metrics.getPrometheusRegistry());
categoryTimer.record(duration);
SearchHelper helper = (SearchHelper) config.getRequestAttribute(SearchHelper.REQUEST_ATTR);
MeterRegistry registry = Metrics.getRegistry();
if (helper != null && registry != null) {
if (helper.getHits() == null || helper.getHits().length == 0) {
Timer.builder("search.latency").tags("category", "ui", "outcome", "empty").register(registry).record(duration);
} else {
Timer.builder("search.latency").tags("category", "ui", "outcome", "success").register(registry).record(duration);
}
}
}
use of org.opengrok.indexer.web.SearchHelper in project OpenGrok by OpenGrok.
the class PageConfig method prepareSearch.
/**
* Prepare a search helper with all required information, ready to execute
* the query implied by the related request parameters and cookies.
* <p>
* NOTE: One should check the {@link SearchHelper#getErrorMsg()} as well as
* {@link SearchHelper#getRedirect()} and take the appropriate action before
* executing the prepared query or continue processing.
* <p>
* This method stops populating fields as soon as an error occurs.
*
* @return a search helper.
*/
public SearchHelper prepareSearch() {
List<SortOrder> sortOrders = getSortOrder();
SearchHelper sh = prepareInternalSearch(sortOrders.isEmpty() ? SortOrder.RELEVANCY : sortOrders.get(0));
if (getRequestedProjects().isEmpty() && getEnv().hasProjects()) {
sh.setErrorMsg("You must select a project!");
return sh;
}
if (sh.getBuilder().getSize() == 0) {
// Entry page show the map
sh.setRedirect(req.getContextPath() + '/');
return sh;
}
return sh;
}
use of org.opengrok.indexer.web.SearchHelper in project OpenGrok by OpenGrok.
the class WebappListener method requestDestroyed.
/**
* {@inheritDoc}
*/
@Override
public void requestDestroyed(ServletRequestEvent e) {
PageConfig.cleanup(e.getServletRequest());
SearchHelper sh = (SearchHelper) e.getServletRequest().getAttribute(SearchHelper.REQUEST_ATTR);
if (sh != null) {
sh.destroy();
}
AnalyzerGuru.returnAnalyzers();
}
Aggregations