IOpipe Trace Plugin
Create marks and measures for arbitrary units of time. Measure latency of database calls, third party requests, or code blocks and visualize them in IOpipe!
Requirements
- Node >=
4.3.2
- NPM >=
2.14.12
- IOpipe >=
0.8.0
Install
With yarn (recommended) in project directory:
yarn add @iopipe/trace
With npm in project directory:
npm install @iopipe/trace
Then include the plugin with IOpipe in your serverless function:
const iopipeLib = require('iopipe');
const tracePlugin = require('@iopipe/trace');
const iopipe = iopipeLib({
token: 'TOKEN_HERE',
plugins: [tracePlugin()]
});
exports.handler = iopipe((event, context) => {
context.iopipe.mark.start('database');
context.iopipe.mark.end('database');
context.iopipe.mark.start('analytics');
context.iopipe.mark.end('analytics');
context.succeed('Wow!');
});
Methods
context.iopipe.mark.start('db');
context.iopipe.mark.end('db');
context.iopipe.measure('custom', 'init', 'db');
Config
autoMeasure
(bool: optional = true)
By default, the plugin will create auto-measurements for marks with matching mark.start
and mark.end
. These measurements will be displayed in the IOpipe Dashboard. If you'd like to turn this off, set autoMeasure: false
.
const iopipe = iopipeLib({
plugins: [tracePlugin({
autoMeasure: false
})]
});
Contributing
- This project uses Prettier. Please execute
npm run eslint -- --fix
to auto-format the code before submitting pull requests.