|
@@ -6,36 +6,14 @@ import traceback
|
|
|
from . import app
|
|
|
from typing import Iterable
|
|
|
from prometheus_client import Counter, Gauge, Histogram, Summary
|
|
|
-# from prometheus_client.core import CollectorRegistry
|
|
|
+from prometheus_client.core import CollectorRegistry
|
|
|
from prometheus_flask_exporter import PrometheusMetrics
|
|
|
|
|
|
metrics = PrometheusMetrics(app)
|
|
|
+# 呼入总量
|
|
|
+CALL_INCOMING_REQUESTS = Counter('call_incoming_requests', '呼入总流量', ['bucket'])
|
|
|
+CALL_BOT_ANSWER_REQUESTS = Counter('call_bot_answer_requests', '机器人接听量', ['bucket'])
|
|
|
+CALL_BOT_TRANSFER_REQUESTS = Counter('call_bot_transfer_requests', '机器转人量', ['bucket'])
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-ESL_EVENT_LATENCY = Histogram('esl_event_latency', 'Esl Event latency in seconds', ['eventName'])
|
|
|
-
|
|
|
-
|
|
|
-def counter(name, description, labels=None, initial_value_when_only_static_labels=True, **kwargs):
|
|
|
- try:
|
|
|
- return metrics.counter(name, description, labels, initial_value_when_only_static_labels, **kwargs)
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
-
|
|
|
-def gauge(name, description, labels=None, initial_value_when_only_static_labels=True, **kwargs):
|
|
|
- try:
|
|
|
- return metrics.gauge(name, description, labels, initial_value_when_only_static_labels, **kwargs)
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
-
|
|
|
-def histogram(name, description, labels=None, initial_value_when_only_static_labels=True, **kwargs):
|
|
|
- try:
|
|
|
- return metrics.histogram(name, description, labels, initial_value_when_only_static_labels, **kwargs)
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
-
|
|
|
-def summary(name, description, labels=None, initial_value_when_only_static_labels=True, **kwargs):
|
|
|
- try:
|
|
|
- return metrics.summary(name, description, labels, initial_value_when_only_static_labels, **kwargs)
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
+# esl时间耗时
|
|
|
+ESL_EVENT_LATENCY = Histogram('esl_event_latency', 'Esl Event latency in seconds', ['eventName'])
|