egg-instrument

2.0.0 • Public • Published

egg-instrument

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Compute the duration of an operation in local environment.

Install

$ npm i egg-instrument --save

Usage

// {app_root}/config/plugin.js
exports.instrument = {
  enable: true,
  package: 'egg-instrument',
};

Instrument can calculate the duration of an operation, for example

// app/controller/home.js
exports.index = async ctx => {
  const ins = ctx.instrument('service', 'home.getData');
  const data = await ctx.service.home.getData();
  ins.end();
  ctx.body = data;
};

Then you can see the infomation in console

2017-01-20 15:32:58,567 INFO 30445 [-/127.0.0.1/-/1024ms GET /] [service] home.getData 1006ms

If you are not in context level, you can use app.instrument or agent.instrument.

Configuration

see config/config.default.js for more detail.

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-instrument

Weekly Downloads

4

Version

2.0.0

License

MIT

Last publish

Collaborators

  • dead_horse
  • popomore