3.1.0 • Published 11 months ago

@thundra/core v3.1.0

Weekly downloads
1,554
License
-
Repository
github
Last release
11 months ago

Catchpoint Trace Node

OpenTracing Badge

Contents

Installation

npm ci @catchpoint/trace --save

Configuration

You can configure Catchpoint trace agent using environment variables or module initialization parameters.

Environment variables have higher precedence over initialization parameters.

Check out the configuration part of our docs for more detailed information.

1. Most Useful Environment variables

NameTypeDefault Value
CATCHPOINT_APIKEYstring-
CATCHPOINT_APPLICATION_NAMEstring-
CATCHPOINT_APPLICATION_STAGEstring-
CATCHPOINT_TRACE_DISABLEboolfalse
CATCHPOINT_TRACE_REQUEST_SKIPboolfalse
CATCHPOINT_TRACE_RESPONSE_SKIPboolfalse
CATCHPOINT_REPORT_REST_BASEURLstringhttps://collector.tracing.catchpoint.com/v1

Usage

Integration Options for Containers and VMs

export CATCHPOINT_APIKEY=<YOUR-CATCHPOINT-TRACE-API-KEY>
export CATCHPOINT_APPLICATION_NAME=<YOUR-APP-NAME>

For Dockerfile, you just replace export with ENV.

For more information see the doc

Express

const catchpoint = require("@catchpoint/trace");
const express = require('express');

const app = express();

app.get('/', function (req,res) {
   res.send("Response")
});
app.listen(3000);

Hapi

const catchpoint = require("@catchpoint/trace");
const Hapi = require('@hapi/hapi');

catchpoint.init();

const startServer = async () => {
    const server = Hapi.server({
        ...
    });

    server.route([{
        method: 'GET',
        path: '/',
        handler: (request, h) => {
            return 'Response';
        }
    }]);
    
    await server.start();
}

startServer();

Koa

const catchpoint = require("@catchpoint/trace");
const Koa = require('koa');

catchpoint.init();
const app = new Koa();

app.use(async (ctx, next) => {
  await next();
  ctx.body = 'Hello Catchpoint!';
});
app.listen(3000)

Google Pubsub

Publish
const { PubSub } = require('@google-cloud/pubsub');

const projectId = 'your_google_cloud_project_id';
const topicName = 'your_google_cloud_pubsub_topic';

const pubsub = new PubSub({ projectId });

/* 
* if topic allready exists 
* const topic = await pubsub.topic(topicName)
**/
const topic = await pubsub.createTopic(topicName);

const date = new Date().toString();
const dataBuffer = Buffer.from(JSON.stringify({date}));

const result = await topic.publishMessage({ data: dataBuffer });
Subscription
Asynchronous Pull
const catchpoint = require("@catchpoint/trace");
catchpoint.init();

const { PubSub, Subscription } = require('@google-cloud/pubsub');

const projectId = 'your_google_cloud_project_id';
const topicName = 'your_google_cloud_pubsub_topic';
const subscriptionName = 'your_google_cloud_pubsup_subscription_name';

const pubsub = new PubSub({ projectId });

(async() => {
    
    /* 
    * if subscription allready exists 
    * const subscription = pubsub.subscription(subscriptionName);
    **/
    const [subscription] = await pubsub.topic(topicName).createSubscription(subscriptionName);
    
    const messageHandler = message => {
      try {
        ...
        message.ack();
      } catch (err) {
        ...
        message.nack();
      }
    };
    
    subscription.on(`message`, messageHandler);
})().catch(error => console.log(error));
Synchronous Pull
const { v1 } = require('@google-cloud/pubsub');

const subClient = new v1.SubscriberClient();

const projectId = 'your_google_cloud_project_id';
const subscriptionName = 'your_google_cloud_pubsup_subscription_name';

const formattedSubscription = subClient.subscriptionPath(
  projectId,
  subscriptionName
);

const request = {
  subscription: formattedSubscription,
  maxMessages: 10,
};

...

const result = await subClient.pull(request);
const [response] = result;

const ackIds = [];
for (const message of response.receivedMessages) {
  ...
  ackIds.push(message.ackId);
}

if (ackIds.length !== 0) {
  const ackRequest = {
    subscription: formattedSubscription,
    ackIds: ackIds,
  };

  await subClient.acknowledge(ackRequest);
}
...

Frameworks

The following frameworks are supported by Catchpoint trace agent:

FrameworkSupported VersionAuto-tracing Supported
Express>=3.0.0- x
Hapi>=16.0.0-
Koa>=2.0.0-

Integrations

Catchpoint trace agent provides out-of-the-box instrumentation (tracing) for following libraries.

LibrarySupported Version
loggingFully supported
aws-sdk>=2.0.0
elasticsearch>=10.5.0
httpFully supported
httpsFully supported
http2Fully supported
ioredis>=2.0.0
redis>=2.6.0
mongodb>=1.0.0
mysql>=2.0.0
mysql2>=1.5.0
pg>=6.0.0
amqp 0.9.1>=0.5.0
@google-cloud/pubsub>=1.2
@google-cloud/bigquery>=5.0

Mask Sensitive Data

You can specify the keys to be masked in the trace by passing the key names (separated by comma (,) if there are multiple) through the CATCHPOINT_REPORT_MASKED_KEYS environment variable. Here, key names can be string for exact match or regexp pattern.

For example,

CATCHPOINT_REPORT_MASKED_KEYS=password

masks all the keys/properties whose names exactly match to password.

As another example,

CATCHPOINT_REPORT_MASKED_KEYS=/.*password.*/

masks all the keys/properties whose names contain (partially match) password.

If there are multiple key names or patterns you want to specify, you can separate them by comma (,).

CATCHPOINT_REPORT_MASKED_KEYS=/.*password.*/,/.*secret.*/

By default, masked data is replaced with *****. But if you want to remove the masked data completely, you can set CATCHPOINT_REPORT_HIDE environment variable to true.

All Environment Variables

NameTypeDefault ValueDescription
CATCHPOINT_APIKEYstring-
CATCHPOINT_DISABLEboolfalse
CATCHPOINT_DEBUG_ENABLEboolfalse
CATCHPOINT_TRACE_DISABLEboolfalse
CATCHPOINT_REPORT_REST_BASEURLstringhttps://collector.tracing.catchpoint.com/v1
CATCHPOINT_REPORT_REST_TRUSTALLCERTIFICATESboolfalse
CATCHPOINT_REPORT_REST_LOCALboolfalse
CATCHPOINT_REPORT_SIZE_MAXnumber32 * 1024 (32 KB)
CATCHPOINT_REPORT_MASKED_KEYSstring-Comma (,) separated key names (can be string or regexp) to be masked in the trace
CATCHPOINT_REPORT_HIDEboolfalseHides masked keys instead of masking them
CATCHPOINT_TRACE_REQUEST_SKIPboolfalse
CATCHPOINT_TRACE_RESPONSE_SKIPboolfalse
CATCHPOINT_APPLICATION_IDstring-
CATCHPOINT_APPLICATION_INSTANCEIDstring-
CATCHPOINT_APPLICATION_REGIONstring-
CATCHPOINT_APPLICATION_NAMEstring-
CATCHPOINT_APPLICATION_STAGEstring-
CATCHPOINT_APPLICATION_DOMAINNAMEstring-
CATCHPOINT_APPLICATION_CLASSNAMEstring-
CATCHPOINT_APPLICATION_VERSIONstring-
CATCHPOINT_APPLICATION_TAGany-
CATCHPOINT_INVOCATION_SAMPLE_ONERRORboolfalse
CATCHPOINT_INVOCATION_REQUEST_TAGSstring-
CATCHPOINT_INVOCATION_RESPONSE_TAGSstring-
CATCHPOINT_TRACE_INSTRUMENT_DISABLEboolfalse
CATCHPOINT_TRACE_INSTRUMENT_TRACEABLECONFIGstring-
CATCHPOINT_TRACE_INSTRUMENT_FILE_PREFIXstring-
CATCHPOINT_TRACE_SPAN_LISTENERCONFIGstring-
CATCHPOINT_TRACE_SPAN_COUNT_MAXnumber200
CATCHPOINT_SAMPLER_TIMEAWARE_TIMEFREQnumber300000
CATCHPOINT_SAMPLER_COUNTAWARE_COUNTFREQnumber100
CATCHPOINT_TRACE_INTEGRATIONS_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_INSTRUMENT_ONLOADboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SNS_MESSAGE_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SNS_TRACEINJECTION_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SQS_MESSAGE_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SQS_TRACEINJECTION_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_LAMBDA_PAYLOAD_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_LAMBDA_TRACEINJECTION_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_DYNAMODB_STATEMENT_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_DYNAMODB_RESULT_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_DYNAMODB_TRACEINJECTION_ENABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_ATHENA_STATEMENT_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_BODY_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_BODY_SIZE_MAXnumber10 * 1024 (10 KB)
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_HEADERS_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_RESPONSE_BODY_MASKbooltrue
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_RESPONSE_BODY_SIZE_MAXnumber10 * 1024 (10 KB)
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_RESPONSE_HEADERS_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_URL_DEPTHnumber1
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_TRACEINJECTION_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_ERROR_ON4XX_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HTTP_ERROR_ON5XX_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_REDIS_COMMAND_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_RDB_STATEMENT_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_RDB_RESULT_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_ELASTICSEARCH_BODY_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_ELASTICSEARCH_PATH_DEPTHnumber1
CATCHPOINT_TRACE_INTEGRATIONS_MONGODB_COMMAND_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_EVENTBRIDGE_DETAIL_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SES_MAIL_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_AWS_SES_MAIL_DESTINATION_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_RABBITMQ_MESSAGE_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_GOOGLE_PUBSUB_MESSAGE_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_GOOGLE_BIGQUERY_RESPONSE_SIZE_MAXnumber1 * 1024 (1 KB)
CATCHPOINT_TRACE_INTEGRATIONS_GOOGLE_BIGQUERY_QUERY_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_GOOGLE_BIGQUERY_RESPONSE_MASKboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_HAPI_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_KOA_DISABLEboolfalse
CATCHPOINT_TRACE_INTEGRATIONS_GOOGLE_PUBSUB_DISABLEboolfalse

How to build

Webpack is used as a module bundler.

To build the project,

npm ci
npm run build

How to test

Tests are written using Jest.

To run tests,

npm run test
3.1.1-rc.0

11 months ago

3.1.3-rc.2

11 months ago

3.1.3-rc.1

11 months ago

3.1.3-rc.0

11 months ago

3.1.2-rc.0

11 months ago

3.0.8-beta.0

11 months ago

3.0.8-beta.1

11 months ago

3.0.3-beta.0

11 months ago

3.0.12-beta.0

11 months ago

3.0.12-beta.1

11 months ago

3.1.0

11 months ago

3.0.11-alpha.0

11 months ago

3.0.11-alpha.1

11 months ago

3.0.2

11 months ago

3.0.1

11 months ago

3.0.6-beta.0

11 months ago

3.0.7-beta.0

11 months ago

3.0.4-beta.0

11 months ago

3.0.7-beta.2

11 months ago

3.0.7-beta.1

11 months ago

3.0.9-beta.0

11 months ago

3.0.9-beta.1

11 months ago

2.14.3

11 months ago

2.14.4

11 months ago

2.14.1

11 months ago

2.14.2

11 months ago

2.14.0

11 months ago

2.13.65

1 year ago

2.13.64

1 year ago

2.13.63

1 year ago

2.13.62

1 year ago

2.13.61

1 year ago

2.13.60

1 year ago

2.13.59

1 year ago

2.13.58

1 year ago

2.13.57

1 year ago

2.13.56

1 year ago

2.13.55

1 year ago

2.13.54

1 year ago

2.13.53

2 years ago

2.13.52

2 years ago

2.13.51

2 years ago

2.13.50

2 years ago

2.13.49

2 years ago

2.13.48

2 years ago

2.13.47

2 years ago

2.13.46

2 years ago

2.13.45

2 years ago

2.13.44

2 years ago

2.13.43

2 years ago

2.13.42

2 years ago

2.13.39

2 years ago

2.13.38

2 years ago

2.13.37

2 years ago

2.13.41

2 years ago

2.13.40

2 years ago

2.13.36

2 years ago

2.13.35

2 years ago

2.13.34

2 years ago

2.13.33

2 years ago

2.13.32

2 years ago

2.13.31

2 years ago

2.13.30

2 years ago

2.13.29

2 years ago

2.13.28

2 years ago

2.13.27

2 years ago

2.13.26

2 years ago

2.13.25

2 years ago

2.13.19

2 years ago

2.13.18

2 years ago

2.13.17

2 years ago

2.13.16

2 years ago

2.13.15

2 years ago

2.13.14

2 years ago

2.13.13

2 years ago

2.13.24

2 years ago

2.13.23

2 years ago

2.13.22

2 years ago

2.13.21

2 years ago

2.13.20

2 years ago

2.13.12

2 years ago

2.13.11

2 years ago

2.13.10

2 years ago

2.13.8

2 years ago

2.13.9

2 years ago

2.13.7

2 years ago

2.13.6

3 years ago

2.13.5

3 years ago

2.13.4

3 years ago

2.13.2

3 years ago

2.13.3

3 years ago

2.13.0

3 years ago

2.13.1

3 years ago

2.12.22

3 years ago

2.12.21

3 years ago

2.12.20

3 years ago

2.12.19

3 years ago

2.12.18

3 years ago

2.12.17

3 years ago

2.12.16

3 years ago

2.12.15

3 years ago

2.12.14

3 years ago

2.12.13

3 years ago

2.12.12

3 years ago

2.12.11

3 years ago

2.12.10

3 years ago

2.12.9

3 years ago

2.12.8

3 years ago

2.12.7

3 years ago

2.12.6

3 years ago

2.12.5

4 years ago

2.12.4

4 years ago

2.12.3

4 years ago

2.12.2

4 years ago

2.12.1

4 years ago

2.12.0

4 years ago

2.11.11

4 years ago

2.11.10

4 years ago

2.11.9

4 years ago

2.11.8

4 years ago

2.11.7

4 years ago

2.11.6

4 years ago

2.11.5

4 years ago

2.11.4

4 years ago

2.11.3

4 years ago

2.11.2

4 years ago

2.11.1

4 years ago

2.11.0

4 years ago

2.10.12

4 years ago

2.10.11

4 years ago

2.10.10

4 years ago

2.10.9

4 years ago

2.10.6

4 years ago

2.10.5

4 years ago

2.10.3

4 years ago

2.10.2

4 years ago

2.10.1

4 years ago

2.10.0

4 years ago

2.9.12

4 years ago

2.9.11

4 years ago

2.9.10

4 years ago

2.9.9

4 years ago

2.9.8

4 years ago

2.9.7

4 years ago

2.9.6

4 years ago

2.9.5

4 years ago

2.9.4

4 years ago

2.9.3

4 years ago

2.9.2

4 years ago

2.9.1

4 years ago

2.9.0

4 years ago

2.8.2

4 years ago

2.8.1

4 years ago

2.8.0

4 years ago

2.7.4

4 years ago

2.7.3

4 years ago

2.7.2

4 years ago

2.7.1

4 years ago

2.7.0

4 years ago

2.6.5

4 years ago

2.6.4

5 years ago

2.6.3

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.10

5 years ago

2.5.9

5 years ago

2.5.8

5 years ago

2.5.7

5 years ago

2.5.6

5 years ago

2.5.5

5 years ago

2.5.4

5 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.6.0

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago