From 66cd50858d9f9b49064479d0eba2185bc809b103 Mon Sep 17 00:00:00 2001 From: Leandro Damascena Date: Tue, 2 May 2023 21:59:14 +0100 Subject: [PATCH] docs: change the default handler --- examples/logger/sam/template.yaml | 2 +- examples/logger/src/append_keys.py | 2 +- examples/logger/src/append_keys_extra.py | 2 +- examples/logger/src/append_keys_kwargs.py | 2 +- examples/logger/src/append_keys_vs_extra.py | 2 +- examples/logger/src/bring_your_own_formatter_from_scratch.py | 2 +- examples/logger/src/clear_state.py | 2 +- examples/logger/src/enabling_boto_logging.py | 2 +- examples/logger/src/fake_lambda_context_for_logger_module.py | 2 +- examples/logger/src/inject_lambda_context.py | 2 +- examples/logger/src/log_incoming_event.py | 2 +- examples/logger/src/logger_reuse.py | 2 +- examples/logger/src/logging_exceptions.py | 2 +- examples/logger/src/logging_inheritance_bad.py | 2 +- examples/logger/src/logging_inheritance_good.py | 2 +- examples/logger/src/logging_uncaught_exceptions.py | 2 +- examples/logger/src/remove_keys.py | 2 +- examples/logger/src/sampling_debug_logs.py | 2 +- examples/logger/src/set_correlation_id.py | 2 +- examples/logger/src/set_correlation_id_jmespath.py | 2 +- examples/logger/src/set_correlation_id_method.py | 2 +- examples/metrics/sam/template.yaml | 2 +- examples/tracer/sam/template.yaml | 2 +- examples/tracer/src/capture_lambda_handler.py | 2 +- examples/tracer/src/capture_method.py | 2 +- examples/tracer/src/capture_method_async.py | 2 +- examples/tracer/src/capture_method_async_concurrency.py | 2 +- examples/tracer/src/capture_method_context_manager.py | 2 +- examples/tracer/src/capture_method_generators.py | 2 +- examples/tracer/src/disable_capture_error.py | 2 +- examples/tracer/src/disable_capture_response.py | 2 +- examples/tracer/src/disable_capture_response_streaming_body.py | 2 +- examples/tracer/src/ignore_endpoints.py | 2 +- examples/tracer/src/patch_modules.py | 2 +- examples/tracer/src/put_trace_annotations.py | 2 +- examples/tracer/src/put_trace_metadata.py | 2 +- examples/tracer/src/sdk_escape_hatch.py | 2 +- examples/tracer/src/tracer_reuse.py | 2 +- examples/tracer/src/tracing_aiohttp.py | 2 +- 39 files changed, 39 insertions(+), 39 deletions(-) diff --git a/examples/logger/sam/template.yaml b/examples/logger/sam/template.yaml index 546367280d4..f38efd82d3e 100644 --- a/examples/logger/sam/template.yaml +++ b/examples/logger/sam/template.yaml @@ -5,7 +5,7 @@ Description: AWS Lambda Powertools Tracer doc examples Globals: Function: Timeout: 5 - Runtime: python3.9 + Runtime: python3.10 Tracing: Active Environment: Variables: diff --git a/examples/logger/src/append_keys.py b/examples/logger/src/append_keys.py index 0ef9cbe0f63..3553f131ba0 100644 --- a/examples/logger/src/append_keys.py +++ b/examples/logger/src/append_keys.py @@ -4,7 +4,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: order_id = event.get("order_id") # this will ensure order_id key always has the latest value before logging diff --git a/examples/logger/src/append_keys_extra.py b/examples/logger/src/append_keys_extra.py index 0c66425f775..066bff9f084 100644 --- a/examples/logger/src/append_keys_extra.py +++ b/examples/logger/src/append_keys_extra.py @@ -4,7 +4,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: fields = {"request_id": "1123"} logger.info("Collecting payment", extra=fields) diff --git a/examples/logger/src/append_keys_kwargs.py b/examples/logger/src/append_keys_kwargs.py index 5885c7e2bd6..285e0c15471 100644 --- a/examples/logger/src/append_keys_kwargs.py +++ b/examples/logger/src/append_keys_kwargs.py @@ -4,7 +4,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.info("Collecting payment", request_id="1123") return "hello world" diff --git a/examples/logger/src/append_keys_vs_extra.py b/examples/logger/src/append_keys_vs_extra.py index ab67ceb6932..432dd1c23aa 100644 --- a/examples/logger/src/append_keys_vs_extra.py +++ b/examples/logger/src/append_keys_vs_extra.py @@ -12,7 +12,7 @@ class PaymentError(Exception): ... -def handler(event, context): +def lambda_handler(event, context): logger.append_keys(payment_id="123456789") charge_id = event.get("charge_id", "") diff --git a/examples/logger/src/bring_your_own_formatter_from_scratch.py b/examples/logger/src/bring_your_own_formatter_from_scratch.py index c591b421cc6..9b616595824 100644 --- a/examples/logger/src/bring_your_own_formatter_from_scratch.py +++ b/examples/logger/src/bring_your_own_formatter_from_scratch.py @@ -39,5 +39,5 @@ def format(self, record: logging.LogRecord) -> str: # noqa: A003 @logger.inject_lambda_context -def handler(event, context): +def lambda_handler(event, context): logger.info("Collecting payment") diff --git a/examples/logger/src/clear_state.py b/examples/logger/src/clear_state.py index ec842f034c1..4cfa44a3ae8 100644 --- a/examples/logger/src/clear_state.py +++ b/examples/logger/src/clear_state.py @@ -5,7 +5,7 @@ @logger.inject_lambda_context(clear_state=True) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: if event.get("special_key"): # Should only be available in the first request log # as the second request doesn't contain `special_key` diff --git a/examples/logger/src/enabling_boto_logging.py b/examples/logger/src/enabling_boto_logging.py index cce8dc6f8e7..0a5b953c603 100644 --- a/examples/logger/src/enabling_boto_logging.py +++ b/examples/logger/src/enabling_boto_logging.py @@ -12,7 +12,7 @@ client = boto3.client("s3") -def handler(event: Dict, context: LambdaContext) -> List: +def lambda_handler(event: Dict, context: LambdaContext) -> List: response = client.list_buckets() return response.get("Buckets", []) diff --git a/examples/logger/src/fake_lambda_context_for_logger_module.py b/examples/logger/src/fake_lambda_context_for_logger_module.py index fcb94f99db1..f5140febaba 100644 --- a/examples/logger/src/fake_lambda_context_for_logger_module.py +++ b/examples/logger/src/fake_lambda_context_for_logger_module.py @@ -5,7 +5,7 @@ @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.info("Collecting payment") return "hello world" diff --git a/examples/logger/src/inject_lambda_context.py b/examples/logger/src/inject_lambda_context.py index 0bdf203565d..b55133ef59b 100644 --- a/examples/logger/src/inject_lambda_context.py +++ b/examples/logger/src/inject_lambda_context.py @@ -5,7 +5,7 @@ @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.info("Collecting payment") # You can log entire objects too diff --git a/examples/logger/src/log_incoming_event.py b/examples/logger/src/log_incoming_event.py index 264a568c4ba..fb962b063c6 100644 --- a/examples/logger/src/log_incoming_event.py +++ b/examples/logger/src/log_incoming_event.py @@ -5,5 +5,5 @@ @logger.inject_lambda_context(log_event=True) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: return "hello world" diff --git a/examples/logger/src/logger_reuse.py b/examples/logger/src/logger_reuse.py index a232eadd979..db2f8a90d8b 100644 --- a/examples/logger/src/logger_reuse.py +++ b/examples/logger/src/logger_reuse.py @@ -7,7 +7,7 @@ @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: inject_payment_id(context=event) logger.info("Collecting payment") return "hello world" diff --git a/examples/logger/src/logging_exceptions.py b/examples/logger/src/logging_exceptions.py index 31df43cd663..05e5c1a1e15 100644 --- a/examples/logger/src/logging_exceptions.py +++ b/examples/logger/src/logging_exceptions.py @@ -7,7 +7,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: try: ret = requests.get(ENDPOINT) ret.raise_for_status() diff --git a/examples/logger/src/logging_inheritance_bad.py b/examples/logger/src/logging_inheritance_bad.py index 18510720d9e..0df805ccd21 100644 --- a/examples/logger/src/logging_inheritance_bad.py +++ b/examples/logger/src/logging_inheritance_bad.py @@ -10,7 +10,7 @@ @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: inject_payment_id(context=event) return "hello world" diff --git a/examples/logger/src/logging_inheritance_good.py b/examples/logger/src/logging_inheritance_good.py index f7e29d09df7..6fc9a4e0d5d 100644 --- a/examples/logger/src/logging_inheritance_good.py +++ b/examples/logger/src/logging_inheritance_good.py @@ -10,7 +10,7 @@ @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: inject_payment_id(context=event) return "hello world" diff --git a/examples/logger/src/logging_uncaught_exceptions.py b/examples/logger/src/logging_uncaught_exceptions.py index 1b43c67914a..53c8908ce01 100644 --- a/examples/logger/src/logging_uncaught_exceptions.py +++ b/examples/logger/src/logging_uncaught_exceptions.py @@ -7,7 +7,7 @@ logger = Logger(log_uncaught_exceptions=True) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: ret = requests.get(ENDPOINT) # HTTP 4xx/5xx status will lead to requests.HTTPError # Logger will log this exception before this program exits non-successfully diff --git a/examples/logger/src/remove_keys.py b/examples/logger/src/remove_keys.py index 763387d9399..5f48142564b 100644 --- a/examples/logger/src/remove_keys.py +++ b/examples/logger/src/remove_keys.py @@ -4,7 +4,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.append_keys(sample_key="value") logger.info("Collecting payment") diff --git a/examples/logger/src/sampling_debug_logs.py b/examples/logger/src/sampling_debug_logs.py index 3bbb1cdb920..042c1f4a54a 100644 --- a/examples/logger/src/sampling_debug_logs.py +++ b/examples/logger/src/sampling_debug_logs.py @@ -6,7 +6,7 @@ logger = Logger(service="payment", sample_rate=0.1) -def handler(event: dict, context: LambdaContext): +def lambda_handler(event: dict, context: LambdaContext): logger.debug("Verifying whether order_id is present") logger.info("Collecting payment") diff --git a/examples/logger/src/set_correlation_id.py b/examples/logger/src/set_correlation_id.py index 3aa0bc5f2be..eacae388d83 100644 --- a/examples/logger/src/set_correlation_id.py +++ b/examples/logger/src/set_correlation_id.py @@ -5,7 +5,7 @@ @logger.inject_lambda_context(correlation_id_path="headers.my_request_id_header") -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.debug(f"Correlation ID => {logger.get_correlation_id()}") logger.info("Collecting payment") diff --git a/examples/logger/src/set_correlation_id_jmespath.py b/examples/logger/src/set_correlation_id_jmespath.py index 049bc70a957..386115c9d2d 100644 --- a/examples/logger/src/set_correlation_id_jmespath.py +++ b/examples/logger/src/set_correlation_id_jmespath.py @@ -6,7 +6,7 @@ @logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_REST) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: logger.debug(f"Correlation ID => {logger.get_correlation_id()}") logger.info("Collecting payment") diff --git a/examples/logger/src/set_correlation_id_method.py b/examples/logger/src/set_correlation_id_method.py index 74eaa338df6..5aca939e067 100644 --- a/examples/logger/src/set_correlation_id_method.py +++ b/examples/logger/src/set_correlation_id_method.py @@ -5,7 +5,7 @@ logger = Logger() -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: request = APIGatewayProxyEvent(event) logger.set_correlation_id(request.request_context.request_id) diff --git a/examples/metrics/sam/template.yaml b/examples/metrics/sam/template.yaml index 14bb92be061..77d7db0c4ae 100644 --- a/examples/metrics/sam/template.yaml +++ b/examples/metrics/sam/template.yaml @@ -5,7 +5,7 @@ Description: AWS Lambda Powertools Metrics doc examples Globals: Function: Timeout: 5 - Runtime: python3.9 + Runtime: python3.10 Tracing: Active Environment: Variables: diff --git a/examples/tracer/sam/template.yaml b/examples/tracer/sam/template.yaml index 53f4277967a..d4e886f5506 100644 --- a/examples/tracer/sam/template.yaml +++ b/examples/tracer/sam/template.yaml @@ -5,7 +5,7 @@ Description: AWS Lambda Powertools Tracer doc examples Globals: Function: Timeout: 5 - Runtime: python3.9 + Runtime: python3.10 Tracing: Active Environment: Variables: diff --git a/examples/tracer/src/capture_lambda_handler.py b/examples/tracer/src/capture_lambda_handler.py index f5d2c1efcea..8ca2503076a 100644 --- a/examples/tracer/src/capture_lambda_handler.py +++ b/examples/tracer/src/capture_lambda_handler.py @@ -10,6 +10,6 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/capture_method.py b/examples/tracer/src/capture_method.py index edf1ed719f4..da50356b56c 100644 --- a/examples/tracer/src/capture_method.py +++ b/examples/tracer/src/capture_method.py @@ -11,6 +11,6 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/capture_method_async.py b/examples/tracer/src/capture_method_async.py index e142ef8f163..a01926ab1e1 100644 --- a/examples/tracer/src/capture_method_async.py +++ b/examples/tracer/src/capture_method_async.py @@ -14,6 +14,6 @@ async def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return asyncio.run(collect_payment(charge_id=charge_id)) diff --git a/examples/tracer/src/capture_method_async_concurrency.py b/examples/tracer/src/capture_method_async_concurrency.py index 82e89070c75..0afd965d35e 100644 --- a/examples/tracer/src/capture_method_async_concurrency.py +++ b/examples/tracer/src/capture_method_async_concurrency.py @@ -26,6 +26,6 @@ async def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return asyncio.run(collect_payment(charge_id=charge_id)) diff --git a/examples/tracer/src/capture_method_context_manager.py b/examples/tracer/src/capture_method_context_manager.py index 083443607ac..9dc6716e69e 100644 --- a/examples/tracer/src/capture_method_context_manager.py +++ b/examples/tracer/src/capture_method_context_manager.py @@ -19,7 +19,7 @@ def collect_payment(charge_id: str) -> Generator[str, None, None]: @tracer.capture_lambda_handler @logger.inject_lambda_context -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") with collect_payment(charge_id=charge_id) as receipt_id: logger.info(f"Processing payment collection for charge {charge_id} with receipt {receipt_id}") diff --git a/examples/tracer/src/capture_method_generators.py b/examples/tracer/src/capture_method_generators.py index 65b87c251e8..7c02f810a27 100644 --- a/examples/tracer/src/capture_method_generators.py +++ b/examples/tracer/src/capture_method_generators.py @@ -12,6 +12,6 @@ def collect_payment(charge_id: str) -> Generator[str, None, None]: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return next(collect_payment(charge_id=charge_id)) diff --git a/examples/tracer/src/disable_capture_error.py b/examples/tracer/src/disable_capture_error.py index 7b7d7e6ad23..59fc2d2376a 100644 --- a/examples/tracer/src/disable_capture_error.py +++ b/examples/tracer/src/disable_capture_error.py @@ -24,7 +24,7 @@ def collect_payment(charge_id: str) -> dict: @tracer.capture_lambda_handler(capture_error=False) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") ret = collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/disable_capture_response.py b/examples/tracer/src/disable_capture_response.py index ffe8230eece..7e3554c4d81 100644 --- a/examples/tracer/src/disable_capture_response.py +++ b/examples/tracer/src/disable_capture_response.py @@ -13,6 +13,6 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler(capture_response=False) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/disable_capture_response_streaming_body.py b/examples/tracer/src/disable_capture_response_streaming_body.py index 3e458a98eb4..fe9b74713d1 100644 --- a/examples/tracer/src/disable_capture_response_streaming_body.py +++ b/examples/tracer/src/disable_capture_response_streaming_body.py @@ -24,7 +24,7 @@ def fetch_payment_report(payment_id: str) -> StreamingBody: @tracer.capture_lambda_handler(capture_response=False) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: payment_id = event.get("payment_id", "") report = fetch_payment_report(payment_id=payment_id) return report.read().decode() diff --git a/examples/tracer/src/ignore_endpoints.py b/examples/tracer/src/ignore_endpoints.py index 6484cfcf5b0..0fe256aeee9 100644 --- a/examples/tracer/src/ignore_endpoints.py +++ b/examples/tracer/src/ignore_endpoints.py @@ -28,7 +28,7 @@ def collect_payment(charge_id: str) -> dict: @tracer.capture_lambda_handler(capture_error=False) -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") ret = collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/patch_modules.py b/examples/tracer/src/patch_modules.py index 09e7092a85a..e547951d746 100644 --- a/examples/tracer/src/patch_modules.py +++ b/examples/tracer/src/patch_modules.py @@ -9,7 +9,7 @@ @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: ret = requests.get("https://httpbin.org/get") ret.raise_for_status() diff --git a/examples/tracer/src/put_trace_annotations.py b/examples/tracer/src/put_trace_annotations.py index 0d9455c7acd..5c31b384e9d 100644 --- a/examples/tracer/src/put_trace_annotations.py +++ b/examples/tracer/src/put_trace_annotations.py @@ -10,6 +10,6 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/put_trace_metadata.py b/examples/tracer/src/put_trace_metadata.py index 23b6753677c..cf53b867b37 100644 --- a/examples/tracer/src/put_trace_metadata.py +++ b/examples/tracer/src/put_trace_metadata.py @@ -9,7 +9,7 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: payment_context = { "charge_id": event.get("charge_id", ""), "merchant_id": event.get("merchant_id", ""), diff --git a/examples/tracer/src/sdk_escape_hatch.py b/examples/tracer/src/sdk_escape_hatch.py index 7f046caff9d..e7024016697 100644 --- a/examples/tracer/src/sdk_escape_hatch.py +++ b/examples/tracer/src/sdk_escape_hatch.py @@ -9,7 +9,7 @@ def collect_payment(charge_id: str) -> str: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") with tracer.provider.in_subsegment("## collect_payment") as subsegment: subsegment.put_annotation(key="PaymentId", value=charge_id) diff --git a/examples/tracer/src/tracer_reuse.py b/examples/tracer/src/tracer_reuse.py index bdfe7bc9d91..d38f22f6871 100644 --- a/examples/tracer/src/tracer_reuse.py +++ b/examples/tracer/src/tracer_reuse.py @@ -7,6 +7,6 @@ @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> str: +def lambda_handler(event: dict, context: LambdaContext) -> str: charge_id = event.get("charge_id", "") return collect_payment(charge_id=charge_id) diff --git a/examples/tracer/src/tracing_aiohttp.py b/examples/tracer/src/tracing_aiohttp.py index 45fe6a46f38..7fb54a8502c 100644 --- a/examples/tracer/src/tracing_aiohttp.py +++ b/examples/tracer/src/tracing_aiohttp.py @@ -20,6 +20,6 @@ async def collect_payment(charge_id: str) -> dict: @tracer.capture_lambda_handler -def handler(event: dict, context: LambdaContext) -> dict: +def lambda_handler(event: dict, context: LambdaContext) -> dict: charge_id = event.get("charge_id", "") return asyncio.run(collect_payment(charge_id=charge_id))