Skip to content
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

feat(logging): Include exception_name #320

Merged
merged 3 commits into from
Mar 9, 2021

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Mar 9, 2021

Description of changes:

Add exception_name to the logging

Example:

from aws_lambda_powertools import Logger
logger = Logger()

try:
        raise ValueError("something went wrong")
except Exception:
        logger.exception("Received an exception")

Would log out :

{
       "level": "ERROR",
       "location": "<module>:4",
       "message": "Received an exception",
       "timestamp": "2020-08-28 18:11:38,886",
       "service": "service_undefined",
       "sampling_rate": 0.0,
       "exception_name":"ValueError",
       "exception": "Traceback (most recent call last):\n  File \"<input>\", line 2, in <module>\nValueError: something went wrong"
}

Checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@heitorlessa heitorlessa added the feature New feature or functionality label Mar 9, 2021
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - We can add either in this or in another PR a mention that the name of the exception will be available in another record to ease analysis exceptions over time: https://awslabs.github.io/aws-lambda-powertools-python/core/logger/#logging-exceptions

@michaelbrewer michaelbrewer marked this pull request as ready for review March 9, 2021 15:46
@heitorlessa heitorlessa self-assigned this Mar 9, 2021
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have that one - been long overdue for me too. I'll make a PR before we release it to add a sample in the docs on how to create stats for it :)

Thank you again!

@heitorlessa heitorlessa merged commit 0ec47dc into aws-powertools:develop Mar 9, 2021
@heitorlessa heitorlessa added this to the 1.12.0 milestone Mar 9, 2021
heitorlessa added a commit that referenced this pull request Mar 9, 2021
…tools-python into develop

* 'develop' of https://github.com/awslabs/aws-lambda-powertools-python:
  feat(logging): Include exception_name (#320)
  chore: remove gatsby mention as migrated completed
  refactor(parameters): Consistently reference env (#319)
  docs(metrics): remove minimum dimensions
  docs: Correct code examples (#317)
  docs(metrics): Correct code examples in markdown (#316)
  fix(idempotency): TypeError when calling is_missing_idempotency_key with an int (#315)
  docs(metrics): Corrections to the code examples (#314)
  fix(idempotency): Correctly handle save_inprogress errors (#313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants