File tree Expand file tree Collapse file tree 9 files changed +16227
-0
lines changed Expand file tree Collapse file tree 9 files changed +16227
-0
lines changed Original file line number Diff line number Diff line change 1+ # build
2+ lib
3+
4+ # include types
5+ ! src /types /* .d.ts
6+
7+ # include jest config
8+ ! jest.config.js
9+ ! .eslintrc.js
10+
11+ # npm
12+ node_modules
13+ npm_debug.log *
14+
15+ # yalc
16+ yalc.lock
17+
Original file line number Diff line number Diff line change 11# aws-lambda-powertools-correlation
22Correlation Ids for aws-lambda-powertools
3+
4+
5+ <h3 >Features</h3 >
6+
7+ 1 . Middleware to enable injecting correlation ids from the request into the <i >AsyncLocalStorage</i >
8+ ``` typescript
9+ import { enableCorrelationIds } from ' @aws-lambda-powertools-correlation' ;
10+ import middy from ' @middy/core' ;
11+ import * as Lambda from ' aws-lambda' ;
12+
13+ export const handler = (_handler : Lambda .APIGatewayProxyHandlerV2 ) => {
14+ return middy (_handler ).use (enableCorrelationIds ());
15+ };
16+ ```
17+
18+
19+ 2 . Utility to extend the powertools logger with correlation ids: <i >injectCorrelationIds(logger)</i >
20+
21+ ``` typescript
22+ import { injectCorrelationIds } from ' @aws-lambda-powertools-correlation' ;
23+ import { Logger } from ' @aws-lambda-powertools/logger'
24+
25+ const logger = new Logger ();
26+
27+ export const handler = (_handler : Lambda .APIGatewayProxyHandlerV2 ) => {
28+ return middy (_handler )
29+ .use (enableCorrelationIds ())
30+ .before (() => { injectCorrelationIds (logger ) });
31+ };
32+ ```
33+
34+ 3 . Utility to get correlation ids from the AsyncLocalStorage: <i >getCorrelationIds()</i >
35+ ``` typescript
36+ import { useCorrelationIds } from ' @aws-lambda-powertools-correlation' ;
37+
38+ const correlationIds = useCorrelationIds ();
39+
40+ ```
41+
42+ <h3 >Dependencies</h3 >
43+
44+ - @aws-sdk/util-dynamodb
45+ - @aws-lambda-powertools/logger
46+
47+
You can’t perform that action at this time.
0 commit comments