AWS Offers a TypeScript Interface for Lambda Observability
Software engineers at Amazon Web Services, with the help of outside volunteers, have released an open source library to help TypeScript developers extract meaningful observability data from their serverless AWS Lambda jobs.
Introduced in Beta, the AWS Lambda Powertools TypeScript “provides a suite of utilities for Node.js Lambda functions to ease the adoption of best practices such as tracing, structured logging, custom metrics,” wrote AWS Senior Solutions Architect Sara Gerion, in a Tweet thread Tuesday.
- Capture key fields from Lambda context, cold start and structures logging output as JSON.
- Log Lambda context when instructed.
- Log sampling prints all logs for a percentage of invocations.
- Append keys to structured log at any point in time.
The Metrics utility can:
- Aggregate up to 100 metrics using a single CloudWatch EMF object.
- Validate against common metric definitions mistakes.
- Metrics are created async by CloudWatch.
- Context manager to create a one-off metric with a different dimension.
And the Tracer utility can:
- Auto capture cold start, responses, errors.
- Auto-disable when not running in AWS Lambda environment.
- Support tracing functions via decorators, middleware, and manual instrumentation.
- Support tracing AWS SDK v2 and v3 via AWS X-Ray SDK.
The suite also includes a Typescript Cloud Development Kit (CDK) for working with CloudFormation and other AWS resources.