Socket
Socket
Sign inDemoInstall

@iopipe/trace

Package Overview
Dependencies
20
Maintainers
7
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @iopipe/trace

IOpipe plugin for tracing metrics


Version published
Maintainers
7
Created

Readme

Source

IOpipe Trace Plugin

styled with prettier semantic-release

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 >= 1.x

Install

Note: This plugin is automatically included in the recommended package @iopipe/iopipe

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/iopipe');
const tracePlugin = require('@iopipe/trace');

const iopipe = iopipeLib({
  token: 'TOKEN_HERE',
  plugins: [tracePlugin()]
});

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

  mark.start('analytics');
  // after analytics call is finished
  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.

Keywords

FAQs

Last updated on 19 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc