|
@@ -449,9 +449,10 @@ class ToTextBotAgent:
|
|
|
# try:
|
|
|
session.headers.update({'Content-Type': 'application/json'})
|
|
|
while try_count > 0:
|
|
|
+ once_start = time.time()
|
|
|
try:
|
|
|
try_count = try_count - 1
|
|
|
- response = session.post(url=url, json=json.loads(request_data), timeout=.5)
|
|
|
+ response = session.post(url=url, json=json.loads(request_data), timeout=.8)
|
|
|
# response = requests.post(url=url, json=json.loads(request_data), headers=headers, timeout=10) # 使用占位URL
|
|
|
if response.status_code == 200:
|
|
|
response_data = response.json()
|
|
@@ -467,6 +468,9 @@ class ToTextBotAgent:
|
|
|
except requests.RequestException as e:
|
|
|
traceback.print_exc()
|
|
|
self.call_agent.logger.error(f"TaskId={request.taskId}, 请求发生异常: {e}, URL: {url}")
|
|
|
+ finally:
|
|
|
+ latency = (time.time() - once_start)
|
|
|
+ registry.BOT_REQUEST_ONCE_LATENCY.labels(request.taskId).observe(latency)
|
|
|
if not response or response.status_code != 200:
|
|
|
massage = self.get_default_response()
|
|
|
self.call_agent.message_queue.put(massage)
|