Effectively running Java on ServerlessPowertools for AWS Lambda2 min

AWS Lambda Powertools for Java is an open-source library to help discover and incorporate serverless best practices early and quickly. It is a suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging, and creating custom metrics asynchronously easier.

Logging

  • Captures key fields from Lambda context, cold start, and structures logging output as JSON.
  • Log Lambda event when instructed, disabled by default, can be enabled explicitly via annotation param.
  • Appends additional keys to structured log at any point in time.

Tracing

  • Powertools tracing is an opinionated thin wrapper for AWS X-Ray Java SDK and provides functionality to reduce the overhead of performing common tracing tasks.
  • Captures cold start as annotation, and responses as well as full exceptions as metadata.
  • Helper methods to improve the developer experience of creating new X-Ray subsegments.
  • Better developer experience when developing with multiple threads.
  • Auto patch supported modules by AWS X-Ray.

Metrics

  • Aggregates up to 100 metrics using a single CloudWatch EMF object (large JSON blob).
  • Validates against common metric definitions mistakes (metric unit, values, max dimensions, max metrics, etc).
  • Metrics are created asynchronously by the CloudWatch service, no custom stacks needed.
  • Context manager to create a one-off metric with a different dimension.

Extra utilities

  • Idempotency – allows safe retries for your function
  • Parameters – retrieves values from Parameter Store or Secrets Manager
  • SQS large message handling – handles SQS messages with payloads in S3
  • SQS batch processing – handles partial failures when processing SQS batches
  • Validation – JSON schema validation for payloads
  • Serialization utilities – manipulates JSON data in your functions

Created by:

Lavanya Tangutur
Lavanya TanguturSr. Technical Account Manager