Browse Source

feat(debug): debugging info for interpolation service

pull/1128/merge
Peter Johnson 6 years ago
parent
commit
fa8257cd06
  1. 6
      middleware/interpolate.js
  2. 8
      service/configurations/Interpolation.js

6
middleware/interpolate.js

@ -3,6 +3,8 @@ const logger = require( 'pelias-logger' ).get( 'api' );
const source_mapping = require('../helper/type_mapping').source_mapping;
const _ = require('lodash');
const stable = require('stable');
const Debug = require('../helper/debug');
const debugLog = new Debug('middleware:interpolate');
/**
example response from interpolation web service:
@ -57,6 +59,7 @@ function setup(service, should_execute) {
// perform interpolations asynchronously for all relevant hits
const start = (new Date()).getTime();
const initialTime = debugLog.beginTimer(req);
logger.info(`[interpolation] [street_results] count=${street_results.length}`);
@ -71,12 +74,14 @@ function setup(service, should_execute) {
// note: leave this hit unmodified
if (!_.has(interpolation_result, 'properties')) {
logger.debug(`[interpolation] [miss] ${req.clean.parsed_text}`);
debugLog.push(req, 'miss');
return;
}
// the interpolation service returned a valid result, debug log for posterity
// note: we now merge those values with the existing 'street' record
logger.debug(`[interpolation] [hit] ${req.clean.parsed_text} ${JSON.stringify(interpolation_result)}`);
debugLog.push(req, interpolation_result);
// -- metadata --
source_result.layer = 'address';
@ -126,6 +131,7 @@ function setup(service, should_execute) {
// log the execution time, continue
logger.info( `[interpolation] [took] ${(new Date()).getTime() - start} ms`);
debugLog.stopTimer(req, initialTime);
next();
});

8
service/configurations/Interpolation.js

@ -1,6 +1,7 @@
const url = require('url');
const _ = require('lodash');
const Debug = require('../../helper/debug');
const debugLog = new Debug('interpolation:request');
const ServiceConfiguration = require('pelias-microservice-wrapper').ServiceConfiguration;
@ -10,13 +11,16 @@ class Language extends ServiceConfiguration {
}
getParameters(req, hit) {
return {
let params = {
number: req.clean.parsed_text.number,
street: hit.address_parts.street || req.clean.parsed_text.street,
lat: hit.center_point.lat,
lon: hit.center_point.lon
};
debugLog.push(req, params);
return params;
}
getUrl(req) {

Loading…
Cancel
Save