Browse Source

Log the time spent in each elasticsearch query.

pull/123/head
Severyn Kozak 10 years ago
parent
commit
51ed1507df
  1. 5
      service/mget.js
  2. 5
      service/search.js
  3. 5
      service/suggest.js

5
service/mget.js

@ -11,6 +11,9 @@
**/ **/
var peliasLogger = require( 'pelias-logger' ).get( 'service/mget' );
var microtime = require( 'microtime' );
function service( backend, query, cb ){ function service( backend, query, cb ){
// backend command // backend command
@ -20,8 +23,10 @@ function service( backend, query, cb ){
} }
}; };
var startTime = microtime.nowDouble();
// query new backend // query new backend
backend().client.mget( cmd, function( err, data ){ backend().client.mget( cmd, function( err, data ){
peliasLogger.verbose( 'time elasticsearch query took:', microtime.nowDouble() - startTime );
// handle backend errors // handle backend errors
if( err ){ return cb( err ); } if( err ){ return cb( err ); }

5
service/search.js

@ -5,10 +5,15 @@
**/ **/
var peliasLogger = require( 'pelias-logger' ).get( 'service/search' );
var microtime = require( 'microtime' );
function service( backend, cmd, cb ){ function service( backend, cmd, cb ){
var startTime = microtime.nowDouble();
// query new backend // query new backend
backend().client.search( cmd, function( err, data ){ backend().client.search( cmd, function( err, data ){
peliasLogger.verbose( 'time elasticsearch query took:', microtime.nowDouble() - startTime );
// handle backend errors // handle backend errors
if( err ){ return cb( err ); } if( err ){ return cb( err ); }

5
service/suggest.js

@ -4,10 +4,15 @@
cmd can be any valid ES suggest command cmd can be any valid ES suggest command
**/ **/
var peliasLogger = require( 'pelias-logger' ).get( 'service/suggest' );
var microtime = require( 'microtime' );
function service( backend, cmd, cb ){ function service( backend, cmd, cb ){
// query new backend // query new backend
var startTime = microtime.nowDouble();
backend().client.suggest( cmd, function( err, data ){ backend().client.suggest( cmd, function( err, data ){
peliasLogger.verbose( 'time elasticsearch query took:', microtime.nowDouble() - startTime );
// handle backend errors // handle backend errors
if( err ){ return cb( err ); } if( err ){ return cb( err ); }

Loading…
Cancel
Save