Skip to content

Commit 06750c5

Browse files
committed
Update metrics query
1 parent d645ad5 commit 06750c5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

benchmarks/benchmark/tools/profile-generator/container/benchmark_serving.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,16 @@ def print_metrics(metrics: List[str], duration: float, backend: str):
655655
# handle response
656656
if request_post.ok:
657657
if response["status"] == "success":
658-
metric_results[query_name] = float(response["data"]["result"][0]["value"][1])
659-
print("%s: %s" % (query_name, response["data"]["result"][0]["value"][1]))
658+
r = response["data"]["result"]
659+
if not r:
660+
print(f"Failed to get result for {query_name}")
661+
continue
662+
v = r[0].get("value", None)
663+
if not v:
664+
print(f"Failed to get value for result: {r}")
665+
continue
666+
metric_results[query_name] = float(v[1])
667+
print("%s: %s" % (query_name, v[1]))
660668
else:
661669
print("Cloud Monitoring PromQL Error: %s" % (response["error"]))
662670
else:

0 commit comments

Comments
 (0)