JSPM

aws-lambda-powertools-correlation

0.3.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 134
    • Score
      100M100P100Q80203F
    • License MIT

    Correlation Ids to be used with powertools-lambda

    Package Exports

    • aws-lambda-powertools-correlation
    • aws-lambda-powertools-correlation/lib/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-lambda-powertools-correlation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    aws-lambda-powertools-correlation

    Correlation Ids for aws-lambda-powertools

    Features

    1. Middleware to enable injecting correlation ids from the request into the AsyncLocalStorage
    import { enableCorrelationIds } from 'aws-lambda-powertools-correlation';
    import middy from '@middy/core';
    import * as Lambda from 'aws-lambda';
    
    export const handler = (_handler: Lambda.APIGatewayProxyHandlerV2) => {
      return middy(_handler).use(enableCorrelationIds());
    };
    1. Utility to extend the powertools logger with correlation ids: injectCorrelationIds(logger)
    import { injectCorrelationIds } from 'aws-lambda-powertools-correlation';
    import { Logger } from '@aws-lambda-powertools/logger'
    
    const logger = new Logger();
    
    export const handler = (_handler: Lambda.APIGatewayProxyHandlerV2) => {
      return middy(_handler)
          .use(enableCorrelationIds())
          .before(() => { injectCorrelationIds(logger) });
    };
    1. Utility to get correlation ids from the internal store: getCorrelationIds()
    import { useCorrelationIds } from 'aws-lambda-powertools-correlation';
    
    const correlationIds = useCorrelationIds();
    

    Dependencies

    • @aws-sdk/util-dynamodb
    • @aws-lambda-powertools/logger