Переглянути джерело

add esl event latency,fix

Davidliu 1 місяць тому
батько
коміт
c510bf47d9

+ 4 - 4
src/core/callcenter/agent.py

@@ -177,9 +177,9 @@ class AgentEventService:
         except:
             traceback.print_exc()
         finally:
-            time_cost = time.time() - start_time
+            time_cost = (time.time() - start_time) * 1000
             registry.ESL_EVENT_CALLBACK_COST.labels(event_name, "agent").observe(time_cost)
-            latency = time.time() - event_timestamp
+            latency = (time.time() - event_timestamp) * 1000
             registry.ESL_EVENT_CALLBACK_LATENCY.labels(event_name, "agent").observe(latency)
 
     def bot_event_channel(self, event, call_info, device_info):
@@ -246,9 +246,9 @@ class AgentEventService:
         except:
             traceback.print_exc()
         finally:
-            time_cost = time.time() - start_time
+            time_cost = (time.time() - start_time) * 1000
             registry.ESL_EVENT_CALLBACK_COST.labels(event_name, "bot").observe(time_cost)
-            latency = time.time() - event_timestamp
+            latency = (time.time() - event_timestamp) * 1000
             registry.ESL_EVENT_CALLBACK_LATENCY.labels(event_name, "bot").observe(latency)
 
     def reprocessing_idle(self, state_data: AgentDelayStateData):

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

@@ -143,9 +143,9 @@ class InboundClient:
         except:
             traceback.print_exc()
         finally:
-            time_cost = time.time() - start_time
+            time_cost = (time.time() - start_time) * 1000
             registry.ESL_EVENT_COST.labels(event_name).observe(time_cost)
-            latency = time.time() - event_timestamp
+            latency = (time.time() - event_timestamp) * 1000
             registry.ESL_EVENT_LATENCY.labels(event_name).observe(latency)
 
     def do_delay_action(self, action, message):

+ 1 - 2
src/core/callcenter/esl/utils/esl_event_util.py

@@ -234,8 +234,7 @@ def getEventDateTimestamp(e):
 
 def getEventTimestamp(e):
     event_timestamp = getEventDateTimestamp(e)
-    print('event_timestamp===>',event_timestamp)
-    event_timestamp_sec = int(event_timestamp) / 1_000_000_1000 if event_timestamp else time.time()
+    event_timestamp_sec = float(event_timestamp) / 1_000_000 if event_timestamp else time.time()
     return event_timestamp_sec
 
 def getEventSubClass(e):