From 2b8372427dd8f7980039d694d3821d4e05302b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BB=D1=8C=D0=B5=D0=B2=20=D0=9D?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Mon, 16 Nov 2026 11:56:45 +0300 Subject: [PATCH] Preserve diagnostic receipts and resume bounded cost experiments --- research/observability_cost.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/research/observability_cost.py b/research/observability_cost.py index 36f8790..3669000 100644 --- a/research/observability_cost.py +++ b/research/observability_cost.py @@ -3,6 +3,7 @@ import concurrent.futures import json import math import os +import sys import re import statistics import subprocess @@ -99,7 +100,7 @@ def run_profile(client, profile, repeat): before = telemetry_snapshot(instance_ids) memory_before = cgroups(['api','worker','collector','tempo']) compose('exec','-T','postgres','psql','-U','messenger','-d','messenger','-c', - "INSERT INTO test_faults(point,action) VALUES ('after_upload_commit','error'),('after_upload_commit','error')") + "DELETE FROM test_faults WHERE point='after_upload_commit' AND reached_at IS NULL; INSERT INTO test_faults(point,action) VALUES ('after_upload_commit','error'),('after_upload_commit','error')") calls = [] dropped = 0 lock_future = None @@ -132,7 +133,7 @@ def run_profile(client, profile, repeat): for future in ready: calls.append(future.result()) pending.remove(future) - if len(pending) >= 15: + if len(pending) >= 15 and index not in (80,240): dropped += 1 else: pending.add(executor.submit(request,index)) @@ -141,7 +142,9 @@ def run_profile(client, profile, repeat): if lock_future: lock_future.result() elapsed = time.monotonic()-started - assert sum(x['status']==500 for x in calls)==2, 'Expected exactly two controlled upload errors' + if sum(x['status']==500 for x in calls)!=2: + (ROOT/'evidence/cost-failed-requests.json').write_text(json.dumps({'profile':name,'repeat':repeat,'not_sent':dropped,'requests':calls},indent=2)) + raise AssertionError('Expected two controlled upload errors; statuses='+str({status:sum(x['status']==status for x in calls) for status in {x['status'] for x in calls}})) assert all(x['status'] in (200,500) for x in calls), 'Unexpected business failure' time.sleep(10) after = telemetry_snapshot(instance_ids) @@ -177,11 +180,19 @@ def main(): 'baseline':'40 warmup requests at 10/s, then10s silence; direct Collector endpoints avoid Prometheus scrape delay', 'post_window':'10s silence before direct Collector counters; bytes include periodic metric exports in observation window', 'resources':'same image/CPU/RAM; sequential profiles, all services on one Docker host'}} + result_path = ROOT/'evidence/observability-cost.json' + if '--resume' in sys.argv and result_path.exists(): + previous = json.loads(result_path.read_text()) + assert previous['method']['rare_slow'] == report['method']['rare_slow'] + report = previous + completed = {(row['profile'], row['repeat']) for row in report['runs']} client = Client() try: for repeat in range(1,4): order = PROFILES[repeat-1:]+PROFILES[:repeat-1] for profile in order: + if (profile[0],repeat) in completed: + continue row = run_profile(client,profile,repeat) report['runs'].append(row) (ROOT/'evidence/observability-cost.json').write_text(json.dumps(report,indent=2))