@@ -320,9 +320,7 @@ Let's include Lambda Powertools as a dependency in `requirement.txt`, and use Ev
320
320
321
321
=== "app.py"
322
322
323
- ```python hl_lines="3 5 8 13 19"
324
- import json
325
-
323
+ ```python hl_lines="1 3 6 11 17"
326
324
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
327
325
328
326
app = ApiGatewayResolver()
@@ -375,13 +373,11 @@ The first option could be to use the standard Python Logger, and use a specializ
375
373
376
374
=== "app.py"
377
375
378
- ```python hl_lines="2 5 9-14 21 27 32"
379
- import json
376
+ ```python hl_lines="4 5 7-12 19 25 30"
380
377
import logging
381
378
import os
382
379
383
380
from pythonjsonlogger import jsonlogger
384
-
385
381
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
386
382
387
383
logger = logging.getLogger("APP")
@@ -454,9 +450,7 @@ We could start by creating a dictionary with Lambda context information or somet
454
450
455
451
As we already have Lambda Powertools as a dependency, we can simply import [ Logger] ( ./core/logger.md ) {target="_ blank"}.
456
452
457
- ``` python title="Refactoring with Lambda Powertools Logger" hl_lines="3 5 7 14 20 24"
458
- import json
459
-
453
+ ``` python title="Refactoring with Lambda Powertools Logger" hl_lines="1 3 5 12 18 22"
460
454
from aws_lambda_powertools import Logger
461
455
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
462
456
from aws_lambda_powertools.logging import correlation_paths
@@ -535,9 +529,7 @@ It's a [two-step process](https://docs.aws.amazon.com/lambda/latest/dg/services-
535
529
536
530
=== "app.py"
537
531
538
- ```python hl_lines="3 12 16 23 30"
539
- import json
540
-
532
+ ```python hl_lines="1 10 14 21 28"
541
533
from aws_xray_sdk.core import patch_all, xray_recorder
542
534
543
535
from aws_lambda_powertools import Logger
@@ -648,9 +640,7 @@ Within AWS X-Ray, we can answer these questions by using two features: tracing *
648
640
649
641
Let's put them into action.
650
642
651
- ``` python title="Enriching traces with annotations and metadata" hl_lines="12 19-20 28-29 37 39-44 47"
652
- import json
653
-
643
+ ``` python title="Enriching traces with annotations and metadata" hl_lines="10 17-19 26-27 35 37-42 45"
654
644
from aws_xray_sdk.core import patch_all, xray_recorder
655
645
656
646
from aws_lambda_powertools import Logger
@@ -729,9 +719,7 @@ We can simplify our previous patterns by using [Lambda Powertools Tracer](core/t
729
719
!!! note
730
720
You can now safely remove ` aws-xray-sdk ` from ` requirements.txt ` ; keep ` aws-lambda-powertools ` only.
731
721
732
- ``` python title="Refactoring with Lambda Powertools Tracer" hl_lines="3 8 13 15 21 23 29"
733
- import json
734
-
722
+ ``` python title="Refactoring with Lambda Powertools Tracer" hl_lines="1 6 11 13 19 21 27"
735
723
from aws_lambda_powertools import Logger, Tracer
736
724
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
737
725
from aws_lambda_powertools.logging import correlation_paths
0 commit comments