Created
April 16, 2018 10:46
-
-
Save galbash/9398c2954e230569b13b65588459641b to your computer and use it in GitHub Desktop.
Instruments all Lambda invocations
This file contains 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
import wrapt | |
def wrapper(wrapped, instance, args, kwargs): | |
""" | |
Wrap all Lambda invocations and prints a log before calling it. | |
""" | |
request_handler = args[0] | |
def _wrapper(event, context): | |
print 'This is a log' | |
return request_handler(event, context) | |
return wrapped(_wrapper, *args[1:], **kwargs) | |
wrapt.wrap_function_wrapper('__main__', 'handle_event_request', wrapper) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment