-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,456 additions
and
334 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Logger configurations | ||
import logging | ||
|
||
|
||
class LoggingConfiguration: | ||
@staticmethod | ||
def configure_request_logger(logger): | ||
console_handler = logging.StreamHandler() | ||
console_handler.setLevel(logging.INFO) | ||
console_handler.setFormatter( | ||
logging.Formatter("%(asctime)s %(message)s | Status: %(status)s | Headers: %(headers)s ") | ||
) | ||
logger.addHandler(console_handler) | ||
logger.propagate = False |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Utils for requests | ||
|
||
# Relevant headers that should be captured for debugging | ||
AMAZON_HEADERS = [ | ||
"x-amzn-requestid", | ||
"x-amz-apigw-id", | ||
"x-amz-cf-id", | ||
"x-amzn-errortype", | ||
"apigw-requestid", | ||
] | ||
|
||
|
||
class RequestUtils: | ||
def __init__(self, response): | ||
self.response = response | ||
self.headers = self._normalize_response_headers() | ||
|
||
def get_amazon_headers(self): | ||
""" | ||
Get a list of relevant amazon headers that could be useful for debugging | ||
""" | ||
amazon_headers = {} | ||
for header, header_val in self.headers.items(): | ||
if header in AMAZON_HEADERS: | ||
amazon_headers[header] = header_val | ||
return amazon_headers | ||
|
||
def _normalize_response_headers(self): | ||
""" | ||
API gateway can return headers with letters in different cases i.e. x-amzn-requestid or x-amzn-requestId | ||
We make them all lowercase here to more easily match them up | ||
""" | ||
if self.response is None or not self.response.headers: | ||
# Need to check for response is None here since the __bool__ method checks 200 <= status < 400 | ||
return {} | ||
|
||
return dict((k.lower(), v) for k, v in self.response.headers.items()) |
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.46.0" | ||
__version__ = "1.47.0" |
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
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
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
Oops, something went wrong.