-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
200 lines (182 loc) · 6.55 KB
/
model.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
from typing import Dict
from prometheus_client import Gauge
class DataCategoryConstants:
Index = "Index"
Operator = "Operator"
Query = "Query"
QueryType = "QueryType"
Session = "Session"
Snapshot = "Snapshot"
Stream = "Stream"
TTL = "TTL"
Transaction = "Transaction"
Trigger = "Trigger"
General = "General"
index_data = [
("ActiveLabelIndices", "Number of active label indices in the system."),
("ActiveLabelPropertyIndices", "Number of active label indices in the system."),
("ActiveTextIndices", "Number of active text indices in the system."),
]
operator_names = [
"AccumulateOperator",
"AggregateOperator",
"ApplyOperator",
"CallProcedureOperator",
"CartesianOperator",
"ConstructNamedPathOperator",
"CreateExpandOperator",
"CreateNodeOperator",
"DeleteOperator",
"DistinctOperator",
"EdgeUniquenessFilterOperator",
"EmptyResultOperator",
"EvaluatePatternFilterOperator",
"ExpandOperator",
"ExpandVariableOperator",
"FilterOperator",
"ForeachOperator",
"HashJoinOperator",
"IndexedJoinOperator",
"LimitOperator",
"MergeOperator",
"OnceOperator",
"OptionalOperator",
"OrderByOperator",
"PeriodicCommitOperator",
"PeriodicSubqueryOperator",
"ProduceOperator",
"RemoveLabelsOperator",
"RemovePropertyOperator",
"RollUpApplyOperator",
"ScanAllByEdgeIdOperator",
"ScanAllByEdgeTypeOperator",
"ScanAllByIdOperator",
"ScanAllByLabelOperator",
"ScanAllByLabelPropertyOperator",
"ScanAllByLabelPropertyRangeOperator",
"ScanAllByLabelPropertyValueOperator",
"ScanAllOperator",
"SetLabelsOperator",
"SetPropertiesOperator",
"SetPropertyOperator",
"SkipOperator",
"UnionOperator",
"UnwindOperator",
]
query_data = [
(
"QueryExecutionLatency_us_99p",
"Query execution latency in microseconds, 99th percentile",
),
(
"QueryExecutionLatency_us_90p",
"Query execution latency in microseconds, 90th percentile",
),
(
"QueryExecutionLatency_us_50p",
"Query execution latency in microseconds, 50th percentile",
),
]
query_type_data = [
("ReadQuery", "Number of read-only queries executed."),
("ReadWriteQuery", "Number of write-only queries executed."),
("WriteQuery", "Number of read-write queries executed."),
]
session_data = [
("ActiveBoltSessions", "Number of active Bolt connections."),
("ActiveSSLSessions", "Number of active SSL connections."),
("ActiveSessions", "Number of active connections."),
("ActiveTCPSessions", "Number of active TCP connections."),
("ActiveWebSocketSessions", "Number of active websocket connections."),
("BoltMessages", "Number of Bolt messages sent."),
]
snapshot_data = [
(
"SnapshotCreationLatency_us_99p",
"Snapshot creation latency in microseconds, 99th percentile.",
),
(
"SnapshotCreationLatency_us_90p",
"Snapshot creation latency in microseconds, 90th percentile.",
),
(
"SnapshotCreationLatency_us_50p",
"Snapshot creation latency in microseconds, 50th percentile.",
),
(
"SnapshotRecoveryLatency_us_99p",
"Snapshot recovery latency in microseconds, 99th percentile.",
),
(
"SnapshotRecoveryLatency_us_90p",
"Snapshot recovery latency in microseconds, 90th percentile.",
),
(
"SnapshotRecoveryLatency_us_50p",
"Snapshot recovery latency in microseconds, 50th percentile.",
),
]
stream_data = [
("MessagesConsumed", "Number of consumed streamed messages."),
("StreamsCreated", "Number of Streams created."),
]
TTL = [
("DeletedEdges", "Number of deleted TTL edges."),
("DeletedNodes", "Number of deleted TTL nodes."),
]
transaction_data = [
("ActiveTransactions", "Number of active transactions."),
("CommitedTransactions", "Number of committed transactions."),
("FailedPrepare", "Number of failed prepare queries."),
("FailedPull", "Number of failed pulls."),
("FailedQuery", "Number of times executing a query failed."),
("RollbackedTransactions", "Number of rollbacked transactions."),
("SuccessfulQuery", "Number of successful queries"),
]
trigger_data = [
("TriggersCreated", "Number of Triggers created."),
("TriggersExecuted", "Number of Triggers executed."),
]
general_data = [
("average_degree", "Average node degree."),
("disk_usage", "Amount of disk usage."),
("edge_count", "Edge count."),
("memory_usage", "Amount of memory usage."),
("peak_memory_usage", "Peak memory usage."),
("unreleased_delta_objects", "Number of unreleased delta objects."),
("vertex_count", "Vertex count."),
]
INDEX = {name: Gauge(name, description) for name, description in index_data}
OPERATOR = {
name: Gauge(name, f"Number of times {name} has been called.")
for name in operator_names
}
QUERY = {name: Gauge(name, description) for name, description in query_data}
QUERY_TYPE = {name: Gauge(name, description) for name, description in query_type_data}
SESSION = {name: Gauge(name, description) for name, description in session_data}
SNAPSHOT = {name: Gauge(name, description) for name, description in snapshot_data}
STREAM = {name: Gauge(name, description) for name, description in stream_data}
TRANSACTION = {name: Gauge(name, description) for name, description in transaction_data}
TRIGGER = {name: Gauge(name, description) for name, description in trigger_data}
GENERAL = {name: Gauge(name, description) for name, description in general_data}
def update_metrics(data: Dict[str, Dict[str, int]]):
for key, value in data[DataCategoryConstants.Index].items():
INDEX[key].set(value)
for key, value in data[DataCategoryConstants.Operator].items():
OPERATOR[key].set(value)
for key, value in data[DataCategoryConstants.Query].items():
QUERY[key].set(value)
for key, value in data[DataCategoryConstants.QueryType].items():
QUERY_TYPE[key].set(value)
for key, value in data[DataCategoryConstants.Session].items():
SESSION[key].set(value)
for key, value in data[DataCategoryConstants.Snapshot].items():
SNAPSHOT[key].set(value)
for key, value in data[DataCategoryConstants.Stream].items():
STREAM[key].set(value)
for key, value in data[DataCategoryConstants.Transaction].items():
TRANSACTION[key].set(value)
for key, value in data[DataCategoryConstants.Trigger].items():
TRIGGER[key].set(value)
for key, value in data[DataCategoryConstants.General].items():
GENERAL[key].set(value)