or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aws-lambda-powertools@3.19.x
tile.json

tessl/pypi-aws-lambda-powertools

tessl install tessl/pypi-aws-lambda-powertools@3.19.0

Comprehensive developer toolkit implementing serverless best practices for AWS Lambda functions in Python

Agent Success

Agent success rate when using this tile

89%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.22x

Baseline

Agent success rate without this tile

73%

task.mdevals/scenario-3/

Lambda Order Processor Metrics

Build a Lambda function that processes e-commerce orders and emits custom CloudWatch metrics to track order processing performance and business KPIs.

Requirements

Your Lambda function should:

  1. Process incoming order events containing order details (order ID, customer ID, amount, region, payment method)
  2. Emit custom metrics to CloudWatch for monitoring business and operational metrics
  3. Track the following metrics with appropriate units:
    • Order processing duration in milliseconds
    • Order amount in dollars (use Count unit for currency)
    • Total number of orders processed (count)
  4. Include relevant dimensions for filtering and analysis:
    • Customer region (e.g., "us-east", "eu-west", "ap-south")
    • Payment method (e.g., "credit_card", "debit_card", "paypal")
  5. Add high-cardinality metadata for detailed debugging (order ID, customer ID)
  6. Use a namespace called "OrderProcessing" for all metrics
  7. Emit a special one-time metric when processing orders from VIP customers that includes a unique dimension for the customer tier

Event Format

Your function will receive events in the following format:

{
  "order_id": "ord-12345",
  "customer_id": "cust-67890",
  "amount": 299.99,
  "region": "us-east",
  "payment_method": "credit_card",
  "is_vip": false
}

Implementation

@generates

Test Cases

  • When processing a standard order, the function emits metrics with region and payment_method dimensions @test
  • When processing a VIP customer order, the function emits a separate metric with customer_tier dimension set to "VIP" @test
  • The function captures and emits processing_time_ms metric with Milliseconds unit @test

Dependencies { .dependencies }

aws-lambda-powertools { .dependency }

Provides utilities for AWS Lambda best practices, including custom metrics via EMF.