Skip to content

Commit

Permalink
Utilize symbol @ as a delimiter for metric file name
Browse files Browse the repository at this point in the history
Utilize symbol '@' as a delimiter between the service name and pod name
within the generaged metric filename to ensure that a given service name
does not erroneously correspond to an excessive number of unrelated
files.

Signed-off-by: Cathy Zhang <[email protected]>
  • Loading branch information
bjzhjing committed Sep 6, 2024
1 parent 0e541f7 commit 311ddf9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion evals/benchmark/stresscli/commands/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def start_collecting_data(self, namespace, services, output_dir="/data", restart
pod_port = self.get_pod_port(pod_info)
metrics = self.collect_metrics(pod_ip, pod_port, metrics_path)
if metrics:
pod_output_path = os.path.join(output_dir, f"{service_name}_{pod_name}_{timestamp}.txt")
pod_output_path = os.path.join(output_dir, f"{service_name}@{pod_name}_{timestamp}.txt")
logging.debug(f"Writing metrics to {pod_output_path}")
with open(pod_output_path, "w") as f:
f.write(metrics)
Expand Down
2 changes: 1 addition & 1 deletion evals/benchmark/stresscli/commands/metrics_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def start_collecting_data(self, services, output_dir="/data"):
for container_name in services:
metrics = self.collect_metrics(container_name)
if metrics:
output_path = os.path.join(output_dir, f"{container_name}_{timestamp}.txt")
output_path = os.path.join(output_dir, f"{container_name}@{timestamp}.txt")
logging.debug(f"Writing Docker metrics to {output_path}")
with open(output_path, "w") as f:
f.write(metrics)
Expand Down
4 changes: 2 additions & 2 deletions evals/benchmark/stresscli/commands/metrics_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def calculate_diff(start_dir, end_dir, output_dir, services=None):
services = [services]

for service_name in services:
# Create a regex pattern to match files starting with the service_name followed by a non-alphanumeric character
pattern = rf"^{re.escape(service_name)}[^a-zA-Z].*\.txt$"
# Create a regex pattern to match files starting with the service_name followed by symbol @
pattern = rf'^{re.escape(service_name)}@.*\.txt$'

start_service_files = [f for f in start_files if re.match(pattern, f)]
end_service_files = [f for f in end_files if re.match(pattern, f)]
Expand Down

0 comments on commit 311ddf9

Please sign in to comment.