Simplify live dashboard and warn on memory target [skip ci]
myfileagent-python-ci/pipeline/head This commit looks good
myfileagent-python-ci/pipeline/head This commit looks good
This commit is contained in:
+8
-1
@@ -320,10 +320,17 @@ def metrics(review, output, completed_at):
|
||||
rows += [f'review_duration_seconds{{mode="live"}} {elapsed}']
|
||||
resource = data.get('resource_measurement', {})
|
||||
for field, metric in [('memory_peak_bytes', 'review_job_memory_peak_bytes'),
|
||||
('memory_limit_bytes', 'review_job_memory_limit_bytes')]:
|
||||
('memory_limit_bytes', 'review_job_memory_limit_bytes'),
|
||||
('memory_target_bytes', 'review_job_memory_target_bytes')]:
|
||||
value = resource.get(field)
|
||||
if type(value) is int and value > 0:
|
||||
rows += [f'{metric}{{mode="live"}} {value}']
|
||||
exceeded = resource.get('memory_target_exceeded')
|
||||
if type(exceeded) is bool:
|
||||
peak, target = resource.get('memory_peak_bytes'), resource.get('memory_target_bytes')
|
||||
if type(peak) is not int or type(target) is not int or exceeded != (peak > target):
|
||||
raise ValueError('Memory target warning disagrees with measured peak')
|
||||
rows += [f'review_job_memory_target_exceeded{{mode="live"}} {int(exceeded)}']
|
||||
if not re.fullmatch('[0-9]+', str(completed_at)):
|
||||
raise ValueError('Completion timestamp must be measured epoch seconds')
|
||||
rows += [f'review_completed_timestamp_seconds{{mode="live"}} {completed_at}']
|
||||
|
||||
Reference in New Issue
Block a user