DavidLiu 3 months ago
parent
commit
4517c864cd

+ 2 - 0
src/core/callcenter/call.py

@@ -4,6 +4,7 @@ import json
 import time
 from datetime import datetime
 
+from src.core.callcenter import registry
 from src.core.callcenter.agent import AgentMonitorService, AgentActionLogService
 from src.core.callcenter.cache import Cache
 from src.core.callcenter.constant import saasId, HOLD_MUSIC_PATH
@@ -86,6 +87,7 @@ class CallService:
         self.client.bridge_call(call_info.call_id, call_info.device_list[0], call_info.device_list[1])
 
     def transfer(self, call_info: CallInfo, agent_number, service_id):
+        registry.CALL_TRANSFER_REQUESTS.labels(f"{call_info.bucket_type}").inc()
         caller = call_info.called
         call_id = call_info.call_id
         agent = self.cache.get_agent_info(call_info.saas_id, agent_number)

+ 1 - 0
src/core/callcenter/esl/handler/channel_answer_handler.py

@@ -28,6 +28,7 @@ class ChannelAnswerHandler(EslEventHandler):
         if not call_info:
             return
 
+        registry.CALL_ANSWER_REQUESTS.labels(f"{call_info.bucket_type}").inc()
         device_id = EslEventUtil.getDeviceId(event)
         device_info = call_info.device_info_map.get(device_id)
         if CallType.AGENT_CALL.code == call_info.call_type and device_info.device_type == DeviceType.CUSTOMER.code:

+ 2 - 0
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -45,6 +45,7 @@ class ChannelHangupHandler(EslEventHandler):
                 self.release(event)
                 self.logger.info("call_info:%s is null", call_id)
                 return
+
             device_id = EslEventUtil.getDeviceId(event)
             device_id = device_id if device_id else EslEventUtil.getUniqueId(event)
             device_info = call_info.device_info_map.get(device_id)
@@ -90,6 +91,7 @@ class ChannelHangupHandler(EslEventHandler):
                 device_info.record_time = int(device_info.end_time) - int(device_info.record_start_time)
             call_info.device_info_map[device_info.device_id] = device_info
             skip_hangup_all = device_info.device_type == DeviceType.ROBOT.code
+            registry.CALL_HANGUP_REQUESTS.labels(f"{call_info.bucket_type}", f"{device_info.sip_status}").inc()
 
             self.logger.info('ChannelHangupHandler, hangup_reason=%s, device_type=%s, cdr_type=%s, end_time=%s, skip_hangup_all=%s' % (hangup_reason, device_info.device_type, device_info.cdr_type, call_info.end_time, skip_hangup_all))
             # 如果是转人工

+ 3 - 0
src/core/callcenter/registry.py

@@ -12,8 +12,11 @@ from prometheus_flask_exporter import PrometheusMetrics
 metrics = PrometheusMetrics(app)
 # 呼入总量
 CALL_INCOMING_REQUESTS = Counter('call_incoming_requests', '呼入总流量', ['bucket'])
+CALL_ANSWER_REQUESTS = Counter('call_answer_requests', '总接听量', ['bucket'])
 CALL_BOT_ANSWER_REQUESTS = Counter('call_bot_answer_requests', '机器人接听量', ['bucket'])
+CALL_TRANSFER_REQUESTS = Counter('call_transfer_requests', '总转人量', ['bucket'])
 CALL_BOT_TRANSFER_REQUESTS = Counter('call_bot_transfer_requests', '机器转人量', ['bucket'])
+CALL_HANGUP_REQUESTS = Counter('call_hangup_requests', '总挂机量', ['bucket','sip_status'])
 CALL_BOT_HANGUP_REQUESTS = Counter('call_bot_hangup_requests', '机器人挂机量', ['bucket','sip_status'])
 CALL_BOT_NO_ANSWER_ERROR_REQUESTS = Counter('call_bot_no_answer_error_requests', '机器人未接听异常数', ['bucket','sip_status'])