Skip to content

Key have been removed from logger in lambda layer #1087

Closed

Description

@HAK-CODE

What were you trying to accomplish?
Was trying to filter logs based on log level i.e INFO, WARN etc

Expected Behavior

arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:7

{
    "level": "INFO",
    "location": "lambda_handler:44",
    "message": "info message",
    "timestamp": "2022-04-01 04:41:43,576+0000",
    "service": "state-monitoring-service",
    "cold_start": true,
    "function_name": "site-state-monitoring-service",
    "function_memory_size": "128",
    "function_arn": "arn:aws:lambda:us-east-2:xxxxxxxxxxx:function:site-state-monitoring-service",
    "function_request_id": "2b37a8b5-35d0-47e7-baf9-6ee75c531c60",
    "xray_trace_id": "1-62468286-269844d9186d7242176fb362"
}

Current Behavior

arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:15

{
    "message": "info message",
    "service": "state-monitoring-service",
    "cold_start": true,
    "function_name": "site-state-monitoring-service",
    "function_memory_size": "128",
    "function_arn": "arn:aws:lambda:us-east-2:xxxxxxxxxxx:function:site-state-monitoring-service",
    "function_request_id": "cc1eba4c-3033-4112-9361-afaf028e22b5",
    "xray_trace_id": "1-624681d2-6b01a06a0559627628346348"
}

Current Behavior

Keys missing in current layer arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:15

level
location
timestamp

Steps to Reproduce (for bugs)

  1. Set the current layer arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:15

Environment

  • Powertools version used: via Layer
  • Packaging format (Layers, PyPi): arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:15
  • AWS Lambda function runtime: 3.9

Activity

  1. added
    bug
    triage
    on Apr 1, 2022
  2. boring-cyborg commented on Apr 1, 2022

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.

  3. HAK-CODE commented on Apr 1, 2022

    @HAK-CODE
    Author
    from aws_lambda_powertools import Logger
    logger = Logger()
    
    @logger.inject_lambda_context(clear_state=True)
    def lambda_handler(event, context):
        """[process the event records to update the cache]
    
        Args:
            event ([dict]): [input event to lambda]
            context ([dict]): [input context of lambda]
    
        Returns:
            [boolean]: [return the lambda handler to service]
        """
        logger.info("info message")
        logger.warning("warning message")
        return "response"
    
  4. HAK-CODE commented on Apr 1, 2022

    @HAK-CODE
    Author

    same goes for catching exceptions.

  5. heitorlessa commented on Apr 1, 2022

    @heitorlessa
    Contributor

    Hi @HAK-CODE thanks for filing this bug report - It's a regression we are working on a patch release today -- it's happening when you use clear_state=True.

    Also reported in #1084, and this regression was introduced when fixing a problem with custom formatters in 1.25.3.

  6. added
    pending-release
    and removed
    triage
    on Apr 1, 2022
  7. github-actions commented on Apr 1, 2022

    @github-actions
    Contributor

    This is now released under 1.25.6 version!

  8. removed
    pending-release
    on Apr 1, 2022
  9. heitorlessa commented on Apr 1, 2022

    @heitorlessa
    Contributor

    Thanks to your bug report we managed to reproduce and improved tests as part of the fix - the latest version 1.25.6 has this fix now. Lambda Layers upcoming version 16 will take a few hours to be available in multiple AWS commercial regions.

  10. heitorlessa commented on Apr 1, 2022

    @heitorlessa
    Contributor

    @HAK-CODE Lambda Layer version 16 is now available with the fix - Please let us know otherwise.

    arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:16

  11. HAK-CODE commented on Apr 1, 2022

    @HAK-CODE
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions