Home

Awesome

feathers-profiler

Greenkeeper badge

Build Status Code Climate Test Coverage Dependency Status Download Status

Log service method calls and gather profile information on them.

Installation

npm install feathers-profiler --save

Example

npm start

Documentation

Service calls transported by websockets are not passed through Express middleware. feathers-profiler logs service calls from all transports and gathers performance information on them.

import { profiler, getProfile, clearProfile, getPending, timestamp } from 'feathers-profiler';

app.configure(profiler(options))

Start logging and/or profiling service calls.

Options:

getProfile()

Returns profile information as an object.

clearProfile()

Re-initializes the profile information. The profile internal counts may not add up perfectly unless getPending() === 0.

getPending()

Returns the number of currently pending service calls.

timestamp()

Returns a timestamp suitable for logging to the console.

Example

const feathers = require('feathers');
const rest = require('feathers-rest');
const sockets = require('feathers-socketio');
const hooks = require('feathers-hooks');
const bodyParser = require('body-parser');
const errorHandler = require('feathers-errors/handler');

const { profiler, getProfile, getPending }  = require('feathers-profiler');

// Initialize the application
const app = feathers()
  .configure(rest())
  .configure(sockets())
  .configure(hooks())
  .use(bodyParser.json()) // Needed for parsing bodies (login)
  .use(bodyParser.urlencoded({ extended: true }))
  .use('users', { ...}) // services
  .use('messages', { ... })
  .configure(profiler({ stats: 'detail' }) // must be configured after all services
  .use(errorHandler());
  
  // ... once multiple service calls have been made
  console.log('pending', getPending());
  console.log(require('util').inspect(getProfile(), {
    depth: 5,
    colors: true
  }));

Usage

Logs service calls

The log message may be customized. The default log message includes:

logs

Gathers profile information on service calls

Profile information is:

stats

License

Copyright (c) 2016

Licensed under the MIT license.