outgoing_webhook: Add a logging statement for each outgoing webhook.

This will help determine potentail timeout lengths, as well as serve
as a generally-useful log for locations which do not have Smokescreen
enabled.

In service of #17742.
This commit is contained in:
Alex Vandiver
2021-04-28 15:28:43 -07:00
committed by Tim Abbott
parent 03e155f38a
commit 8711ab7676
2 changed files with 50 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import abc
import json
import logging
from time import perf_counter
from typing import Any, AnyStr, Dict, Optional
import requests
@@ -317,10 +318,18 @@ def do_rest_call(
) -> Optional[Response]:
"""Returns response of call if no exception occurs."""
try:
start_time = perf_counter()
response = service_handler.make_request(
base_url,
event,
)
bot_profile = service_handler.user_profile
logging.info(
"Outgoing webhook request from %s@%s took %f seconds",
bot_profile.id,
bot_profile.realm.string_id,
perf_counter() - start_time,
)
if not response:
return None
if str(response.status_code).startswith("2"):