Skip to content

Commit

Permalink
fix(verbose_logging): exclude auth and headers on errors
Browse files Browse the repository at this point in the history
also json dump params
  • Loading branch information
lucas03 committed Aug 20, 2024
1 parent 9c0317c commit 5c8f4e3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions request_session/request_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _process(
max_runs = 1 + (self.max_retries if max_retries is None else max_retries)
run, retries_on_econnreset = 0, 0
# this will set maximum number of retries to max_runs where econnreset retries
# are not counting and maximum number of of retries on econnreset is also
# are not counting and maximum number of retries on econnreset is also
# set to max_runs
while run < max_runs + retries_on_econnreset:
run += 1
Expand Down Expand Up @@ -480,11 +480,11 @@ def _log_with_params(
"""
extra_params = (
{
"request_params": {
"request_params": json.dumps({
k: v
for k, v in deepcopy(request_params).items()
if k not in self.request_param_logging_blacklist
},
}),
"response_text": self.get_response_text(response),
}
if self.verbose_logging
Expand Down Expand Up @@ -557,11 +557,11 @@ def _exception_log_and_metrics(
# type: (...) -> None
"""Assign appropriate metric and log for exception.
:param requests.RequestException error: exception that occured
:param requests.RequestException error: exception that occurred
:param str request_category: String describing request category.
:param Dict request_params: Parameters used to make the HTTP call.
:param List[str] dd_tags: Tags to increment metric with.
:param Union[int, None] Status_code: HTTP status code of the response.
:param Union[int, None] status_code: HTTP status code of the response.
"""
tags = ["status:error"]

Expand All @@ -586,7 +586,11 @@ def _exception_log_and_metrics(
tags.append("error:request_exception")

if self.verbose_logging is True:
extra_params["request_params"] = json.dumps(request_params)
extra_params["request_params"] = json.dumps({
k: v
for k, v in deepcopy(request_params).items()
if k not in self.request_param_logging_blacklist
})

self.log(
"exception",
Expand Down

0 comments on commit 5c8f4e3

Please sign in to comment.