47 lines
2.5 KiB
Python
47 lines
2.5 KiB
Python
"""Derive a compact table from authentic raw run receipts; never alter raw data."""
|
|
import json
|
|
import re
|
|
import statistics
|
|
|
|
from common import ROOT
|
|
|
|
|
|
def memory_mib(value):
|
|
number, unit = re.fullmatch(r'([0-9.]+)([A-Za-z]+)', value.split(' / ')[0]).groups()
|
|
return float(number) * {'B': 1/1048576, 'KiB': 1/1024, 'MiB': 1, 'GiB': 1024}[unit]
|
|
|
|
|
|
def main():
|
|
data = json.loads((ROOT/'evidence/observability-cost.json').read_text())
|
|
assert data['passed'] and len(data['runs']) == 12
|
|
rows = []
|
|
for profile in ('off', 'full', 'sample25', 'sample10'):
|
|
runs = [run for run in data['runs'] if run['profile'] == profile]
|
|
samples = [sample for run in runs for sample in run['docker_samples']]
|
|
rows.append({
|
|
'profile': profile, 'runs': len(runs),
|
|
'median_success_rps': statistics.median(run['successful_rps'] for run in runs),
|
|
**{'median_'+key+'_ms': statistics.median(run['latency_s'][key]*1000 for run in runs)
|
|
for key in ('p50', 'p95', 'p99')},
|
|
'mean_total_docker_cpu_percent': statistics.mean(sum(float(c['CPUPerc'].rstrip('%'))
|
|
for c in sample['containers']) for sample in samples),
|
|
'peak_total_docker_memory_mib': max(sum(memory_mib(c['MemUsage']) for c in sample['containers'])
|
|
for sample in samples),
|
|
**{'median_'+key: statistics.median(run['telemetry_delta'][key] for run in runs)
|
|
for key in ('traces_wire_bytes', 'logs_wire_bytes', 'metrics_wire_bytes',
|
|
'collector_accepted_spans', 'collector_refused_spans')},
|
|
'export_failed_spans': sum(run['telemetry_delta']['spans_export_failed'] for run in runs),
|
|
'queue_lost_spans': sum(run['telemetry_delta']['spans_queue_lost'] for run in runs),
|
|
'not_sent': sum(run['not_sent'] for run in runs),
|
|
'rare_total': sum(len(run['rare_probes']) for run in runs),
|
|
'rare_found': sum(sum(probe['found_in_tempo'] for probe in run['rare_probes']) for run in runs),
|
|
'errors_found': sum(sum(probe['found_in_tempo'] for probe in run['rare_probes'] if probe['status']==500) for run in runs),
|
|
'slow_found': sum(sum(probe['found_in_tempo'] for probe in run['rare_probes'] if probe['status']!=500) for run in runs),
|
|
})
|
|
(ROOT/'evidence/observability-cost-summary.json').write_text(json.dumps(rows, indent=2))
|
|
print(json.dumps(rows, indent=2))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|