-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics.py
65 lines (61 loc) · 1.95 KB
/
metrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from prometheus_client import Counter, Gauge, Histogram, Summary
# counters
http_requests_counter = Counter(
name="http_requests",
documentation="Total number of http requests.",
labelnames=["api"],
)
pos_predictions_counter = Counter(
name="pos_predictions",
documentation="Total number of positive predictions.",
labelnames=["api", "restaurant_name"],
)
neg_predictions_counter = Counter(
name="neg_predictions",
documentation="Total number of negative predictions.",
labelnames=["api", "restaurant_name"],
)
predictions_counter = Counter(
name="predictions",
documentation="Total number of predictions.",
labelnames=["api", "restaurant_name"],
)
true_pos_predictions_counter = Counter(
name="true_pos_predictions",
documentation="Total number of true positive predictions.",
labelnames=["api", "restaurant_name"],
)
true_neg_predictions_counter = Counter(
name="true_neg_predictions",
documentation="Total number of true negative predictions.",
labelnames=["api", "restaurant_name"],
)
false_pos_predictions_counter = Counter(
name="false_pos_predictions",
documentation="Total number of false positive predictions.",
labelnames=["api", "restaurant_name"],
)
false_neg_predictions_counter = Counter(
name="false_neg_predictions",
documentation="Total number of false negative predictions.",
labelnames=["api", "restaurant_name"],
)
# gauges
model_accuracy_gauge = Gauge(
name="model_accuracy",
documentation="Prediction accuracy of the model.",
labelnames=["api", "restaurant_name"],
)
# histograms
response_time_histogram = Histogram(
name="response_time_seconds",
documentation="Response time of requests in seconds.",
labelnames=["api"],
buckets=(0.001, 0.002, 0.003, 0.01, 0.025, 0.05, 0.1, 0.5, 1, 1.5, 2),
)
# summaries
response_size_summary = Summary(
name="response_size_summary",
documentation="Summary of response sizes",
labelnames=["api"],
)