Amazon recently announced the beta release of AWS Lambda Powertools TypeScript. The set of utilities for Node.js Lambda functions helps developers follow best practices for tracing, structured logging and custom metrics.
AWS Lambda Powertools is an open source project composed of three modules: Tracer, a suite of utilities to trace Lambda handlers and synchronous/asynchronous functions, Logger, a middleware to add details of the Lambda context to the log items and Metrics, custom metrics created with CloudWatch Embedded Metric Format (EMF). Sara Gerion, senior solutions architect at AWS , summarizes in a tweet the main scenarios for the Logger module:
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.
and explains how the metrics and tracer can help, capturing responses and aggregating metrics in a single CloudWatch EMF object. In a Reddit thread, user teeokay celebrates the announcement:
The only thing that kept me from moving to Typescript Lambdas. Finally!
The new library provides a set of TypeScript calls for managing Lambda functions running on a Node.js runtime and helps developers extract observability data from serverless applications. Matt Morgan, director of software engineering at PowerSchool, wrote a "First Look at Lambda Powertools TypeScript" article and suggests:
Adding all of the utilities to my project seemed to add about 600kb unminified or 200kb to minified bundles. Given the value and the need to chain some dependencies into the AWS SDK or X-Ray SDK, this seems quite reasonable and the team has done a good job of staying with their "Keep It Lean" tenet. Lambda Powertools does an excellent job putting focus on the kinds of utilities developers really need to improve their applications and follow best practices.
Matt Lewis, chief architect at DVLA, adds:
What I love about the AWS Lambda Powertools is that it allows a new project to be developed that conforms to the best practices as set out in the Serverless Lens of the Well Architected Framework (...) It is an awesome new library for anyone that develops Lambda functions in JavaScript.
JavaScript is not the first language supported by Lambda Powertools, with AWS having previously released versions for Python and Java. The project is currently a beta developer preview, with a public roadmap and a production-ready release expected later this year.