Skip to content

Commit

Permalink
additional log output: selected query parameters (#304)
Browse files Browse the repository at this point in the history
* log query filter
* log query boundary bbox
* log boundary type
* log query boundary area (in km²)
* log query time parameter
  • Loading branch information
tyrasd authored Aug 31, 2023
1 parent 44c01dc commit b768e4b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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[] { "<none>" })[0]);
logger.info("query time: "
+ request.getParameterMap().getOrDefault("time", new String[] { "<none>" })[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: <error while processing request params>");
}
logger.info("processing time: " + (System.currentTimeMillis() - startTime));
logger.info("response code: " + response.getStatus());
}
Expand Down

0 comments on commit b768e4b

Please sign in to comment.