-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.py
More file actions
34 lines (29 loc) · 1.03 KB
/
server.py
File metadata and controls
34 lines (29 loc) · 1.03 KB
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
"""
initialization of the structure to gather the sampled metrics
for the server of the system
"""
from collections.abc import Iterable
from asyncflow.config.constants import SampledMetricName
# Initialize one time outside the function all possible metrics
# related to the servers, the idea of this structure is to
# guarantee scalability in the long term if multiple metrics
# will be considered
SERVER_METRICS = (
SampledMetricName.READY_QUEUE_LEN,
SampledMetricName.EVENT_LOOP_IO_SLEEP,
SampledMetricName.RAM_IN_USE,
)
def build_server_metrics(
enabled_sample_metrics: Iterable[SampledMetricName],
) -> dict[SampledMetricName, list[float | int]]:
"""
Function to populate a dictionary to collect values for
time series of sampled metrics related to the server of
the system.
"""
# The edge case of the empty dict is avoided since at least
# one metric is always measured by default.
return {
metric: [] for metric in SERVER_METRICS
if metric in enabled_sample_metrics
}