This package has been deprecated

Author message:

This plugin has moved to @iopipe/trace - no updates for iopipe-plugin-trace will be provided.

iopipe-plugin-trace

0.2.0 • Public • Published

IOpipe Trace Plugin

styled with prettier

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-plugin-trace

With npm in project directory:

npm install iopipe-plugin-trace

Then include the plugin with IOpipe in your serverless function:

const iopipeLib = require('iopipe');
const tracePlugin = require('iopipe-plugin-trace');

const iopipe = iopipeLib({
  plugins: [tracePlugin()]
});

// wrap your lambda handler
exports.handler = iopipe((event, context) => {
  context.iopipe.mark.start('database');
  // after database call is finished
  context.iopipe.mark.end('database');

  context.iopipe.mark.start('analytics');
  // after analytics call is finished
  context.iopipe.mark.end('analytics');
  context.succeed('Wow!');
});

Methods

// create the start mark
// the string argument is a name you are assigning the particular trace
context.iopipe.mark.start('db');

// create the end mark
// pass the name of the trace that you want to end
context.iopipe.mark.end('db');

// create an custom measurement between start:init and 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.

Package Sidebar

Install

npm i iopipe-plugin-trace

Weekly Downloads

0

Version

0.2.0

License

Apache-2.0

Last publish

Collaborators

  • teamiopipe