April 11, 2026

wshtlib: a shared internal library without the framework

Eight Lambda functions and one FastAPI app need structured logging, request context, CloudWatch metrics, and Lambda warming support.

AWS Lambda Powertools covers all of this. wshtlib is a smaller alternative — stdlib only, no external dependencies, ~400 lines.

Structure

A single directory, copied into each Lambda image at build time:

COPY backend/v1/wshtlib/ ./wshtlib/

Six modules:

Lambda Usage

@lambda_handler
def handler(event, context):
    logger.info("processing", shoot_id=event["shoot_id"])
    metrics.count("PhotosProcessed")
    metrics.flush()

@lambda_handler handles warming events, initialises context, and catches unhandled exceptions. The logger picks up trace_id from context automatically. Metrics emit EMF JSON to stdout — CloudWatch picks it up without a sidecar.

FastAPI Usage

app.add_middleware(WshtlibMiddleware)

Same context initialisation, same structured request logs, same X-Trace-Id response header.

What It Doesn’t Cover

No X-Ray tracing integration, no event parsing utilities, no idempotency helpers.