Epsagon Documentation

Welcome to the Epsagon Documentation. You'll find comprehensive guides and documentation to help you start working with our product as quickly as possible. Let's jump right in!

Get Started

This package provides tracing to Node.js applications for the collection of distributed tracing and performance metrics in Epsagon.

📘

Open source repository

This is an open-source project which can be found at our GitHub repository.

Installation

To install Epsagon, simply run:

npm install epsagon

Usage

Auto-tracing

The simplest way to get started in some frameworks is to install epsagon-frameworks:

npm install epsagon-frameworks

epsagon-frameworks extends the base epsagon support to more frameworks.

And run your node command:

export EPSAGON_TOKEN=epsagon-token
export EPSAGON_APP_NAME=app-name-stage
export NODE_OPTIONS='-r epsagon-frameworks'
node command

For example:

export EPSAGON_TOKEN=your-token
export EPSAGON_APP_NAME=express-prod
export NODE_OPTIONS='-r epsagon-frameworks'
node app.js

When using inside a Dockerfile, you can use ENV instead of export.

You can see the list of auto-tracing supported frameworks

Calling the SDK

Another simple alternative is to copy the snippet into your code:

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

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

To run on your framework please refer to supported frameworks

Tagging Traces

You can add custom tags to your traces, for easier filtering and aggregations.

Add the following call inside your code:

epsagon.label('key', 'value');
epsagon.label('userId', userId);

You can also use it to ship custom metrics:

epsagon.label('key', 'metric')
epsagon.label('itemsInCart', itemsInCart)

You can also use it iniside init function:

epsagon.init({
  token: 'epsagon-token',
  appName: 'app-name-stage',
  labels: [['key', 'value'], ['userId', userId]],
});

Valid types are string, boolean and number.

In some frameworks tagging can be done in different ways.

Custom Errors

You can set a trace as an error (although handled correctly) to get an alert or just follow it on the dashboard.

Add the following call inside your code:

try {
  // something bad happens
} catch (err) {
  epsagon.setError(err);
}

// Or manually specify Error object
epsagon.setError(Error('My custom error'));

In some frameworks custom errors can be declared in different ways.

Filter Sensitive Data

You can pass a list of sensitive properties and hostnames and they will be filtered out from the traces:

epsagon.init({
  token: 'epsagon-token',
  appName: 'app-name-stage',
  metadataOnly: false,
  ignoredKeys: ['password', /.*_token$/],
  urlPatternsToIgnore: ['example.com', 'auth.com'],
});

The ignoredKeys property can contain strings (will perform a loose match, so that First Name also matches first_name), regular expressions, and predicate functions.
Also, you can set urlPatternsToIgnore to ignore HTTP calls to specific domains.

Ignore Endpoints

You can ignore certain incoming requests by specifying endpoints:

epsagon.ignoreEndpoints(['/healthcheck'])

Frameworks

The following frameworks are supported by Epsagon.
Some require installing also epsagon-frameworks

FrameworkSupported VersionEpsagon LibraryAuto-tracing Supported
AWS LambdaAllepsagonYes, through the dashboard
Step FunctionsAllepsagonNo
OpenWhisk ActionAllepsagonNo
AWS BatchAllepsagonNo
GenericAllepsagonNo
Express>=3.0.0epsagon-frameworksYes
Hapi>=17.0.0epsagon-frameworksYes
Koa>=1.1.0epsagon-frameworksYes
KafkaJS>=1.2.0epsagon-frameworks<Yes
PubSub>=1.1.0epsagon-frameworksYes
SQS Consumer>=4.0.0epsagon-frameworksYes
amqplib>=0.5.0epsagon-frameworksYes
bunnybus>=7.0.0epsagon-frameworks
  • - [x]
NATS>=1.4.0epsagon-frameworksYes

Integrations

Epsagon provides out-of-the-box instrumentation (tracing) for many popular frameworks and libraries.

LibrarySupported Version
httpFully supported
httpsFully supported
http2Fully supported
dnsFully supported
aws-sdk>=2.2.0
amazon-dax-client>=1.0.2
@google-cloud>=2.0.0
@google-cloud/pubsub>=1.1.0
mysql>=2
mysql2>=1
pg>=4
mongodb>=3.0.0
kafkajs>=1.2.0
amqplib>=0.5.0
redis>=0.12.1
ioredis>=4.0.0
mqtt>=2.13.1
nats>=1.4.0
openwhisk>=3.0.0

Configuration

Advanced options can be configured as a parameter to the init() method or as environment variables.

ParameterEnvironment VariableTypeDefaultDescription
tokenEPSAGON_TOKENString-Epsagon account token
appNameEPSAGON_APP_NAMEStringApplicationApplication name that will be set for traces
metadataOnlyEPSAGON_METADATABooleantrueWhether to send only the metadata (true) or also the payloads (false)
useSSLEPSAGON_SSLBooleantrueWhether to send the traces over HTTPS SSL or not
traceCollectorURL-String-The address of the trace collector to send trace to
isEpsagonDisabledDISABLE_EPSAGONBooleanfalseA flag to completely disable Epsagon (can be used for tests or locally)
ignoredKeysEPSAGON_IGNORED_KEYSArray-Array of keys names (can be string or regex) to be removed from the trace
urlPatternsToIgnoreEPSAGON_URLS_TO_IGNOREArray[]Array of URL patterns to ignore the calls
sendTimeoutEPSAGON_SEND_TIMEOUT_SECFloat0.2The timeout duration in seconds to send the traces to the trace collector
decodeHTTPEPSAGON_DECODE_HTTPBooleantrueWhether to decode and decompress HTTP responses into the payload
httpErrorStatusCodeEPSAGON_HTTP_ERR_CODEInteger400The minimum number of an HTTP response status code to treat as an error
-DISABLE_EPSAGON_PATCHBooleanfalseDisable the library patching (instrumentation)
-EPSAGON_DEBUGBooleanfalseEnable debug prints for troubleshooting
-EPSAGON_PROPAGATE_NATS_IDBooleanfalseWhether to propagate a correlation ID in NATS.io calls for distributed tracing
-EPSAGON_ADD_NODE_PATHString-List of folders to looks for node_modules when patching libraries. Separated by :
-EPSAGON_DNS_INSTRUMENTATIONBooleanfalseWhether to capture dns calls into the trace
-EPSAGON_STEPS_IDString-The Epsagon step id from the ECS step functions state input
-EPSAGON_STEPS_NUMString0The step number of the ECS step functions state
-EPSAGON_DISABLE_HTTP_TRACE_IDBooleanfalseWhether to disable the trace ID propagation over HTTP calls

Updated 10 days ago


Node.js


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.