Skip to content
Instrumentation library for Node.js frameworks ⚡️
JavaScript
Branch: master
Clone or download
dependabot and ranrib build(deps): bump mixin-deep from 1.3.1 to 1.3.2 (#9)
Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2)

Signed-off-by: dependabot[bot] <support@github.com>
Latest commit a98b4fa Aug 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src
.eslintignore
.eslintrc
.gitignore
.npmignore
.travis.yml
CODE_OF_CONDUCT.md
LICENSE
README.md
commitlint.config.js
package-lock.json
package.json
rollup.config.js

README.md

Epsagon Instrumentation for Node.js Frameworks

Build Status npm version semantic-release

This package provides an instrumentation to Node.js code running on frameworks for collection of distributed tracing and performance monitoring.

Installation

From your project directory:

npm install --save epsagon-frameworks

Express application

If you're running express.js application on any non Lambda environment, you can still use Epsagon! Note: Only Express 4 and above is supported You can accomplish that with the following example:

const express = require('express');
const epsagon = require('epsagon-frameworks');

epsagon.init({
    token: 'my-secret-token',
    appName: 'my-app-name',
    metadataOnly: false,
});

const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000)

Hapi application

If you're running Hapi.js application on any non Lambda environment, you can still use Epsagon! Note: Only Hapi 17 and above is supported You can accomplish that with the following example:

const Hapi = require('hapi');
const epsagon = require('epsagon-frameworks');

epsagon.init({
    token: 'my-secret-token',
    appName: 'my-app-name',
    metadataOnly: false,
});

const init = async () => {

    const server = Hapi.server({
        port: 3000,
        host: 'localhost'
    });

    server.route({
        method: 'GET',
        path:'/',
        handler: (request, h) => {
            return 'Hello World!';
        }
    });

    await server.start();
    console.log('Server running on %ss', server.info.uri);
};

init();

Koa application

If you're running Koa.js application on any non Lambda environment, you can still use Epsagon! You can accomplish that with the following example:

const Koa = require('koa');
const epsagon = require('epsagon-frameworks');

epsagon.init({
    token: 'my-secret-token',
    appName: 'my-app-name',
    metadataOnly: false,
});

const app = new Koa();

app.use(async ctx => {
  ctx.body = 'Hello World';

  // Example label usage
  ctx.epsagon.label('myFirstLabel', 'customValue1');
});

app.listen(3000)

Custom labels

You can add custom labels to your traces. Filters can later be used for filtering traces that contains specific labels:

function handler(event, context, callback) {
    epsagon.label('myCustomLabel', 'labelValue');
    callback(null, 'It worked!')
}

Custom errors

You can set a trace as an error (although handled correctly) by catching an error:

function handler(event, context, callback) {
    try {
        // something bad happens
    } catch (err) {
        epsagon.setError(err);
    }

    callback(null, 'It worked!')
}

Or manually specify Error object:

function handler(event, context, callback) {
    epsagon.setError(Error('My custom error'));
    callback(null, 'It worked!')
}

Ignoring endpoints

You can ignore certain requests by specifying endpoints:

epsagon.ignoreEndpoints(['/healthcheck'])

Copyright

Provided under the MIT license. See LICENSE for details.

Copyright 2019, Epsagon

You can’t perform that action at this time.