Observability / Serverless / Software Development

AWS Offers a TypeScript Interface for Lambda Observability

6 Jan 2022 7:22am, by
Tracer

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.

The suite provides a set of TypeScript calls for managing AWS Lambda “serverless” functions running on a Node.js runtime. TypeScript is JavaScript with strong typing, which provides a platform for more refined debugging tools such as these.

According to Gerion, the logger utility can:
  • 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.

Logger

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.

Metrics

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.

Tracer

The suite also includes a Typescript Cloud Development Kit (CDK) for working with CloudFormation and other AWS resources.

Each TypeScript utility is installed as a standalone NPM package and follows the format of the AWS SDK v3 for JavaScript.

AWS has released similar Lambda Powertool packages for Java and Python.