@lamware/powertools-tracing
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
NPM Discord Apache-2.0

Lamware - AWS Powertools Tracing

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 };

Package Sidebar

Install

npm i @lamware/powertools-tracing

Weekly Downloads

65

Version

2.0.1

License

GPL-3.0-only

Unpacked Size

41.2 kB

Total Files

7

Last publish

Collaborators

  • oyed