开发者社区> 镜像站> NPM> @perform/lambda-powertools-correlation-ids
@perform/lambda-powertools-correlation-ids

Module for recording correlation IDs

Moved to @dazn/lambda-powertools-correlation-ids - please migrate to the new package by Tuesday 20th August 2019 as this package will be made private.
Last updated a year ago by automation-drone .
MIT · Original npm · Tarball · package.json
$ cnpm install @perform/lambda-powertools-correlation-ids 
SYNC missed versions from official npm registry.

lambda-powertools-correlation-ids

A helper module for recording correlation IDs.

Main features:

  • allows you to fetch, update, and delete correlation IDs

  • respects convention for correlation IDs - i.e. x-correlation-

  • allows you to store more than one correlation IDs, which allows you to correlate logs on multiple dimensions (e.g. by x-correlation-user-id, or x-correlation-order-id, etc.)

Getting Started

Install from NPM: npm install @perform/lambda-powertools-correlation-ids

API

const CorrelationIds = require('@perform/lambda-powertools-correlation-ids')

// automatically inserts 'x-correlation-' prefix if not provided
CorrelationIds.set('id', '12345678') // records id as x-correlation-id
CorrelationIds.set('x-correlation-username', 'theburningmonk') // records as x-correlation-username

const myCorrelationIds = CorrelationIds.get()
// {
//   'x-correlation-id': '12345678',
//   'x-correlation-username': 'theburningmonk'
// }

CorrelationIds.clearAll() // removes all recorded correlation IDs
CorrelationIds.replaceAllWith({  // bypasses the 'x-correlation-' convention
  'DEBUG-LOG-ENABLED': 'true',
  'User-Agent': 'jest test'
})

In practice, you're likely to only need set when you want to record correlation IDs from your function.

The middleware, @perform/lambda-powertools-middleware-correlation-ids, would automatically capture the correlation IDs from the invocation event for supported event sources:

  • API Gateway (via HTTP headers)

  • Kinesis (via the JSON payload)

  • SNS (via message attributes)

  • any invocation event with the special field __context__ (which is how we inject them with the Step Functions and Lambda clients below)

Whilst other power tools would use get to make use of the correlation IDs:

  • @perform/lambda-powertools-logger includes recorded correlation IDs in logs

  • @perform/lambda-powertools-http-client includes recorded correlation IDs as HTTP headers when you make a HTTP request

  • @perform/lambda-powertools-sns-client includes recorded correlation IDs as SNS message attributes when you publish a message to SNS (ie. SNS.publish)

  • @perform/lambda-powertools-kinesis-client injects recorded correlation IDs as part of the event payload when you publish event(s) to Kinesis (ie. Kinesis.putRecord and Kinesis.putRecords)

  • @perform/lambda-powertools-step-functions-client injects recorded correlation IDs as part of the payload when you start a Step Functions execution (ie. SFN.startExecution)

  • @perform/lambda-powertools-lambda-client injects recorded correlation IDs as part of the invocation payload when you invoke a Lambda function directly (ie. Lambda.invoke and Lambda.invokeAsync)

Current Tags

  • 1.5.0                                ...           latest (a year ago)

25 Versions

  • 1.5.0 [deprecated]           ...           a year ago
  • 1.3.0 [deprecated]           ...           a year ago
  • 1.1.7 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
  • 0.10.5 [deprecated]           ...           2 years ago
  • 0.10.4 [deprecated]           ...           2 years ago
  • 0.10.3 [deprecated]           ...           2 years ago
  • 0.10.2 [deprecated]           ...           2 years ago
  • 0.10.1 [deprecated]           ...           2 years ago
  • 0.10.0 [deprecated]           ...           2 years ago
  • 0.9.0 [deprecated]           ...           2 years ago
  • 0.8.0 [deprecated]           ...           2 years ago
  • 0.7.0 [deprecated]           ...           2 years ago
  • 0.6.4 [deprecated]           ...           2 years ago
  • 0.6.3 [deprecated]           ...           2 years ago
  • 0.6.2 [deprecated]           ...           2 years ago
  • 0.6.0 [deprecated]           ...           2 years ago
  • 0.5.0 [deprecated]           ...           2 years ago
  • 0.4.0 [deprecated]           ...           2 years ago
  • 0.3.0 [deprecated]           ...           2 years ago
  • 0.2.12 [deprecated]           ...           2 years ago
  • 0.2.11 [deprecated]           ...           2 years ago
  • 0.2.10 [deprecated]           ...           2 years ago
  • 0.2.9 [deprecated]           ...           2 years ago
  • 0.2.8 [deprecated]           ...           2 years ago
Maintainers (326)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None