ЛР 6 — БВТ2303 — Вейнмайер — на 5 #63

Closed
Weinmaier_Andrew wants to merge 9 commits from Weinmaier_Andrew/mtusi2026lab6:solution/bvt2303-weinmaier into main
Showing only changes of commit d90aef716a - Show all commits
+7 -4
View File
@@ -298,11 +298,14 @@ def breakdown(spans):
srv = next((s for s in spans if s['parent'] == '' or s['name'].startswith(('POST /api', 'GET /api'))), None)
if not srv:
return None
db = sum(s['ms'] for s in spans if s['service'] == srv['service'] and is_db(s))
s3 = sum(s['ms'] for s in spans if s['name'].startswith('S3'))
# DB-spans вложены (BEGIN/batch/query): сумма перекрывается, поэтому берём самый
# длинный отдельный span БД относительно server span.
dbs = sorted(((s['name'], s['ms']) for s in spans if s['service'] == srv['service'] and is_db(s)), key=lambda x: -x[1])
db = dbs[0][1] if dbs else 0.0
s3 = max([s['ms'] for s in spans if s['name'].startswith('S3')] or [0.0])
return {'server_span': srv['name'], 'server_ms': srv['ms'], 'status': srv['attrs'].get('http.response.status_code'),
'db_ms': round(db, 1), 's3_ms': round(s3, 1), 'db_share': round(db / srv['ms'], 3) if srv['ms'] else None,
'db_spans': [(s['name'], s['ms']) for s in spans if is_db(s)][:6]}
'longest_db_span_ms': round(db, 1), 'longest_s3_span_ms': round(s3, 1),
'db_share': round(db / srv['ms'], 3) if srv['ms'] else None, 'db_spans_longest': dbs[:4]}
def scenario_incident_db(c):