Search in sources :

Example 1 with SearchHelper

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);
        }
    }
}
Also used : Timer(io.micrometer.core.instrument.Timer) SearchHelper(org.opengrok.indexer.web.SearchHelper) MeterRegistry(io.micrometer.core.instrument.MeterRegistry)

Example 2 with SearchHelper

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;
}
Also used : SortOrder(org.opengrok.indexer.web.SortOrder) SearchHelper(org.opengrok.indexer.web.SearchHelper)

Example 3 with SearchHelper

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();
}
Also used : SearchHelper(org.opengrok.indexer.web.SearchHelper)

Aggregations

SearchHelper (org.opengrok.indexer.web.SearchHelper)3 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 Timer (io.micrometer.core.instrument.Timer)1 SortOrder (org.opengrok.indexer.web.SortOrder)1