From b768e4bfb7a781ba406137cc40515594e0f04a1b Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 31 Aug 2023 18:13:45 +0200 Subject: [PATCH] additional log output: selected query parameters (#304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * log query filter * log query boundary bbox * log boundary type * log query boundary area (in kmĀ²) * log query time parameter --- CHANGELOG.md | 4 ++++ .../LoggingRequestInterceptor.java | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f1d7331..729e99771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Changelog ### Bug Fixes * Fix bug which prevented some filters (which only work on ContributionView-based queries) to correctly work in contribution extraction endpoints ([#305]) +### Other +* Add additional query metrics to log output: the used `filter`, `time` and some stats about the boundary parameter (type, bounding box and area) ([#304]) + +[#304]: https://github.com/GIScience/ohsome-api/pull/304 [#305]: https://github.com/GIScience/ohsome-api/issues/305 diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/interceptor/LoggingRequestInterceptor.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/interceptor/LoggingRequestInterceptor.java index a350fa6c7..7fca8997c 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/interceptor/LoggingRequestInterceptor.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/interceptor/LoggingRequestInterceptor.java @@ -3,6 +3,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.heigit.ohsome.ohsomeapi.Application; +import org.heigit.ohsome.ohsomeapi.inputprocessing.InputProcessor; +import org.heigit.ohsome.oshdb.util.geometry.Geo; +import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -31,6 +34,23 @@ public void afterCompletion(HttpServletRequest request, HttpServletResponse resp requestUri = request.getRequestURL().toString(); } logger.info("accessed URI: " + requestUri); + logger.info("query filter: " + + request.getParameterMap().getOrDefault("filter", new String[] { "" })[0]); + logger.info("query time: " + + request.getParameterMap().getOrDefault("time", new String[] { "" })[0]); + try { + var inputProcessor = new InputProcessor(request, false, false); + inputProcessor.processParameters(); + var boundary = inputProcessor.getGeometry(); + var envelope = boundary.getEnvelopeInternal(); + var bbox = OSHDBGeometryBuilder.boundingBoxOf(envelope); + logger.info("query boundary type: " + + inputProcessor.getProcessingData().getBoundaryType().toString()); + logger.info("query boundary bbox: " + bbox.toString()); + logger.info("query boundary area: " + String.format("%.2f", Geo.areaOf(boundary) / 1E6)); + } catch (Exception e) { + logger.info("query boundary: "); + } logger.info("processing time: " + (System.currentTimeMillis() - startTime)); logger.info("response code: " + response.getStatus()); }