gala-gopher/fix-delete-unnecessary-judgments.patch

79 lines
2.9 KiB
Diff
Raw Permalink Normal View History

2024-05-07 21:09:03 +08:00
From f5078ecd0e1bd4d4e3862746c483b988a4f99b00 Mon Sep 17 00:00:00 2001
From: wangqing <wangqing@uniontech.com>
Date: Tue, 7 May 2024 18:09:13 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=B2=A1=E5=BF=85?=
=?UTF-8?q?=E8=A6=81=E7=9A=84=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangqing <wangqing@uniontech.com>
---
.../cadvisor.probe/cadvisor_probe.py | 49 +++++++++----------
1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
index d31f7a6..81e06c9 100755
--- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
@@ -231,32 +231,31 @@ def print_metrics():
continue
for key, record in records.items():
s = "|" + table + "|"
- if table in g_meta:
- for field_name, field_type in g_meta[table].items():
- value = 0
- if field_type == LABEL:
- continue
-
- if field_type == KEY:
- value = key
- s += value + "|"
- continue
-
- if field_name not in record:
- value = ""
- else:
- for item in record[field_name].values():
- if field_type == COUNTER:
- if item[1] > item[0]:
- value += item[1] - item[0]
- else:
- value += 0
- item[0] = item[1]
+ for field_name, field_type in g_meta[table].items():
+ value = 0
+ if field_type == LABEL:
+ continue
+
+ if field_type == KEY:
+ value = key
+ s += value + "|"
+ continue
+
+ if field_name not in record:
+ value = ""
+ else:
+ for item in record[field_name].values():
+ if field_type == COUNTER:
+ if item[1] > item[0]:
+ value += item[1] - item[0]
else:
- value += item
- s = s + str(value) + "|"
- print(s)
- sys.stdout.flush()
+ value += 0
+ item[0] = item[1]
+ else:
+ value += item
+ s = s + str(value) + "|"
+ print(s)
+ sys.stdout.flush()
def clean_metrics():
--
2.28.0.windows.1