npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

feathers-profiler

v0.1.5

Published

Log feathers service calls and gather profile information on them.

Downloads

1,256

Readme

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:

  • logger
    • defaults to logging on console.log.
    • null disables logging.
    • require('winston') routes logs to the popular winston logger.
    • { log: payload => {} } routes logs to your customized logger.
  • logMsg
    • default message is shown below.
    • hook => {} returns a custom string or object payload for the logger. hook._log contains log information; hook.original and hook.error contain error information.
  • stats
    • null or 'none' profile information will not be gathered.
    • total gathers profile information by service and method only. The default.
    • detail gathers profile information by characteristics of the call.
  • statsDetail
    • default is shown below.
    • hook => {} returns a custom category for the call.

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:

  • Service name, method and transport provider.
  • Elapsed time between the method being called and its completion.
  • Number of service calls pending when call was made.
  • Where service call failed and why.

logs

Gathers profile information on service calls

Profile information is:

  • Grouped by service and method.
  • Grouped by characteristics of the call. These may be customized.
  • Average pending count provides information on how busy the server was during these calls.
  • Average, min and max elapsed time provide information on how responsive the server is.
  • The number of returned items provides information on how large the find results were.

stats

License

Copyright (c) 2016

Licensed under the MIT license.