@lamware/powertools-tracing
v2.0.1
Published
Lamware Middleware to utilize the official Tracing powertools
Downloads
106
Readme
This Lamware Middleware utilizes the official Lambda TypeScript Powertools provided by AWS to:
- Set-up and memoize a root
Tracer
instance - Automatically set-up a root Tracer Segment to:
- Annotate the cold-start time
- Set the service name
- If the response is an error, capture that too
- Clean-up and close segments created by the package
Installation
This package is available via NPM:
yarn add @lamware/powertools-tracing
# or
npm install @lamware/powertools-tracing
Usage
import { powertoolsTracing } from '@lamware/powertools-tracing';
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { lamware } from '@lamware/core';
const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
.use(powertoolsTracing({
// Options are pass-through to the Tracing instance.
serviceName: 'my-api',
}))
.execute(async ({ state }) => {
// state.tracer
// state.segment
// state.subsegment
return { statusCode: 200 };
});
export { handler };