-
Notifications
You must be signed in to change notification settings - Fork 433
feat(logger): new stack_trace field with rich exception details #3147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
163b908
Added optional stack trace to exception logging. Issue 1268
stevrobu 3ad3c76
Added tests and documentation
stevrobu 5436377
Added tests and documentation.
stevrobu dda7593
Merge branch 'develop' into develop
leandrodamascena c57a77b
Merge branch 'develop' into develop
leandrodamascena faf838f
Updated the tests, serialization method and renamed the parameter
stevrobu fee5479
Removed dead code
stevrobu 2a47946
Merge branch 'develop' into develop
leandrodamascena 6d5f148
Removed env variable and default stack trace logging to True
stevrobu 0b79f69
Merge branch 'develop' of https://github.com/stevrobu/powertools-lamb…
stevrobu 2ddfde9
Small changes
leandrodamascena 9307e9d
Removing wrong field
leandrodamascena 8eba534
Adjusting tests
leandrodamascena b7294cb
Merge branch 'develop' into develop
leandrodamascena ed2a3c5
Adjusting documentation
leandrodamascena e2bc82e
Merge branch 'develop' into develop
leandrodamascena d24a566
Addressing Ruben's feedback
leandrodamascena 8c1831e
Addressing Ruben's feedback
leandrodamascena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import requests | ||
|
||
from aws_lambda_powertools import Logger | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
ENDPOINT = "http://httpbin.org/status/500" | ||
logger = Logger(serialize_stacktrace=True) | ||
|
||
|
||
def lambda_handler(event: dict, context: LambdaContext) -> str: | ||
try: | ||
ret = requests.get(ENDPOINT) | ||
ret.raise_for_status() | ||
except requests.HTTPError as e: | ||
logger.exception(e) | ||
raise RuntimeError("Unable to fullfil request") from e | ||
|
||
return "hello world" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"level":"ERROR", | ||
"location":"lambda_handler:16", | ||
"message":"500 Server Error: INTERNAL SERVER ERROR for url: http://httpbin.org/status/500", | ||
"timestamp":"2023-10-09 17:47:50,191+0000", | ||
"service":"service_undefined", | ||
"exception":"Traceback (most recent call last):\n File \"/var/task/app.py\", line 14, in lambda_handler\n ret.raise_for_status()\n File \"/var/task/requests/models.py\", line 1021, in raise_for_status\n raise HTTPError(http_error_msg, response=self)\nrequests.exceptions.HTTPError: 500 Server Error: INTERNAL SERVER ERROR for url: http://httpbin.org/status/500", | ||
"exception_name":"HTTPError", | ||
"stack_trace":{ | ||
"type":"HTTPError", | ||
"value":"500 Server Error: INTERNAL SERVER ERROR for url: http://httpbin.org/status/500", | ||
"module":"requests.exceptions", | ||
"frames":[ | ||
{ | ||
"file":"/var/task/app.py", | ||
"line":14, | ||
"function":"lambda_handler", | ||
"statement":"ret.raise_for_status()" | ||
}, | ||
{ | ||
"file":"/var/task/requests/models.py", | ||
"line":1021, | ||
"function":"raise_for_status", | ||
"statement":"raise HTTPError(http_error_msg, response=self)" | ||
} | ||
] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.