Skip to content

Commit ef8f6fc

Browse files
committed
Fix typo in comments
1 parent f9560f9 commit ef8f6fc

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tools/run_tests/performance/prometheus.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
# --url=http://prometheus.prometheus.svc.cluster.local:9090
2020
# --pod_type=driver --pod_type=clients --container_name=main
2121
# --container_name=sidecar
22-
"""Perform prometheus range queries to obtain cpu and memory data.
22+
"""Perform Prometheus range queries to obtain cpu and memory data.
2323
2424
This module performs range queries through Prometheus API to obtain
25-
total cpu seconds and memory during a tets run for given container
25+
total cpu seconds and memory during a test run for given container
2626
in given pods. The cpu data obtained is total cpu second used within
27-
given period of time. The memory data was the instant memory at the
28-
query time.
27+
given period of time. The memory data was instant memory usage at
28+
the query time.
2929
"""
3030
import argparse
3131
import json
@@ -38,8 +38,7 @@
3838

3939

4040
class Prometheus:
41-
"""Objects which holds the start and end time, query URL
42-
for a query."""
41+
"""Objects which holds the start time, end time and query URL."""
4342

4443
def __init__(
4544
self,
@@ -54,9 +53,9 @@ def __init__(
5453
def _fetch_by_query(self, query: str) -> Dict[str, Any]:
5554
"""Fetches the given query with time range.
5655
57-
Fetch the given query within a time range. The pulling
56+
Fetch the given query within a time range. The pulling
5857
interval is every 5s, the actual data from the query is
59-
a time serier.
58+
a time series.
6059
"""
6160
resp = requests.get(
6261
self.url + '/api/v1/query_range',
@@ -75,7 +74,7 @@ def _fetch_cpu_for_pod(self, container_matcher: str,
7574
"""Fetches the cpu data for each pod.
7675
7776
Fetch total cpu seconds during the time range specified in the Prometheus instance
78-
for a pod. After obtain the cpu seconds, the data are trimmed from time serier to
77+
for a pod. After obtain the cpu seconds, the data are trimmed from time series to
7978
a data list and saved in the Dict that keyed by the container names.
8079
8180
Args:
@@ -96,7 +95,7 @@ def _fetch_memory_for_pod(self, container_matcher: str,
9695
"""Fetches memory data for each pod.
9796
9897
Fetch total memory data during the time range specified in the Prometheus instance
99-
for a pod. After obtain the memory data, the data are trimmed from time serier to
98+
for a pod. After obtain the memory data, the data are trimmed from time series to
10099
a data list and saved in the Dict that keyed by the container names.
101100
102101
Args:
@@ -118,7 +117,7 @@ def _fetch_memory_for_pod(self, container_matcher: str,
118117
def fetch_cpu_and_memory_data(
119118
self, container_list: List[str],
120119
pod_dict: Dict[str, List[str]]) -> Dict[str, Any]:
121-
"""Fetch total cpu seconds and memory data for a multiple pods.
120+
"""Fetch total cpu seconds and memory data for multiple pods.
122121
123122
Args:
124123
container_list: A list of container names to fetch the data for.
@@ -168,7 +167,7 @@ def construct_container_matcher(container_list: List[str]) -> str:
168167

169168
def get_data_list_from_timeseries(data: Any) -> Dict[str, List[float]]:
170169
"""Constructs a Dict as keys are the container names and
171-
values are a list of data taken from given timeserie data."""
170+
values are a list of data taken from given timeseries data."""
172171
if data['status'] != 'success':
173172
raise Exception('command failed: ' + data['status'] + str(data))
174173
if data['data']['resultType'] != 'matrix':
@@ -178,10 +177,10 @@ def get_data_list_from_timeseries(data: Any) -> Dict[str, List[float]]:
178177
container_name_to_data_list = {}
179178
for res in data["data"]["result"]:
180179
container_name = res["metric"]["container"]
181-
container_data_timeserie = res["values"]
180+
container_data_timeseries = res["values"]
182181

183182
container_data = []
184-
for d in container_data_timeserie:
183+
for d in container_data_timeseries:
185184
container_data.append(float(d[1]))
186185
container_name_to_data_list[container_name] = container_data
187186
return container_name_to_data_list
@@ -193,7 +192,7 @@ def compute_total_cpu_seconds(cpu_data_list: List[float]) -> float:
193192

194193

195194
def compute_average_memory_usage(memory_data_list: List[float]) -> float:
196-
"""Computes the mean and for given list of data."""
195+
"""Computes the mean and for a given list of data."""
197196
return statistics.mean(memory_data_list)
198197

199198

@@ -224,7 +223,7 @@ def construct_pod_dict(node_info_file: str,
224223

225224

226225
def convert_UTC_to_epoch(utc_timestamp: str) -> str:
227-
"""Converts a utc timstamp string to epoch time string."""
226+
"""Converts a utc timestamp string to epoch time string."""
228227
parsed_time = parser.parse(utc_timestamp)
229228
epoch = parsed_time.strftime('%s')
230229
return epoch

0 commit comments

Comments
 (0)