Kaynağa Gözat

metric tools debug

DavidLiu 4 ay önce
ebeveyn
işleme
10d18da013
2 değiştirilmiş dosya ile 15 ekleme ve 13 silme
  1. 5 3
      src/core/callcenter/api.py
  2. 10 10
      src/core/callcenter/esl/client.py

+ 5 - 3
src/core/callcenter/api.py

@@ -445,8 +445,8 @@ class CallInfo(BaseApi):
                  call_time=None, call_type=None, direction=None, answer_flag=None, wait_time=None, answer_count=0,
                  hangup_dir=None, sdk_hangup=0, hangup_code=None, answer_time=None, end_time=None, talk_time=None,
                  first_queue_time=None, queue_start_time=None, queue_end_time=None, overflow_count=0,
-                 uuid1=None, uuid2=None, cdr_notify_url=None, queue_level=None, transfer_agent=None, user_no_answer_end_call=False, device_list=[],
-                 device_info_map: Dict[str, Any] = {}, follow_data: Dict[str, Any] = {},
+                 uuid1=None, uuid2=None, cdr_notify_url=None, queue_level=None, transfer_agent=None, bucket_type=None,
+                 user_no_answer_end_call=False, device_list=[], device_info_map: Dict[str, Any] = {}, follow_data: Dict[str, Any] = {},
                  process_data: Dict[str, Any] = {}, next_commands=[], call_details=[]):
         self.core_uuid = core_uuid  # 通话唯一标识
         self.cti_flow_id = cti_flow_id
@@ -492,6 +492,7 @@ class CallInfo(BaseApi):
         self.cdr_notify_url = cdr_notify_url  # 话单通知地址
         self.queue_level = queue_level  # 排队等级,默认是进队列时间
         self.transfer_agent = transfer_agent #是否转人工
+        self.bucket_type = bucket_type #呼入流量类型
         self.user_no_answer_end_call = user_no_answer_end_call #用户未接听挂机
         self.device_list = device_list  # 当前通话的设备
         self.device_info_map = device_info_map
@@ -526,7 +527,7 @@ class CallInfo(BaseApi):
                    queue_end_time=data.get('queue_end_time'), overflow_count=data.get('overflow_count'),
                    uuid1=data.get('uuid1'), uuid2=data.get('uuid2'), cdr_notify_url=data.get('cdr_notify_url'),
                    queue_level=data.get('queue_level'), transfer_agent=data.get('transfer_agent'),
-                   user_no_answer_end_call=data.get('user_no_answer_end_call'),
+                   bucket_type=data.get('bucket_type'), user_no_answer_end_call=data.get('user_no_answer_end_call'),
                    device_list=data.get('device_list', []),device_info_map=device_info_map,
                    follow_data=follow_data, process_data=process_data,
                    next_commands=next_commands, call_details=call_details)
@@ -580,6 +581,7 @@ class CallInfo(BaseApi):
             "cdr_notify_url": self.cdr_notify_url,
             "queue_level": self.queue_level,
             "transfer_agent": self.transfer_agent,
+            "bucket_type": self.bucket_type,
             "user_no_answer_end_call": self.user_no_answer_end_call,
             "device_list": [x for x in self.device_list],
             "device_info_map": {key: vars(value) for key, value in self.device_info_map.items()},

+ 10 - 10
src/core/callcenter/esl/client.py

@@ -519,30 +519,30 @@ class OutboundClient:
                     kwargs['variable_sip_h_P-LIBRA-CallId'] = call_id
                     kwargs['variable_sip_h_P-LIBRA-DeviceId'] = new_device_id
 
-                    _call_type = 2
+                    _bucket_call_type = 2
                     destination = None
                     bucket = self.server.get_bucket(call_id)
                     whitelist = self.server.get_whitelist()
                     if bucket and bucket.name == 'AI':
                         #转到ai机器人
-                        _call_type = 1
+                        _bucket_call_type = 1
                         destination = self.server.agent.register(**kwargs)
                         self.server.logger.info("device_id=%s, destination=%s, new_device_id=%s" % (device_id, destination, new_device_id))
-                        self.build_call_info(call_id, device_id, new_device_id, str(destination), **kwargs)
+                        self.build_call_info(call_id, device_id, new_device_id, str(destination), _bucket_call_type, **kwargs)
                         self.server.cache.add_device_user_part(device_id, destination)
                         con.execute("bridge", "{sip_h_P-LIBRA-CallId=%s,sip_h_P-LIBRA-DeviceId=%s,origination_uuid=%s}user/%s" % (call_id, new_device_id, new_device_id, destination), device_id)
                     elif caller_number in whitelist:
                         # 检查白名单
-                        _call_type = 0
-                        self.build_call_info(call_id, device_id, new_device_id, destination=None, **kwargs)
+                        _bucket_call_type = 0
+                        self.build_call_info(call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
                         self.server.agent.acd_service.transfer_to_agent(call_id, new_device_id)
                     else:
                         # 传统服务
-                        self.build_call_info(call_id, device_id, new_device_id, destination=None, **kwargs)
+                        self.build_call_info(call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type,  **kwargs)
                         self.server.agent.acd_service.transfer_to_agent(call_id, new_device_id)
 
-                    Registry.counter('call_incoming_requests', '呼入流量统计', ['call_type', str(_call_type)]).inc()
-                    self.server.dataHandleServer.create_record(call_id, caller_number, _call_type, service_category=None, destination=destination)
+                    Registry.counter('call_incoming_requests', '呼入流量统计', ['bucket_type', str(_bucket_call_type)]).inc()
+                    self.server.dataHandleServer.create_record(call_id, caller_number, _bucket_call_type, service_category=None, destination=destination)
 
                     # # 检查白名单
                     # if caller_number in whitelist:
@@ -589,7 +589,7 @@ class OutboundClient:
             except:
                 traceback.print_exc()
 
-        def build_call_info(self, call_id, device_id, new_device_id, destination, **kwargs):
+        def build_call_info(self, call_id, device_id, new_device_id, destination, bucket_type, **kwargs):
             caller = kwargs.get('Channel-Caller-ID-Number')
             called = destination
             now = datetime.utcnow().timestamp()
@@ -597,7 +597,7 @@ class OutboundClient:
             call_info = CallInfo(call_id=call_id, agent_key=destination,
                                  caller=caller, called=called, direction=Direction.INBOUND.code,
                                  call_type=CallType.BOT_CALL.code, call_time=now,
-                                 uuid1=call_id, uuid2=device_id, saas_id=saasId,
+                                 uuid1=call_id, uuid2=device_id, saas_id=saasId, bucket_type=bucket_type,
                                  core_uuid=None, cti_flow_id=None, conference=None, group_id=None, hidden_customer=0, caller_display=None, called_display=None, number_location=None, agent_name=None, login_type=None, ivr_id=None, task_id=None, media_host=None, sip_server=None, client_host=None, record=None, record2=None, record_time=None, answer_flag=None, wait_time=None, answer_count=0, hangup_dir=None, sdk_hangup=0, hangup_code=None, answer_time=None, end_time=None, talk_time=None, first_queue_time=None, queue_start_time=None, queue_end_time=None, overflow_count=0, cdr_notify_url=None, queue_level=None, transfer_agent=None,device_list=[], device_info_map = {}, follow_data = {}, process_data = {}, next_commands=[], call_details=[])
             device_custom = DeviceInfo(device_id=device_id, call_time=now,
                                      call_id=call_id, device_type=DeviceType.CUSTOMER.code,