Skip to content

How correctly log AWS Lambda event with lambda powertools #1769

Closed Answered by heitorlessa
macdrorepo asked this question in Q&A
Discussion options

You must be logged in to vote

So that would be correct order of decorators?

That's right!

edit: Also that means @LOGGER.inject_lambda_context(log_event=True) must on top of all decorators if I would use more of them?

No. This is only the case for event_source and parser decorators (or your own in the future) that modify the "event" dictionary in-place.

NOTE: I'll convert this discussion into a documentation issue as we can do better.

If we were to break it down, a mental model for decorators works like this, since the "@" is a syntactic sugar:

  1. Modifies the event as dict into a SNS Data Class when called
handler = event_source(handler(event, context))
  1. We log the event and extract key info from context. We do n…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@macdrorepo
Comment options

@heitorlessa
Comment options

@macdrorepo
Comment options

@heitorlessa
Comment options

Answer selected by heitorlessa
@macdrorepo
Comment options

@heitorlessa
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants