• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Observe and develop serverless apps with confidence on AWS Lambda with Tracing, Metrics, Profiling, Monitoring, and more.

IOpipe Agent for JavaScript


Coverage Status npm version styled with prettier semantic-release

IOpipe is a serverless DevOps platform for organizations building event-driven architectures in AWS Lambda. IOpipe captures crucial, high-fidelity metrics for each Lambda function invocation. This data powers a flexibile and robust development and operations experience with features including tracing, profiling, custom metrics, and low-latency alerts. Get started today to quickly and confidently gain superior observability, identify issues, and discover anomalies in your connected applications.

Note: this library is a lower-level implementation than the package you might likely be looking for. Enjoy pre-bundled plugins like tracing and event info with @iopipe/iopipe

Installation

Install using your package manager of choice,

npm install @iopipe/core

or

yarn add @iopipe/core

If you are using the Serverless Framework to deploy your lambdas, check out our serverless plugin.

Usage

Configure the library with your project token (register for access), and it will automatically monitor and collect metrics from your applications running on AWS Lambda.

Example:

const iopipeLib = require('@iopipe/core');

const iopipe = iopipeLib({ token: 'PROJECT_TOKEN' });

exports.handler = iopipe((event, context) => {
  context.succeed('This is my serverless function!');
});

Custom metrics

You may add custom metrics to an invocation using context.iopipe.metric to add either string or numerical values. Keys have a maximum length of 256 characters, and string values are limited to 1024.

Example:

const iopipeLib = require('@iopipe/core');

const iopipe = iopipeLib({ token: 'PROJECT_TOKEN' });

exports.handler = iopipe((event, context) => {
  context.iopipe.metric('key', 'some-value');
  context.iopipe.metric('another-key', 42);
  context.succeed('This is my serverless function!');
});

Labels

You can label invocations using context.iopipe.label to label an invocation with a string value, with a limit of 128 characters.

Example:

const iopipeLib = require('@iopipe/core');

const iopipe = iopipeLib({ token: 'PROJECT_TOKEN' });

exports.handler = iopipe((event, context) => {
  context.iopipe.label('something-important-happened');
  context.succeed('This is my serverless function!');
});

Configuration

Methods

You can configure your iopipe setup through one or more different methods - that can be mixed, providing a config chain. The current methods are listed below, in order of precendence. The module instantiation object overrides all other config values (if values are provided).

  1. Module instantiation object
  2. IOPIPE_* environment variables
  3. An .iopiperc file
  4. An iopipe package.json entry
  5. An extends key referencing a config package
  6. Default values

Options

token (string: required)

If not supplied, the environment variable $IOPIPE_TOKEN will be used if present. Find your project token.

debug (bool: optional = false)

Debug mode will log all data sent to IOpipe servers to STDOUT. This is also a good way to evaluate the sort of data that IOpipe is receiving from your application. If not supplied, the environment variable $IOPIPE_DEBUG will be used if present.

const iopipe = require('@iopipe/core')({
  token: 'PROJECT_TOKEN',
  debug: true
});

exports.handler = iopipe((event, context, callback) => {
  // Do things here. We'll log info to STDOUT.
});

networkTimeout (int: optional = 5000)

The number of milliseconds IOpipe will wait while sending a report before timing out. If not supplied, the environment variable $IOPIPE_NETWORK_TIMEOUT will be used if present.

const iopipe = require('@iopipe/core')({ token: 'PROJECT_TOKEN', networkTimeout: 30000})

timeoutWindow (int: optional = 150)

By default, IOpipe will capture timeouts by exiting your function 150ms early from the AWS configured timeout, to allow time for reporting. You can disable this feature by setting timeoutWindow to 0 in your configuration. If not supplied, the environment variable $IOPIPE_TIMEOUT_WINDOW will be used if present.

const iopipe = require('@iopipe/core')({ token: 'PROJECT_TOKEN', timeoutWindow: 0})

plugins (array: optional)

Note that if you use the @iopipe/iopipe package, you get our recommended plugin set-up right away. Plugins can extend the functionality of IOpipe in ways that best work for you. Follow the guides for the plugins listed below for proper installation and usage on the @iopipe/core library:

Example:

const tracePlugin = require('@iopipe/trace');

const iopipe = require('@iopipe/core')({
  token: 'PROJECT_TOKEN',
  plugins: [tracePlugin()]
});

exports.handler = iopipe((event, context, callback) => {
  // Run your fn here
});

enabled (boolean: optional = True)

Conditionally enable/disable the agent. The environment variable $IOPIPE_ENABLED will also be checked.

url (string: optional)

Sets an alternative URL to use for the IOpipe collector. The environment variable $IOPIPE_COLLECTOR_URL will be used if present.

RC File Configuration

Not recommended for webpack/bundlers due to dynamic require.

You can configure iopipe via an .iopiperc RC file. An example of that is here. Config options are the same as the module instantiation object, except for plugins. Plugins should be an array containing mixed-type values. A plugin value can be a:

  • String that is the name of the plugin
  • Or an array with plugin name first, and plugin options second
{
  "token": "wow_token",
  "plugins": [
    "@iopipe/trace",
    ["@iopipe/profiler", {"enabled": true}]
  ]
}

IMPORTANT: You must install the plugins as dependencies for them to load properly in your environment.

package.json Configuration

Not recommended for webpack/bundlers due to dynamic require.

You can configure iopipe within a iopipe package.json entry. An example of that is here. Config options are the same as the module instantiation object, except for plugins. Plugins should be an array containing mixed-type values. A plugin value can be a:

  • String that is the name of the plugin
  • Or an array with plugin name first, and plugin options second
{
  "name": "my-great-package",
  "dependencies": {
    "@iopipe/trace": "^0.2.0",
    "@iopipe/profiler": "^0.1.0"
  },
  "iopipe": {
    "token": "wow_token",
    "plugins": [
      "@iopipe/trace",
      ["@iopipe/profiler", {"enabled": true}]
    ]
  }
}

IMPORTANT: You must install the plugins as dependencies for them to load properly in your environment.

Extends Configuration

Not recommended for webpack/bundlers due to dynamic require.

You can configure iopipe within a package.json or rc file by referencing a extends config package. An example of that is here. Config options are the same as the module instantiation object, except for plugins. Plugins should be an array containing mixed-type values. A plugin value can be a:

  • String that is the name of the plugin
  • Or an array with plugin name first, and plugin options second

For an example of a config package, check out @iopipe/config.

IMPORTANT: You must install the config package and plugins as dependencies for them to load properly in your environment.

License

Apache 2.0

More Repositories

1

lambda-shell

interactive shell for machines running on AWS Lambda
JavaScript
155
star
2

turtle

Turtle - functional composition for building lambda architectures in NodeJS
JavaScript
153
star
3

iopipe-python

Python agent for AWS Lambda metrics, tracing, profiling & analytics
Python
79
star
4

dockaless

Dockaless - Serverless Docker functions
JavaScript
78
star
5

serverless-plugin-iopipe

Automatically wrap your serverless framework functions with IOpipe
JavaScript
40
star
6

iopipe-js

Build and run serverless apps with confidence on AWS Lambda with Tracing, Profiling, Metrics, Monitoring, and more.
Shell
33
star
7

awslambda-reverse-proxy

serverless reverse proxy
JavaScript
29
star
8

sqs-to-lambda-async

Process SQS messages with Lambda, asynchronously
JavaScript
27
star
9

awslambda-npm-install

Install any module, including native C/C++ modules for your NodeJS project on AWS Lambda
23
star
10

iopipe-go

Go agent for AWS Lambda metrics, tracing, profiling & analytics
Go
18
star
11

lambda-runtime-pypy3.5

AWS Lambda Runtime for PyPy 3.5
Python
18
star
12

performance-node

Performance for Node.js
JavaScript
17
star
13

iopipe-java

AWS Lambda telemetry for Java
Java
17
star
14

turtle-shell

Serverless function composition and sharing CLI for Go
Go
16
star
15

lambda-workshop

Learn AWS Lambda in just 45 minutes!
JavaScript
15
star
16

serverless-iopipe-layers

Please migrate to the equivalent New Relic Serverless plugin: serverless-newrelic-lambda-layers
TypeScript
14
star
17

servers.lol

Cattle or crickets? You decide!
JavaScript
13
star
18

v8-profiler-lambda

AWS Lambda Wrapper for v8-profiler
JavaScript
12
star
19

iopipe-js-profiler

Profiling and tracing for AWS Lambda
JavaScript
11
star
20

dockerbot-serverless

A Slackbot which runs Docker images and commands via a /docker
JavaScript
9
star
21

iopipe-js-trace

Custom timings + tracing for AWS Lambda serverless functions
JavaScript
8
star
22

examples

IOpipe Example Projects
Java
7
star
23

aws-amplify-geolocation-app

Uses AWS Amplify to create serverless frontend and backend. AWS Appsync as the API which has two lambda functions as resolvers to return data from Hacker News and Github
JavaScript
5
star
24

lambda-requestbin

RequestBin service using AWS Lambda
JavaScript
4
star
25

eva

Eva is your event ally for event-driven and API application development.
Go
3
star
26

aws-sar-examples

AWS Serverless Application Repository Demo for IOpipe
JavaScript
3
star
27

iopipe-cli

Installer for IOpipe instrumentation using AWS Layers
Python
3
star
28

iopipe-js-logger

Automatic console data into IOpipe
JavaScript
2
star
29

turtle-registry

Turtle Code Registry - an npm alternative for NodeJS for functional applications
JavaScript
1
star
30

iopipe-java-logger-log4j2

Support for Log4j2 using the IOpipe Logger Plugin.
Shell
1
star
31

iopipe-newrelic-migration-faq

IOpipe to New Relic migration guide
1
star
32

turtle-examples

JavaScript
1
star
33

dockaless-examples

Examples for Dockaless
JavaScript
1
star
34

iopipe-js-event-info

Event Info Plugin for IOpipe JS
JavaScript
1
star
35

iopipe-java-logger-tinylog

Support for TinyLog using the IOpipe Logger Plugin.
Shell
1
star