forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2302 — Нурлыгаянова — на 3
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run after persistence hook; query the IDs/timestamps captured BEFORE restart."""
|
||||
import json
|
||||
from observability import ROOT, eventually, logs, get, trace_exists
|
||||
|
||||
proof = json.loads((ROOT/'evidence'/'telemetry.json').read_text())
|
||||
result = {}
|
||||
for role in ['api','worker']:
|
||||
tid = proof[role+'_trace_id']
|
||||
eventually(lambda: trace_exists(tid))
|
||||
eventually(lambda: logs('messenger-'+role,' | trace_id="'+tid+'"'))
|
||||
result[role] = {'trace_id':tid,'old_trace_found':True,'old_log_found':True}
|
||||
when = proof['metrics']['api_requests_total'][0]['value'][0]
|
||||
old = eventually(lambda: get('http://localhost:19091','/api/v1/query',{'query':'api_requests_total','time':when})['data']['result'])
|
||||
result['metrics'] = {'historical_query_timestamp':when,'series_found':len(old)}
|
||||
(ROOT/'evidence'/'telemetry-history.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print('PASS: pre-restart API/worker traces, correlated logs and metric history survived restart')
|
||||
Reference in New Issue
Block a user