forked from mtusi2026/mtusi2026lab6
ЛР6: OpenTelemetry, Collector, Prometheus/Loki/Tempo, Grafana, SLO и алерты, инциденты
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
# attachments: lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids
|
||||
# date: 2026-11-01 00:52:47, commit: unknown
|
||||
# command: python student-tests/test_attachments.py
|
||||
# exit code: 0, 13.5 s
|
||||
|
||||
sample.png: 111817 bytes, sha256 99ea7533c441..., downloaded by the other member, same bytes
|
||||
sample.jpg: 1492 bytes, sha256 c310b9a1c208..., downloaded by the other member, same bytes
|
||||
progressive.jpg: 1081 bytes, sha256 913df01aec84..., downloaded by the other member, same bytes
|
||||
interlaced.png: 79 bytes, sha256 38149222f78f..., downloaded by the other member, same bytes
|
||||
1x1.png: 67 bytes, sha256 eaa4a94ea300..., downloaded by the other member, same bytes
|
||||
PASS: PNG, JPEG, progressive JPEG, interlaced PNG and 1x1 PNG are stored and returned byte for byte
|
||||
exactly 10485760 bytes (10 MiB) -> 202, then ready
|
||||
10485761 bytes (10 MiB + 1) with Content-Length -> 413 before reading the body
|
||||
PASS: the 10 MiB limit is exact
|
||||
12 MiB without Content-Length (chunked) -> 413 as soon as the 10 MiB limit is passed
|
||||
PASS: oversized streamed body is cut off, the API keeps working
|
||||
8000x5000 = 40 000 000 pixels (38957 bytes compressed) -> 202, ready f30c028f
|
||||
8001x5000 = 40 005 000 pixels (38962 bytes) -> 413
|
||||
header claims 100000x100000 in 65 bytes -> 413 from the header, nothing is decoded
|
||||
PASS: pixel limit is checked before decompression
|
||||
PNG cut in half (55908 bytes, image/png) -> 415
|
||||
PNG without IEND (111805 bytes, image/png) -> 415
|
||||
PNG with a flipped byte in IDAT (CRC mismatch) (111817 bytes, image/png) -> 415
|
||||
PNG with garbage after IEND (111824 bytes, image/png) -> 415
|
||||
PNG signature only (8 bytes, image/png) -> 415
|
||||
PNG with less pixel data than the header says (70 bytes, image/png) -> 415
|
||||
JPEG cut in half (746 bytes, image/jpeg) -> 415
|
||||
JPEG header only (20 bytes, image/jpeg) -> 415
|
||||
random bytes (1600 bytes, image/png) -> 415
|
||||
plain text (28 bytes, image/jpeg) -> 415
|
||||
empty body -> 400
|
||||
PASS: damaged and foreign files are rejected with 415, never 500
|
||||
PLTE 771 bytes = 257 entries (review case) (850 bytes, valid CRCs) -> 415
|
||||
PLTE length not a multiple of 3 (83 bytes, valid CRCs) -> 415
|
||||
empty PLTE (79 bytes, valid CRCs) -> 415
|
||||
palette larger than bit depth allows (depth 1, 3 entries) (88 bytes, valid CRCs) -> 415
|
||||
palette image without PLTE (67 bytes, valid CRCs) -> 415
|
||||
PLTE in a grayscale image (85 bytes, valid CRCs) -> 415
|
||||
PLTE after IDAT (85 bytes, valid CRCs) -> 415
|
||||
two PLTE chunks (103 bytes, valid CRCs) -> 415
|
||||
tRNS longer than the palette (100 bytes, valid CRCs) -> 415
|
||||
tRNS before PLTE (98 bytes, valid CRCs) -> 415
|
||||
tRNS of wrong size for RGB (4 bytes instead of 6) (85 bytes, valid CRCs) -> 415
|
||||
tRNS in an image with alpha channel (84 bytes, valid CRCs) -> 415
|
||||
IEND with data (70 bytes, valid CRCs) -> 415
|
||||
unknown critical chunk (81 bytes, valid CRCs) -> 415
|
||||
IDAT chunks not consecutive (95 bytes, valid CRCs) -> 415
|
||||
gAMA after IDAT (85 bytes, valid CRCs) -> 415
|
||||
gAMA of 2 bytes instead of 4 (83 bytes, valid CRCs) -> 415
|
||||
3 MiB metadata chunk before IDAT (3145809 bytes, valid CRCs) -> 415
|
||||
private chunk after IDAT (181 bytes, valid CRCs) -> 415
|
||||
animated PNG frame (fdAT) (91 bytes, valid CRCs) -> 415
|
||||
tIME of 2 bytes instead of 7 (83 bytes, valid CRCs) -> 415
|
||||
tEXt without keyword separator (86 bytes, valid CRCs) -> 415
|
||||
zTXt with broken zlib after IDAT (91 bytes, valid CRCs) -> 415
|
||||
zTXt text bomb: 50 MB of text in ~50 KB after IDAT (48694 bytes, valid CRCs) -> 415
|
||||
palette 256 entries + tRNS + tEXt and tIME after IDAT -> 201, downloaded byte for byte
|
||||
palette depth 2 with 4 entries -> 201, downloaded byte for byte
|
||||
RGB with 6-byte tRNS and gAMA -> 201, downloaded byte for byte
|
||||
compressed zTXt (100 KB of text) and iTXt after IDAT -> 201, downloaded byte for byte
|
||||
PASS: chunk contents are checked, not only CRCs; valid PNGs with metadata are still accepted
|
||||
PNG bytes sent as image/jpeg -> 415
|
||||
JPEG bytes sent as image/png -> 415
|
||||
GIF bytes sent as image/png -> 415
|
||||
PNG sent as image/gif -> 415
|
||||
PNG sent as text/html -> 415
|
||||
PNG sent as application/octet-stream -> 415
|
||||
PNG sent as multipart/form-data -> 415
|
||||
PNG sent as 'IMAGE/PNG; charset=binary' -> 201, stored as image/png
|
||||
PASS: the type is taken from the content; a declared type that does not match is refused
|
||||
13 dangerous or invalid names (path, slashes, NUL, control characters, empty, 256 chars) -> 400
|
||||
no filename -> 400
|
||||
Unicode, 255 chars, leading dots, %20 and ? are kept as display names only
|
||||
PASS: filename never becomes a path; dangerous names are refused
|
||||
outsider -> 404 for metadata and bytes (same as a non-existent id); no token -> 401; bad UUID -> 400
|
||||
upload into someone else's / unknown chat -> 404, without token -> 401
|
||||
variant=preview -> 400 (not in the contract); original/thumbnail/crop/optimized -> 200 (lab5)
|
||||
PASS: only chat members can see an attachment
|
||||
text='' with 2 attachments -> 201, order kept; any member may attach a file uploaded by another member
|
||||
history returns attachment_ids for every message, [] for a message without files; reuse is allowed
|
||||
attachment of another chat (author is a member of both) -> 404
|
||||
own + foreign attachment -> 404
|
||||
unknown attachment_id -> 404
|
||||
outsider referencing an attachment of the chat -> 404
|
||||
duplicate ids -> 400
|
||||
11 ids -> 400
|
||||
bad UUID -> 400
|
||||
empty text without attachments -> 400
|
||||
whitespace text without attachments -> 400
|
||||
PASS: only attachments of the same chat can be linked; rejected requests change nothing
|
||||
same key + same attachments -> same 201; other attachments -> 409; missing field == []
|
||||
PASS: Idempotency-Key covers attachment_ids
|
||||
sent 1.1 MB of a declared 5 MB body and closed the connection
|
||||
the API keeps serving uploads; nothing of the aborted request is visible (DB/S3 side is checked by test_consistency.py)
|
||||
PASS: an interrupted upload is dropped
|
||||
12 passed, 0 failed
|
||||
@@ -0,0 +1,6 @@
|
||||
# check: offline contract check (make check)
|
||||
# date: 2026-11-01 00:22:29, commit: unknown
|
||||
# command: python scripts/check_contract.py
|
||||
# exit code: 0, 0.1 s
|
||||
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,28 @@
|
||||
# configs: lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning
|
||||
# date: 2026-11-01 00:22:31, commit: unknown
|
||||
# command: python student-tests/check_configs.py
|
||||
# exit code: 0, 0.7 s
|
||||
|
||||
--- otelcol-contrib validate (infra/otel/collector.yaml): exit 0
|
||||
|
||||
--- promtool check config (infra/prometheus/prometheus.yml): exit 0
|
||||
|
||||
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/alerts.yml
|
||||
SUCCESS: 6 rules found
|
||||
|
||||
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/recording.yml
|
||||
SUCCESS: 10 rules found
|
||||
--- promtool check rules (recording + alerts): exit 0
|
||||
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/alerts.yml
|
||||
SUCCESS: 6 rules found
|
||||
|
||||
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/recording.yml
|
||||
SUCCESS: 10 rules found
|
||||
--- promtool test rules (unit tests of alert thresholds/windows/for): exit 0
|
||||
SUCCESS
|
||||
--- loki -verify-config (infra/loki/loki.yaml): exit 0
|
||||
|
||||
--- tempo -config.verify (infra/tempo/tempo.yaml): exit 0
|
||||
|
||||
--- Grafana: not reachable at http://127.0.0.1:3000, skipped (local binaries mode)
|
||||
PASS: collector, prometheus (config, rules, unit tests), loki and tempo configs are valid
|
||||
@@ -0,0 +1,36 @@
|
||||
# dashboard: lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels
|
||||
# date: 2026-11-01 00:23:49, commit: unknown
|
||||
# command: python student-tests/check_dashboard.py
|
||||
# exit code: 0, 0.5 s
|
||||
|
||||
PromQL: 54 dashboard expressions + 16 rule expressions executed, 0 errors, 15 empty now (no traffic of that kind / Docker-only / no incident)
|
||||
empty now: CPU контейнеров / лимит
|
||||
empty now: Collector: потери и отказы
|
||||
empty now: SDK приложений: экспорт и потери
|
||||
empty now: alerts.yml: MessengerDbPoolSaturated
|
||||
empty now: alerts.yml: MessengerHighErrorRate
|
||||
empty now: alerts.yml: MessengerQueueLagGrowing
|
||||
empty now: alerts.yml: MessengerWorkerNoConsumers
|
||||
empty now: alerts.yml: TelemetryCollectorDown
|
||||
empty now: alerts.yml: TelemetryExportFailing
|
||||
empty now: Алерты Prometheus (pending/firing)
|
||||
empty now: Память: RSS процесса и контейнер
|
||||
LogQL ok: Предупреждения и ошибки (Loki): {service_name=~"messenger-.*"} | detected_level=~"warn|error"
|
||||
TraceQL ok: Трассы с ошибками (Tempo, TraceQL): { status = error } -> 5 trace(s)
|
||||
|
||||
data: http_server_request_duration_seconds_count{job="messenger-api"} 39 series <- HTTP requests/duration (3)
|
||||
data: messenger_job_duration_seconds_count 3 series <- jobs processed/failed + duration (3)
|
||||
data: messenger_attachment_time_to_ready_seconds_count 1 series <- end-to-end time to ready (4)
|
||||
data: messenger_queue_depth 2 series <- queue depth (4)
|
||||
data: messenger_queue_oldest_age_seconds 1 series <- oldest job age (4)
|
||||
data: db_client_connection_count 4 series <- DB pool used/idle (4)
|
||||
data: db_client_connection_pending_requests 2 series <- DB pool waiting (4)
|
||||
data: messenger_worker_busy 1 series <- worker busy (4)
|
||||
data: messenger_worker_capacity 1 series <- worker capacity (4)
|
||||
data: process_cpu_time_seconds_total 12 series <- process CPU (4)
|
||||
data: process_memory_usage_bytes 6 series <- process RAM (4)
|
||||
data: otelcol_exporter_queue_size 3 series <- collector queue (4)
|
||||
|
||||
labels used by application metrics: __name__, cpu_mode, db_client_connection_pool_name, db_client_connection_state, deployment_environment_name, error_type, http_request_method, http_response_status_class, http_response_status_code, http_route, instance, job, job_type, le, messaging_destination_name, otel_component_name, otel_component_type, otel_span_parent_origin, otel_span_sampling_result, outcome, server_address, server_port, service_version, status, telemetry_sdk_language, telemetry_sdk_name, telemetry_sdk_version
|
||||
http_route values (templates, not URLs): ['/api/v1/attachments/{attachment_id}', '/api/v1/attachments/{attachment_id}/content', '/api/v1/auth/sessions', '/api/v1/auth/sessions/current', '/api/v1/chats', '/api/v1/chats/{chat_id}', '/api/v1/chats/{chat_id}/attachments', '/api/v1/chats/{chat_id}/messages', '/api/v1/users', '/api/v1/users/me', '/health/live', '/health/ready']
|
||||
PASS: every dashboard/rule query runs, key signals have data, no forbidden labels
|
||||
@@ -0,0 +1,22 @@
|
||||
# idempotency: Idempotency-Key, parallel same key via replicas
|
||||
# date: 2026-11-01 00:52:50, commit: unknown
|
||||
# command: python student-tests/test_idempotency.py
|
||||
# exit code: 0, 2.2 s
|
||||
|
||||
first -> 201; same JSON written differently -> 201; plain retry -> 201
|
||||
PASS: a retry with the same key returns the original 201 and message, no duplicate
|
||||
20 parallel POSTs with one key: statuses {201: 20}, replicas {'a1a1a1a1a1a1': 10, 'a2a2a2a2a2a2': 10}, different bodies in answers: 1, messages in history: 1
|
||||
PASS: parallel requests with one key through different replicas create exactly one message
|
||||
20 parallel POSTs, one key, two different bodies: {('body A', 409): 10, ('body B', 201): 10}; saved: ['body B']
|
||||
PASS: the first body wins, the same body gets 201, the other body gets 409
|
||||
one key: alice in chat 1, bob in chat 1, alice in chat 2 -> 3 messages
|
||||
PASS: the key is scoped to the current user and chat; another body with a used key -> 409
|
||||
missing, empty, 129 chars, space, '/', non-ASCII, '"', '+' -> 400; 128 chars of A-Z a-z 0-9 . _ : - -> 201
|
||||
PASS: Idempotency-Key is required and checked: [A-Za-z0-9._:-]{1,128}
|
||||
key used by a 400 and by a 404 first, then valid request -> 201
|
||||
PASS: rejected requests (400, 404) do not store a result for the key
|
||||
same key and body by an outsider -> 404; by alice after logout -> 401
|
||||
PASS: a retry checks the session and chat access again, the saved answer is not leaked
|
||||
POST sent, connection closed without reading the answer; retry -> 201; messages: 1
|
||||
PASS: an unconfirmed POST can be safely retried with the same key
|
||||
8 passed, 0 failed
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"scenario": "collector-down",
|
||||
"date": "2026-11-01 00:39:14",
|
||||
"outage_s": 90,
|
||||
"baseline": {
|
||||
"requests": 1002,
|
||||
"codes": {
|
||||
"201": 1002
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 66.8,
|
||||
"p95_ms_successful": 15.2
|
||||
},
|
||||
"during": {
|
||||
"requests": 6263,
|
||||
"codes": {
|
||||
"201": 6263
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 67.4,
|
||||
"p95_ms_successful": 14.3
|
||||
},
|
||||
"api_mib_before": 280.5,
|
||||
"api_mib_max": 292.5,
|
||||
"sdk_lost_spans_api": {
|
||||
"processor_queue_full": 0,
|
||||
"exporter_failed": 24576
|
||||
},
|
||||
"sdk_exported_ok_after_restart": 10524,
|
||||
"after": {
|
||||
"requests": 1703,
|
||||
"codes": {
|
||||
"201": 1703
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 68.1,
|
||||
"p95_ms_successful": 13.8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# incident-collector: lab6: Collector down -> API unaffected, SDK queue bounded, drops counted
|
||||
# date: 2026-11-01 00:41:37, commit: unknown
|
||||
# command: python student-tests/incidents.py collector-down
|
||||
# exit code: 0, 143.3 s
|
||||
|
||||
=== collector-down
|
||||
[ 20.3s] baseline: {'requests': 1002, 'codes': {'201': 1002}, 'success_ratio': 1.0, 'success_rps': 66.8, 'p95_ms_successful': 15.2}, api containers 280.5 MiB
|
||||
[ 20.6s] docker compose stop otel-collector
|
||||
[ 20.8s] {'t': 0.3, 'api_mib': 283.0}
|
||||
[ 31.0s] {'t': 10.5, 'api_mib': 283.2}
|
||||
[ 41.3s] {'t': 20.8, 'api_mib': 288.6}
|
||||
[ 51.5s] {'t': 31.0, 'api_mib': 289.0}
|
||||
[ 61.7s] {'t': 41.2, 'api_mib': 289.7}
|
||||
[ 71.9s] {'t': 51.4, 'api_mib': 292.5}
|
||||
[ 82.1s] {'t': 61.6, 'api_mib': 292.4}
|
||||
[ 92.4s] {'t': 71.9, 'api_mib': 292.3}
|
||||
[ 102.6s] {'t': 82.1, 'api_mib': 291.2}
|
||||
[ 113.2s] docker compose start otel-collector
|
||||
[ 143.2s] API during collector outage: {'requests': 6263, 'codes': {'201': 6263}, 'success_ratio': 1.0, 'success_rps': 67.4, 'p95_ms_successful': 14.3}; api memory 280.5 -> max 292.5 MiB; SDK lost spans (api): {'processor_queue_full': 0, 'exporter_failed': 24576}; exported OK in the last minute after restart: 10524
|
||||
[ 143.2s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-collector-down.json
|
||||
PASS: Collector down -> API unaffected, SDK memory bounded, lost spans counted, export resumes after start
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"scenario": "db-slow",
|
||||
"date": "2026-11-01 00:42:49",
|
||||
"lock_seconds": 210,
|
||||
"baseline": {
|
||||
"requests": 2648,
|
||||
"codes": {
|
||||
"201": 2648
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 132.4,
|
||||
"p95_ms_successful": 18.5,
|
||||
"server_p95_s": 0.0214
|
||||
},
|
||||
"firing_after_lock_s": 120.1,
|
||||
"diagnosis": {
|
||||
"http_5xx_ratio_1m": 1.0,
|
||||
"http_p95_messages_s": 7.375,
|
||||
"pool_used": 8.0,
|
||||
"pool_wait_p95_s": 0.001,
|
||||
"status_codes_1m": {
|
||||
"201": 0.0,
|
||||
"200": 0.0,
|
||||
"404": 0.0,
|
||||
"400": 0.0,
|
||||
"409": 0.0,
|
||||
"503": 1.6
|
||||
},
|
||||
"reads_during_lock_ms": {
|
||||
"GET /users/me + GET /chats, avg per request": 4.7,
|
||||
"max": 5.4
|
||||
},
|
||||
"api_log_db_unavailable_by_error_type": {
|
||||
"QueryCanceled": 184
|
||||
},
|
||||
"error_trace": {
|
||||
"trace_id": "1c7f8dd06427574a5f155558aa4cd975",
|
||||
"server_ms": 5006.7,
|
||||
"slowest_db_span": "INSERT",
|
||||
"slowest_db_ms": 5000.6,
|
||||
"db_span_status": "ERROR",
|
||||
"db_share": 0.999,
|
||||
"tree": [
|
||||
"- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5006.7 ms) ERROR http.response.status_code=503 error.type=503",
|
||||
" - [api] redis GET (CLIENT, 0.2 ms)",
|
||||
" - [api] SELECT (CLIENT, 0.4 ms)",
|
||||
" - [api] INSERT (CLIENT, 5000.6 ms) ERROR"
|
||||
]
|
||||
},
|
||||
"handler_cpu_contrast": {
|
||||
"trace_id": "a6da2e3fe7b0c229773f36fa507293ca",
|
||||
"server_ms": 34.0,
|
||||
"argon2id_ms": 29.0,
|
||||
"db_ms_total": 0.6,
|
||||
"tree": [
|
||||
"- [api] POST /api/v1/users (SERVER, 34.0 ms) http.response.status_code=201",
|
||||
" - [api] argon2id hash (INTERNAL, 29.0 ms)",
|
||||
" - [api] INSERT (CLIENT, 0.6 ms)"
|
||||
]
|
||||
}
|
||||
},
|
||||
"during_lock": {
|
||||
"requests": 326,
|
||||
"codes": {
|
||||
"503": 320,
|
||||
"201": 6
|
||||
},
|
||||
"success_ratio": 0.0184,
|
||||
"success_rps": 0.0,
|
||||
"p95_ms_successful": 2718.4
|
||||
},
|
||||
"resolved_after_unlock_s": 30.0,
|
||||
"after": {
|
||||
"requests": 3298,
|
||||
"codes": {
|
||||
"201": 3298
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 131.9,
|
||||
"p95_ms_successful": 21.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
# incident-db: lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved
|
||||
# date: 2026-11-01 00:47:15, commit: unknown
|
||||
# command: python student-tests/incidents.py db-slow
|
||||
# exit code: 0, 265.4 s
|
||||
|
||||
=== db-slow
|
||||
[ 0.1s] load: 8 threads POST /messages
|
||||
[ 25.1s] baseline: {'requests': 2648, 'codes': {'201': 2648}, 'success_ratio': 1.0, 'success_rps': 132.4, 'p95_ms_successful': 18.5, 'server_p95_s': 0.0214}
|
||||
[ 25.1s] LOCK TABLE messages IN ACCESS EXCLUSIVE MODE for 210 s (PostgreSQL alive, writes wait)
|
||||
[ 25.1s] 5xx ratio=0.0 p95=0.021 s pool used=0.0 waiting=0.0
|
||||
[ 30.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
|
||||
[ 35.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
|
||||
[ 40.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
|
||||
[ 45.1s] 5xx ratio=0.005 p95=0.022 s pool used=8.0 waiting=0.0
|
||||
[ 50.1s] 5xx ratio=0.005 p95=0.023 s pool used=8.0 waiting=0.0
|
||||
[ 55.1s] 5xx ratio=0.005 p95=0.023 s pool used=8.0 waiting=0.0
|
||||
[ 60.1s] 5xx ratio=0.01 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 65.1s] 5xx ratio=0.01 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 70.1s] 5xx ratio=0.01 p95=5.688 s pool used=8.0 waiting=0.0
|
||||
[ 75.2s] 5xx ratio=0.069 p95=5.688 s pool used=8.0 waiting=0.0
|
||||
[ 80.2s] 5xx ratio=0.069 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 85.2s] 5xx ratio=0.069 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 90.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 95.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 100.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 105.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 110.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 115.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 120.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 125.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 130.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 135.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 140.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 145.2s] ALERT MessengerHighErrorRate firing (120.1 s after lock)
|
||||
[ 151.5s] diagnosis: {"http_5xx_ratio_1m": 1.0, "http_p95_messages_s": 7.375, "pool_used": 8.0, "pool_wait_p95_s": 0.001, "status_codes_1m": {"201": 0.0, "200": 0.0, "404": 0.0, "400": 0.0, "409": 0.0, "503": 1.6}, "reads_during_lock_ms": {"GET /users/me + GET /chats, avg per request": 4.7, "max": 5.4}, "api_log_db_unavailable_by_error_type": {"QueryCanceled": 184}}
|
||||
[ 151.5s] error trace (DB): {"trace_id": "1c7f8dd06427574a5f155558aa4cd975", "server_ms": 5006.7, "slowest_db_span": "INSERT", "slowest_db_ms": 5000.6, "db_span_status": "ERROR", "db_share": 0.999}
|
||||
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5006.7 ms) ERROR http.response.status_code=503 error.type=503
|
||||
- [api] redis GET (CLIENT, 0.2 ms)
|
||||
- [api] SELECT (CLIENT, 0.4 ms)
|
||||
- [api] INSERT (CLIENT, 5000.6 ms) ERROR
|
||||
[ 151.5s] contrast, slow handler (CPU): {"trace_id": "a6da2e3fe7b0c229773f36fa507293ca", "server_ms": 34.0, "argon2id_ms": 29.0, "db_ms_total": 0.6}
|
||||
- [api] POST /api/v1/users (SERVER, 34.0 ms) http.response.status_code=201
|
||||
- [api] argon2id hash (INTERNAL, 29.0 ms)
|
||||
- [api] INSERT (CLIENT, 0.6 ms)
|
||||
[ 235.4s] lock released (psql exit 0), 210.3 s after LOCK
|
||||
[ 235.4s] ... MessengerHighErrorRate: firing (0 s)
|
||||
[ 240.4s] ... MessengerHighErrorRate: firing (5 s)
|
||||
[ 245.4s] ... MessengerHighErrorRate: firing (10 s)
|
||||
[ 250.4s] ... MessengerHighErrorRate: firing (15 s)
|
||||
[ 255.4s] ... MessengerHighErrorRate: firing (20 s)
|
||||
[ 260.4s] ... MessengerHighErrorRate: firing (25 s)
|
||||
[ 265.4s] ALERT MessengerHighErrorRate resolved 30.0 s after unlock
|
||||
[ 265.4s] load: during lock {'requests': 326, 'codes': {'503': 320, '201': 6}, 'success_ratio': 0.0184, 'success_rps': 0.0, 'p95_ms_successful': 2718.4}; after {'requests': 3298, 'codes': {'201': 3298}, 'success_ratio': 1.0, 'success_rps': 131.9, 'p95_ms_successful': 21.0}
|
||||
[ 265.4s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-db-slow.json
|
||||
PASS: slow DB -> 503 -> MessengerHighErrorRate firing; traces show the time in the INSERT span (not the handler); unlock -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,307 @@
|
||||
{
|
||||
"scenario": "telemetry-down",
|
||||
"date": "2026-11-01 00:32:59",
|
||||
"stopped": [
|
||||
"tempo",
|
||||
"loki"
|
||||
],
|
||||
"outage_s": 150,
|
||||
"baseline": {
|
||||
"requests": 955,
|
||||
"codes": {
|
||||
"201": 955
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 63.7,
|
||||
"p95_ms_successful": 17.9
|
||||
},
|
||||
"collector_heap_before_mib": 44.1,
|
||||
"collector_container_before_mib": 224.4,
|
||||
"during": {
|
||||
"requests": 11500,
|
||||
"codes": {
|
||||
"201": 11500
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 68.3,
|
||||
"p95_ms_successful": 13.2
|
||||
},
|
||||
"samples": [
|
||||
{
|
||||
"t": 0.0,
|
||||
"collector_heap_mib": 39.8,
|
||||
"collector_rss_mib": 228.5,
|
||||
"collector_container_mib": 228.6,
|
||||
"queue": {
|
||||
"otlp_http/loki": 0.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 6.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 10.1,
|
||||
"collector_heap_mib": 52.2,
|
||||
"collector_rss_mib": 228.6,
|
||||
"collector_container_mib": 228.6,
|
||||
"queue": {
|
||||
"otlp_http/loki": 5.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 10.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 20.3,
|
||||
"collector_heap_mib": 52.2,
|
||||
"collector_rss_mib": 228.6,
|
||||
"collector_container_mib": 228.7,
|
||||
"queue": {
|
||||
"otlp_http/loki": 5.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 10.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 30.4,
|
||||
"collector_heap_mib": 63.3,
|
||||
"collector_rss_mib": 230.2,
|
||||
"collector_container_mib": 233.6,
|
||||
"queue": {
|
||||
"otlp_http/loki": 12.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 14.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 40.6,
|
||||
"collector_heap_mib": 48.5,
|
||||
"collector_rss_mib": 234.5,
|
||||
"collector_container_mib": 234.5,
|
||||
"queue": {
|
||||
"otlp_http/loki": 20.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 18.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 50.7,
|
||||
"collector_heap_mib": 48.5,
|
||||
"collector_rss_mib": 234.5,
|
||||
"collector_container_mib": 234.6,
|
||||
"queue": {
|
||||
"otlp_http/loki": 20.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 18.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 60.8,
|
||||
"collector_heap_mib": 59.5,
|
||||
"collector_rss_mib": 234.6,
|
||||
"collector_container_mib": 234.9,
|
||||
"queue": {
|
||||
"otlp_http/loki": 27.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 22.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 71.0,
|
||||
"collector_heap_mib": 70.7,
|
||||
"collector_rss_mib": 239.4,
|
||||
"collector_container_mib": 242.2,
|
||||
"queue": {
|
||||
"otlp_http/loki": 35.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 26.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 81.2,
|
||||
"collector_heap_mib": 70.7,
|
||||
"collector_rss_mib": 239.4,
|
||||
"collector_container_mib": 247.4,
|
||||
"queue": {
|
||||
"otlp_http/loki": 35.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 26.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 91.3,
|
||||
"collector_heap_mib": 58.1,
|
||||
"collector_rss_mib": 247.4,
|
||||
"collector_container_mib": 247.4,
|
||||
"queue": {
|
||||
"otlp_http/loki": 42.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 30.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 101.4,
|
||||
"collector_heap_mib": 69.3,
|
||||
"collector_rss_mib": 247.5,
|
||||
"collector_container_mib": 247.5,
|
||||
"queue": {
|
||||
"otlp_http/loki": 50.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 32.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 111.6,
|
||||
"collector_heap_mib": 69.3,
|
||||
"collector_rss_mib": 247.5,
|
||||
"collector_container_mib": 249.7,
|
||||
"queue": {
|
||||
"otlp_http/loki": 50.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 32.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 121.8,
|
||||
"collector_heap_mib": 80.2,
|
||||
"collector_rss_mib": 249.9,
|
||||
"collector_container_mib": 258.8,
|
||||
"queue": {
|
||||
"otlp_http/loki": 57.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 36.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 131.9,
|
||||
"collector_heap_mib": 92.7,
|
||||
"collector_rss_mib": 262.3,
|
||||
"collector_container_mib": 265.4,
|
||||
"queue": {
|
||||
"otlp_http/loki": 63.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 40.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 142.1,
|
||||
"collector_heap_mib": 92.7,
|
||||
"collector_rss_mib": 262.3,
|
||||
"collector_container_mib": 273.3,
|
||||
"queue": {
|
||||
"otlp_http/loki": 63.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 40.0
|
||||
},
|
||||
"alert": "firing"
|
||||
}
|
||||
],
|
||||
"collector_heap_max_mib": 92.7,
|
||||
"collector_rss_max_mib": 262.3,
|
||||
"collector_container_max_mib": 273.3,
|
||||
"TelemetryExportFailing_firing_at_s": 101.4,
|
||||
"queue_drained_after_start_s": 80.0,
|
||||
"probe_traces": [
|
||||
{
|
||||
"sent_at_s": 0.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 10.1,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 20.3,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 30.4,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 40.6,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 50.7,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 60.8,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 71.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 81.2,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 91.3,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 101.4,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 111.6,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 121.7,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 131.9,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 142.1,
|
||||
"http": 201,
|
||||
"trace_in_tempo": false
|
||||
}
|
||||
],
|
||||
"lost_in_collector": {
|
||||
"spans": 4096,
|
||||
"log_records": 269
|
||||
},
|
||||
"resolved_after_start_s": 155.4,
|
||||
"after": {
|
||||
"requests": 10186,
|
||||
"codes": {
|
||||
"201": 10186
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 67.7,
|
||||
"p95_ms_successful": 14.2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# incident-telemetry: lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted
|
||||
# date: 2026-11-01 00:39:14, commit: unknown
|
||||
# command: python student-tests/incidents.py telemetry-down
|
||||
# exit code: 0, 374.8 s
|
||||
|
||||
=== telemetry-down
|
||||
[ 20.2s] baseline: {'requests': 955, 'codes': {'201': 955}, 'success_ratio': 1.0, 'success_rps': 63.7, 'p95_ms_successful': 17.9}, collector heap 44.1 MiB, container 224.4 MiB
|
||||
[ 50.9s] docker compose stop tempo loki: stopped
|
||||
[ 51.1s] {'t': 0.0, 'collector_heap_mib': 39.8, 'collector_rss_mib': 228.5, 'collector_container_mib': 228.6, 'queue': {'otlp_http/loki': 0.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 6.0}, 'alert': 'inactive'}
|
||||
[ 61.2s] {'t': 10.1, 'collector_heap_mib': 52.2, 'collector_rss_mib': 228.6, 'collector_container_mib': 228.6, 'queue': {'otlp_http/loki': 5.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 10.0}, 'alert': 'inactive'}
|
||||
[ 71.3s] {'t': 20.3, 'collector_heap_mib': 52.2, 'collector_rss_mib': 228.6, 'collector_container_mib': 228.7, 'queue': {'otlp_http/loki': 5.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 10.0}, 'alert': 'inactive'}
|
||||
[ 81.5s] {'t': 30.4, 'collector_heap_mib': 63.3, 'collector_rss_mib': 230.2, 'collector_container_mib': 233.6, 'queue': {'otlp_http/loki': 12.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 14.0}, 'alert': 'inactive'}
|
||||
[ 91.6s] {'t': 40.6, 'collector_heap_mib': 48.5, 'collector_rss_mib': 234.5, 'collector_container_mib': 234.5, 'queue': {'otlp_http/loki': 20.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 18.0}, 'alert': 'pending'}
|
||||
[ 101.8s] {'t': 50.7, 'collector_heap_mib': 48.5, 'collector_rss_mib': 234.5, 'collector_container_mib': 234.6, 'queue': {'otlp_http/loki': 20.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 18.0}, 'alert': 'pending'}
|
||||
[ 112.0s] {'t': 60.8, 'collector_heap_mib': 59.5, 'collector_rss_mib': 234.6, 'collector_container_mib': 234.9, 'queue': {'otlp_http/loki': 27.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 22.0}, 'alert': 'pending'}
|
||||
[ 122.1s] {'t': 71.0, 'collector_heap_mib': 70.7, 'collector_rss_mib': 239.4, 'collector_container_mib': 242.2, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 26.0}, 'alert': 'pending'}
|
||||
[ 132.2s] {'t': 81.2, 'collector_heap_mib': 70.7, 'collector_rss_mib': 239.4, 'collector_container_mib': 247.4, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 26.0}, 'alert': 'pending'}
|
||||
[ 142.4s] {'t': 91.3, 'collector_heap_mib': 58.1, 'collector_rss_mib': 247.4, 'collector_container_mib': 247.4, 'queue': {'otlp_http/loki': 42.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 30.0}, 'alert': 'pending'}
|
||||
[ 152.5s] {'t': 101.4, 'collector_heap_mib': 69.3, 'collector_rss_mib': 247.5, 'collector_container_mib': 247.5, 'queue': {'otlp_http/loki': 50.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 32.0}, 'alert': 'firing'}
|
||||
[ 162.7s] {'t': 111.6, 'collector_heap_mib': 69.3, 'collector_rss_mib': 247.5, 'collector_container_mib': 249.7, 'queue': {'otlp_http/loki': 50.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 32.0}, 'alert': 'firing'}
|
||||
[ 172.9s] {'t': 121.8, 'collector_heap_mib': 80.2, 'collector_rss_mib': 249.9, 'collector_container_mib': 258.8, 'queue': {'otlp_http/loki': 57.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 36.0}, 'alert': 'firing'}
|
||||
[ 183.0s] {'t': 131.9, 'collector_heap_mib': 92.7, 'collector_rss_mib': 262.3, 'collector_container_mib': 265.4, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 40.0}, 'alert': 'firing'}
|
||||
[ 193.2s] {'t': 142.1, 'collector_heap_mib': 92.7, 'collector_rss_mib': 262.3, 'collector_container_mib': 273.3, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 40.0}, 'alert': 'firing'}
|
||||
[ 219.3s] docker compose start tempo loki
|
||||
[ 299.3s] exporter queues drained 80.0 s after start
|
||||
[ 324.7s] ... TelemetryExportFailing: firing (0 s)
|
||||
[ 329.7s] ... TelemetryExportFailing: firing (5 s)
|
||||
[ 334.7s] ... TelemetryExportFailing: firing (10 s)
|
||||
[ 339.7s] ... TelemetryExportFailing: firing (15 s)
|
||||
[ 344.7s] ... TelemetryExportFailing: firing (20 s)
|
||||
[ 349.7s] ... TelemetryExportFailing: firing (25 s)
|
||||
[ 354.7s] ... TelemetryExportFailing: firing (30 s)
|
||||
[ 359.7s] ... TelemetryExportFailing: firing (35 s)
|
||||
[ 364.7s] ... TelemetryExportFailing: firing (40 s)
|
||||
[ 369.7s] ... TelemetryExportFailing: firing (45 s)
|
||||
[ 374.7s] API during outage: {'requests': 11500, 'codes': {'201': 11500}, 'success_ratio': 1.0, 'success_rps': 68.3, 'p95_ms_successful': 13.2}
|
||||
[ 374.7s] probe traces: 14/15 reached Tempo (lost: sent at [142.1] s)
|
||||
[ 374.7s] lost in Collector (send_failed+enqueue_failed): {'spans': 4096, 'log_records': 269}; collector heap 44.1 -> max 92.7 MiB (memory_limiter 200 MiB), container max 273.3 MiB
|
||||
[ 374.7s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-telemetry-down.json
|
||||
PASS: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted; recovery -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"scenario": "worker-stop",
|
||||
"date": "2026-11-01 00:26:35",
|
||||
"firing_after_stop_s": {
|
||||
"MessengerWorkerNoConsumers": 66.4,
|
||||
"MessengerQueueLagGrowing": 111.4
|
||||
},
|
||||
"diagnosis": {
|
||||
"queue_consumers": 0.0,
|
||||
"broker_queue_depth": 3.0,
|
||||
"jobs_backlog_queued": 3.0,
|
||||
"oldest_job_age_s": 97.3,
|
||||
"outbox_oldest_age_s": 0.0,
|
||||
"published_ok_last_5m": 3.102218085931441,
|
||||
"worker_metrics_last_seen_s": 110.0,
|
||||
"last_worker_log": {
|
||||
"event": "service.stopped",
|
||||
"message": "stopped"
|
||||
},
|
||||
"upload_trace_span_names": [
|
||||
"INSERT",
|
||||
"NOTIFY",
|
||||
"POST /api/v1/chats/{chat_id}/attachments",
|
||||
"S3 PutObject",
|
||||
"SELECT",
|
||||
"UPDATE",
|
||||
"create attachments",
|
||||
"inspect image",
|
||||
"publish attachments",
|
||||
"redis GET"
|
||||
],
|
||||
"upload_trace_has_consumer_span": false
|
||||
},
|
||||
"ready_after_start_s": [
|
||||
1.5,
|
||||
1.6,
|
||||
2.0
|
||||
],
|
||||
"resolved_after_start_s": {
|
||||
"MessengerWorkerNoConsumers": 17.0,
|
||||
"MessengerQueueLagGrowing": 17.0
|
||||
},
|
||||
"after_recovery": {
|
||||
"jobs_backlog_queued": 0.0,
|
||||
"oldest_job_age_s": 0.0,
|
||||
"queue_consumers": 2.0
|
||||
},
|
||||
"time_to_ready_p95_5m_s": 117.0
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
# incident-worker: lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved
|
||||
# date: 2026-11-01 00:28:44, commit: unknown
|
||||
# command: python student-tests/incidents.py worker-stop
|
||||
# exit code: 0, 128.6 s
|
||||
|
||||
=== worker-stop
|
||||
[ 0.1s] baseline: consumers=2.0, oldest job age=0.0 s
|
||||
[ 1.3s] docker compose stop worker
|
||||
[ 1.4s] uploaded 3 attachments: 202 queued (API accepts without worker)
|
||||
[ 1.4s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
|
||||
[ 6.4s] consumers=0.0 backlog queued=3.0 oldest age=2.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 11.4s] consumers=0.0 backlog queued=3.0 oldest age=2.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 16.4s] consumers=0.0 backlog queued=3.0 oldest age=12.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 21.4s] consumers=0.0 backlog queued=3.0 oldest age=12.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 26.4s] consumers=0.0 backlog queued=3.0 oldest age=22.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 31.4s] consumers=0.0 backlog queued=3.0 oldest age=22.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 36.4s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 41.4s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 46.4s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 51.4s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 56.4s] consumers=0.0 backlog queued=3.0 oldest age=47.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 61.5s] consumers=0.0 backlog queued=3.0 oldest age=47.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 66.5s] ALERT MessengerWorkerNoConsumers firing (66.4 s after stop)
|
||||
[ 66.5s] consumers=0.0 backlog queued=3.0 oldest age=57.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 71.5s] consumers=0.0 backlog queued=3.0 oldest age=57.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 76.5s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 81.5s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 86.5s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 91.5s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 96.5s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 101.5s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 106.5s] consumers=0.0 backlog queued=3.0 oldest age=97.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 111.5s] ALERT MessengerQueueLagGrowing firing (111.4 s after stop)
|
||||
[ 111.5s] diagnosis: {"queue_consumers": 0.0, "broker_queue_depth": 3.0, "jobs_backlog_queued": 3.0, "oldest_job_age_s": 97.3, "outbox_oldest_age_s": 0.0, "published_ok_last_5m": 3.102218085931441, "worker_metrics_last_seen_s": 110.0, "last_worker_log": {"event": "service.stopped", "message": "stopped"}, "upload_trace_span_names": ["INSERT", "NOTIFY", "POST /api/v1/chats/{chat_id}/attachments", "S3 PutObject", "SELECT", "UPDATE", "create attachments", "inspect image", "publish attachments", "redis GET"], "upload_trace_has_consumer_span": false}
|
||||
[ 111.6s] docker compose start worker
|
||||
[ 113.5s] all attachments ready 2.0 s after worker start; backlog now 3.0
|
||||
[ 113.5s] ... MessengerWorkerNoConsumers: firing (0 s)
|
||||
[ 118.5s] ... MessengerWorkerNoConsumers: firing (5 s)
|
||||
[ 123.5s] ... MessengerWorkerNoConsumers: firing (10 s)
|
||||
[ 128.5s] alerts resolved: {'MessengerWorkerNoConsumers': 17.0, 'MessengerQueueLagGrowing': 17.0}; now {'jobs_backlog_queued': 0.0, 'oldest_job_age_s': 0.0, 'queue_consumers': 2.0}
|
||||
[ 128.5s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-worker-stop.json
|
||||
PASS: worker stop -> no consumers + growing queue lag -> firing; cause from metrics/logs/trace; start -> backlog drained -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,8 @@
|
||||
# jobs-concurrency: lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing
|
||||
# date: 2026-11-01 00:52:34, commit: unknown
|
||||
# command: python student-tests/test_jobs.py concurrency
|
||||
# exit code: 0, 7.1 s
|
||||
|
||||
--- concurrency: Ограниченная конкуренция: WORKER_CONCURRENCY потребителей с prefetch=1; одновременно processing <= 2.
|
||||
2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 4.1 s after worker start, peak processing 2 of 8 (22 samples)
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,9 @@
|
||||
# jobs-outbox: lab5: dispatcher crash between COMMIT and publish / after confirm
|
||||
# date: 2026-11-01 00:51:38, commit: unknown
|
||||
# command: python student-tests/test_jobs.py outbox-crash
|
||||
# exit code: 0, 7.4 s
|
||||
|
||||
--- outbox-crash: Разрыв COMMIT/publish: dispatcher падает после COMMIT задания до publish и после confirm до отметки.
|
||||
dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job 18ab06f7-657b-4508-9ba5-844bd2c7ba2e ready, attempt 1, no manual action
|
||||
dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,16 @@
|
||||
# jobs-recovery: lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits
|
||||
# date: 2026-11-01 00:48:13, commit: unknown
|
||||
# command: python student-tests/test_jobs.py worker-down broker-down
|
||||
# exit code: 0, 44.2 s
|
||||
|
||||
--- worker-down: Защита п.2-3: worker остановлен -> 202 -> сообщение с вложением -> рестарт API+broker -> worker -> ready.
|
||||
worker stopped
|
||||
upload while worker is down -> 202 queued, attachment 748b0b56-e355-48a0-9ac6-4b731a3432a9
|
||||
message with attachment 201, content 409, other messages 201; job 87ddc8fa-f8fe-4241-bf18-95fd2d4a2762 published, queue messages/unacked = (1, 0)
|
||||
rabbitmq and api restarted with volumes; queue still holds 1 message(s); status queued
|
||||
worker started -> same job 87ddc8fa-f8fe-4241-bf18-95fd2d4a2762 ready, thumbnail downloadable; staging object deleted
|
||||
--- broker-down: Брокер недоступен: API принимает (outbox), dispatcher копит и публикует после восстановления.
|
||||
rabbitmq stopped
|
||||
upload -> 202 and /health/ready 200 without broker; outbox row pending for job 5784e1e7-7173-4a27-a3ad-72216f4a43a9
|
||||
rabbitmq started -> dispatcher published the pending row -> ready
|
||||
2 passed, 0 failed
|
||||
@@ -0,0 +1,15 @@
|
||||
# jobs-retry: lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ
|
||||
# date: 2026-11-01 00:52:27, commit: unknown
|
||||
# command: python student-tests/test_jobs.py retry exhausted-replay permanent dlq
|
||||
# exit code: 0, 49.1 s
|
||||
|
||||
--- retry: Временные ошибки S3: backoff с jitter, затем ready; задержки видны в журнале.
|
||||
2 x storage_unavailable -> retries after 1.40 s and 3.50 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready
|
||||
--- exhausted-replay: Исчерпание попыток -> failed/retry_exhausted, реестр failed, явный replay; replay ready — отказ.
|
||||
5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable)
|
||||
ops replay -> same job_id fce6904a-fe4b-429c-821a-e3b55a43b0ef attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs"
|
||||
--- permanent: Постоянная ошибка (битое изображение в worker) -> failed сразу, без повторов.
|
||||
invalid image in the worker -> failed/invalid_image at attempt 1, no retry (permanent error)
|
||||
--- dlq: Невалидные сообщения и сообщения о неизвестной job -> DLQ; dlq-replay их не исполняет.
|
||||
schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job']
|
||||
4 passed, 0 failed
|
||||
@@ -0,0 +1,14 @@
|
||||
# jobs-variants: lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped
|
||||
# date: 2026-11-01 00:47:29, commit: unknown
|
||||
# command: python student-tests/test_jobs.py variants
|
||||
# exit code: 0, 14.3 s
|
||||
|
||||
--- variants: thumbnail/crop/optimized по контракту, EXIF orientation, alpha -> белый, без увеличения, без метаданных.
|
||||
thumb320: thumbnail 256x160, crop 128x128, optimized 320x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
exif6: thumbnail 192x256, crop 128x128, optimized 300x400; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
alpha: thumbnail 256x170, crop 128x128, optimized 300x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
tiny: thumbnail 40x30, crop 128x128, optimized 40x30; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
large: thumbnail 256x170, crop 128x128, optimized 1280x853; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
strip: thumbnail 256x1, crop 128x128, optimized 1280x1; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
unknown variant name -> 400; variants carry their own size/sha256, original fields describe the upload
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 6,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.083,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 8762,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 291.265,
|
||||
"successful_latency_ms": {
|
||||
"p50": 11.557,
|
||||
"p95": 26.659,
|
||||
"p99": 56.425
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# load: public load generator, 30 s, concurrency 4
|
||||
# date: 2026-11-01 00:42:08, commit: unknown
|
||||
# command: python tests/load.py --base-url http://127.0.0.1:8080 --duration 30 --concurrency 4 --output evidence/load.json
|
||||
# exit code: 0, 30.4 s
|
||||
|
||||
{
|
||||
"lab": 6,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.083,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 8762,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 291.265,
|
||||
"successful_latency_ms": {
|
||||
"p50": 11.557,
|
||||
"p95": 26.659,
|
||||
"p99": 56.425
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# race: lab2 races via the balancer
|
||||
# date: 2026-11-01 00:52:53, commit: unknown
|
||||
# command: python student-tests/test_race.py
|
||||
# exit code: 0, 1.5 s
|
||||
|
||||
sent 100 messages from 10 clients in 0.34 s; read 100 in 4 pages, unique ids: 100
|
||||
PASS: 100 concurrent messages from 10 clients, no losses and no duplicates
|
||||
20 parallel registrations of one username: 201 x1, 409 x19
|
||||
PASS: concurrent registration created exactly one user
|
||||
2 passed, 0 failed
|
||||
@@ -0,0 +1,6 @@
|
||||
# smoke: public smoke via the balancer (make test) with telemetry ON, with attachment
|
||||
# date: 2026-11-01 00:22:30, commit: unknown
|
||||
# command: python tests/smoke.py --base-url http://127.0.0.1:8080
|
||||
# exit code: 0, 1.7 s
|
||||
|
||||
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,26 @@
|
||||
# student-tests: lab1/lab2 API tests via the balancer
|
||||
# date: 2026-11-01 00:52:52, commit: unknown
|
||||
# command: python student-tests/test_api.py
|
||||
# exit code: 0, 2.0 s
|
||||
|
||||
PASS: duplicate username returns 409
|
||||
PASS: invalid JSON returns 400
|
||||
PASS: wrong and extra fields return 400
|
||||
PASS: foreign chat returns 404
|
||||
PASS: empty and too long messages return 400, 4000 chars is ok
|
||||
PASS: pagination works across multiple pages, foreign cursor returns 400
|
||||
PASS: empty cursor (?cursor= and ?cursor) returns 400, no cursor returns the first page
|
||||
PASS: chat list pagination
|
||||
PASS: unicode text is stored as is
|
||||
PASS: strings with U+0000 are stored and returned as is
|
||||
PASS: user response has no password or hash
|
||||
PASS: password length 12..128, blank password is rejected
|
||||
PASS: Basic login returns opaque Bearer token with expiry
|
||||
PASS: wrong password and unknown user both return the same 401
|
||||
PASS: malformed Basic header returns 401
|
||||
PASS: password with colon and unicode works
|
||||
PASS: business endpoints need Bearer; Basic and X-User-Id give 401
|
||||
PASS: X-User-Id does not change the current user
|
||||
PASS: 401 comes before 400 and 404
|
||||
PASS: logout revokes only the current session
|
||||
20 passed, 0 failed
|
||||
@@ -0,0 +1,48 @@
|
||||
# Сводка проверок (нативная песочница, без Docker)
|
||||
|
||||
Стенд теми же процессами без контейнеров: PostgreSQL 16, Redis 7, RabbitMQ 3.12, SeaweedFS 3.80, HAProxy 2.8, 2 реплики API, dispatcher, worker, janitor (Python 3.11, requirements.txt), otelcol-contrib 0.164.0, Prometheus 3.15.1, Loki 3.7.9, Tempo 3.1.1 с конфигами из infra/ (адреса -> 127.0.0.1). Команды `docker compose` тестов выполнялись через подмену на управление процессами. Машина: Linux x86_64, 2 vCPU, 8 GiB RAM.
|
||||
|
||||
| Шаг | Что проверяет | Результат | Время, с | Файл |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| check | offline contract check (make check) | PASS | 0 | evidence/native-sandbox/check.txt |
|
||||
| smoke | public smoke via the balancer (make test) with telemetry ON, with attachment | PASS | 2 | evidence/native-sandbox/smoke.txt |
|
||||
| configs | lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning | PASS | 1 | evidence/native-sandbox/configs.txt |
|
||||
| telemetry | lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets | PASS | 77 | evidence/native-sandbox/telemetry.txt |
|
||||
| dashboard | lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels | PASS | 0 | evidence/native-sandbox/dashboard.txt |
|
||||
| telemetry-history | lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes) | PASS | 52 | evidence/native-sandbox/telemetry-history.txt |
|
||||
| incident-worker | lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved | PASS | 129 | evidence/native-sandbox/incident-worker.txt |
|
||||
| incident-db | lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved | PASS | 265 | evidence/native-sandbox/incident-db.txt |
|
||||
| incident-telemetry | lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted | PASS | 375 | evidence/native-sandbox/incident-telemetry.txt |
|
||||
| incident-collector | lab6: Collector down -> API unaffected, SDK queue bounded, drops counted | PASS | 143 | evidence/native-sandbox/incident-collector.txt |
|
||||
| jobs-variants | lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped | PASS | 14 | evidence/native-sandbox/jobs-variants.txt |
|
||||
| jobs-recovery | lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits | PASS | 44 | evidence/native-sandbox/jobs-recovery.txt |
|
||||
| jobs-outbox | lab5: dispatcher crash between COMMIT and publish / after confirm | PASS | 7 | evidence/native-sandbox/jobs-outbox.txt |
|
||||
| jobs-retry | lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ | PASS | 49 | evidence/native-sandbox/jobs-retry.txt |
|
||||
| jobs-concurrency | lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing | PASS | 7 | evidence/native-sandbox/jobs-concurrency.txt |
|
||||
| attachments | lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids | PASS | 14 | evidence/native-sandbox/attachments.txt |
|
||||
| idempotency | Idempotency-Key, parallel same key via replicas | PASS | 2 | evidence/native-sandbox/idempotency.txt |
|
||||
| student-tests | lab1/lab2 API tests via the balancer | PASS | 2 | evidence/native-sandbox/student-tests.txt |
|
||||
| race | lab2 races via the balancer | PASS | 2 | evidence/native-sandbox/race.txt |
|
||||
| load | public load generator, 30 s, concurrency 4 | PASS | 30 | evidence/native-sandbox/load.txt |
|
||||
|
||||
# Замеры
|
||||
|
||||
Алерты на контролируемых инцидентах (`student-tests/incidents.py`, состояние из Prometheus /api/v1/alerts):
|
||||
|
||||
| Инцидент | Воздействие | Алерт | firing через, с | resolved через, с после устранения |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerWorkerNoConsumers | 66.4 (от stop) | 17.0 (от start) |
|
||||
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerQueueLagGrowing | 111.4 (от stop) | 17.0 (от start) |
|
||||
| 2. PostgreSQL | `LOCK TABLE messages IN ACCESS EXCLUSIVE MODE` на 210 с под нагрузкой 8 потоков | MessengerHighErrorRate | 120.1 (от LOCK) | 30.0 (от COMMIT блокировки) |
|
||||
| 3. телеметрия | `docker compose stop tempo loki` на 150 с | TelemetryExportFailing | 101.4 (от stop) | 155.4 (от start) |
|
||||
|
||||
Инцидент 1, наблюдения в момент firing: consumers очереди = 0.0, сообщений в RabbitMQ = 3.0, queued заданий = 3.0, возраст старейшего = 97.3 с, возраст outbox = 0.0 с (публикация работает), метрики worker не обновлялись 110.0 с, последний лог worker: event=`service.stopped`; трасса загрузки содержит `publish attachments`, но не содержит `process attachments.process.v1`. После start: вложения ready через 2.0 с, backlog 0.0.
|
||||
|
||||
Инцидент 2, наблюдения: доля 5xx (1m) = 1.0, коды POST /messages за 1m = {'201': 0.0, '200': 0.0, '404': 0.0, '400': 0.0, '409': 0.0, '503': 1.6}, p95 POST /messages = 7.375 с, чтения других таблиц (GET /users/me, /chats) во время блокировки {'GET /users/me + GET /chats, avg per request': 4.7, 'max': 5.4} мс, занято соединений пула = 8.0, p95 ожидания пула = 0.001 с, логи API event=db.unavailable по error_type: {'QueryCanceled': 184}. Error-трасса 1c7f8dd06427574a5f155558aa4cd975: server-спан 5006.7 мс, из них `INSERT` 5000.6 мс (доля 0.999, статус ERROR). Контраст «медленный обработчик» (трасса a6da2e3fe7b0c229773f36fa507293ca, POST /users): server 34.0 мс, `argon2id hash` 29.0 мс, все спаны БД 0.6 мс. Нагрузка: до 132.4 успешных записей/с, во время блокировки {'503': 320, '201': 6}, после 131.9/с без ошибок.
|
||||
|
||||
| Отказ телеметрии | API во время отказа | Память | Потери телеметрии |
|
||||
| --- | --- | --- | --- |
|
||||
| `stop tempo loki` на 150 с (окно повторов Collector 120 с) | 11500 запросов, коды {'201': 11500}, доля успеха 1.0 | heap Collector 44.1 -> max 92.7 MiB (limit 200), контейнер max 273.3 MiB | send/enqueue failed в Collector: {'spans': 4096, 'log_records': 269}; пробные трассы дошли 14/15, потеряны отправленные на [142.1] с |
|
||||
| `stop otel-collector` на 90 с | 6263 запросов, коды {'201': 6263}, доля успеха 1.0 | api 280.5 -> max 292.5 MiB (2 реплики) | SDK api потерял спанов: {'processor_queue_full': 0, 'exporter_failed': 24576} (queue_full — очередь 2048 полна, exporter_failed — Collector не принял пакет); после start экспорт возобновился (10524 спанов за минуту) |
|
||||
|
||||
Публичный генератор нагрузки при включённой телеметрии (`tests/load.py`, closed loop, concurrency 4, 30 с, 2 реплики): 291.265 успешных POST/с, ошибок 0, p50 11.557 мс, p95 26.659 мс, p99 56.425 мс (песочница 2 vCPU на всё: стенд + хранилища + клиент; не сравнивать с Docker-машиной).
|
||||
@@ -0,0 +1,9 @@
|
||||
# telemetry-history: lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes)
|
||||
# date: 2026-11-01 00:26:35, commit: unknown
|
||||
# command: python student-tests/test_telemetry.py history
|
||||
# exit code: 0, 52.2 s
|
||||
|
||||
before restart: trace 52668075eebc7fd4938de9690ba2aad1 found, its log found, sum(http_server_request_duration_seconds_count{job="messenger-api"}) at t-30s = 719
|
||||
after restart of prometheus, loki, tempo: trace 52668075eebc7fd4938de9690ba2aad1 (4 spans), 1 log record(s), metric at t-30s = 719 (same value)
|
||||
PASS: persistent volumes keep traces, logs and metrics across restarts of the stores
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,145 @@
|
||||
# telemetry: lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets
|
||||
# date: 2026-11-01 00:23:48, commit: unknown
|
||||
# command: python student-tests/test_telemetry.py request upload-chain retry-chain replay-link
|
||||
# exit code: 0, 77.1 s
|
||||
|
||||
POST message: 201, X-Request-Id=4d281ed1-39de-484a-add2-8480ef33ab9c, trace_id=97ebaba763fec926fa1e1ed3fc0fae7a (client traceparent)
|
||||
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5.8 ms) http.response.status_code=201
|
||||
- [api] redis GET (CLIENT, 0.3 ms)
|
||||
- [api] SELECT (CLIENT, 0.5 ms)
|
||||
- [api] INSERT (CLIENT, 0.8 ms)
|
||||
Loki: 'POST /api/v1/chats/{chat_id}/messages -> 201 (5.9 ms)' event=http.request severity=INFO service=messenger-api trace_id=97ebaba763fec926fa1e1ed3fc0fae7a span_id=82ab66080cb50d2a request_id=4d281ed1-39de-484a-add2-8480ef33ab9c
|
||||
PASS: request -> server span with DB/Redis children -> structured log with the same trace_id/span_id and request_id; no message text, password or token in logs/span attributes
|
||||
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 64.6 ms) http.response.status_code=202
|
||||
- [api] redis GET (CLIENT, 0.4 ms)
|
||||
- [api] SELECT (CLIENT, 0.5 ms)
|
||||
- [api] inspect image (INTERNAL, 45.7 ms)
|
||||
- [api] INSERT (CLIENT, 1.1 ms)
|
||||
- [api] S3 PutObject (CLIENT, 5.1 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
|
||||
- [api] UPDATE (CLIENT, 0.9 ms)
|
||||
- [api] create attachments (PRODUCER, 3.5 ms) messenger.job.attempt=1
|
||||
- [api] INSERT (CLIENT, 0.9 ms)
|
||||
- [api] INSERT (CLIENT, 0.9 ms)
|
||||
- [api] INSERT (CLIENT, 0.8 ms)
|
||||
- [api] NOTIFY (CLIENT, 0.3 ms)
|
||||
- [dispatcher] publish attachments (PRODUCER, 4.4 ms) messenger.job.attempt=1
|
||||
- [dispatcher] UPDATE (CLIENT, 0.9 ms)
|
||||
- [worker] process attachments.process.v1 (CONSUMER, 280.0 ms) messenger.job.attempt=1 messenger.job.outcome=ready
|
||||
- [worker] SELECT (CLIENT, 1.4 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 1.4 ms)
|
||||
- [worker] INSERT (CLIENT, 0.7 ms)
|
||||
- [worker] S3 GetObject (CLIENT, 2.9 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
|
||||
- [worker] verify source sha256 (INTERNAL, 0.1 ms)
|
||||
- [worker] imaging (INTERNAL, 238.2 ms)
|
||||
- [worker] S3 PutObject (CLIENT, 4.2 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/original
|
||||
- [worker] S3 PutObject (CLIENT, 3.4 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/optimized.webp
|
||||
- [worker] S3 PutObject (CLIENT, 3.2 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/thumbnail.jpg
|
||||
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/crop.jpg
|
||||
- [worker] commit result (INTERNAL, 7.5 ms)
|
||||
- [worker] SELECT (CLIENT, 0.7 ms)
|
||||
- [worker] INSERT (CLIENT, 1.0 ms)
|
||||
- [worker] INSERT (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.7 ms)
|
||||
- [worker] UPDATE (CLIENT, 1.0 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.7 ms)
|
||||
- [worker] INSERT (CLIENT, 0.4 ms)
|
||||
- [worker] cleanup staging (INTERNAL, 4.1 ms)
|
||||
- [worker] S3 DeleteObject (CLIENT, 2.4 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
|
||||
- [worker] UPDATE (CLIENT, 1.4 ms)
|
||||
worker logs with trace_id 0eecc096d0191a19e41ad1547110183c: ['job.claimed', 'job.ready']
|
||||
PASS: one trace 0eecc096d0191a19e41ad1547110183c: API 202 -> outbox create -> dispatcher publish -> worker consume -> 4 S3 objects + COMMIT ready (37 spans, services: messenger-api, messenger-dispatcher, messenger-worker)
|
||||
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 17.4 ms) http.response.status_code=202
|
||||
- [api] redis GET (CLIENT, 0.3 ms)
|
||||
- [api] SELECT (CLIENT, 0.5 ms)
|
||||
- [api] inspect image (INTERNAL, 0.3 ms)
|
||||
- [api] INSERT (CLIENT, 0.7 ms)
|
||||
- [api] S3 PutObject (CLIENT, 5.0 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
|
||||
- [api] UPDATE (CLIENT, 0.6 ms)
|
||||
- [api] create attachments (PRODUCER, 2.9 ms) messenger.job.attempt=1
|
||||
- [api] INSERT (CLIENT, 0.6 ms)
|
||||
- [api] INSERT (CLIENT, 0.5 ms)
|
||||
- [api] INSERT (CLIENT, 0.5 ms)
|
||||
- [api] NOTIFY (CLIENT, 0.2 ms)
|
||||
- [dispatcher] publish attachments (PRODUCER, 3.2 ms) messenger.job.attempt=1
|
||||
- [dispatcher] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] process attachments.process.v1 (CONSUMER, 255.7 ms) ERROR messenger.job.attempt=1 messenger.job.outcome=retry error.type=storage_unavailable
|
||||
- [worker] SELECT (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] INSERT (CLIENT, 0.4 ms)
|
||||
- [worker] S3 GetObject (CLIENT, 3.4 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
|
||||
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
|
||||
- [worker] imaging (INTERNAL, 238.9 ms)
|
||||
- [worker] SELECT (CLIENT, 0.6 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] create attachments (PRODUCER, 1.5 ms) messenger.job.attempt=2
|
||||
- [worker] INSERT (CLIENT, 0.8 ms)
|
||||
- [worker] NOTIFY (CLIENT, 0.2 ms)
|
||||
- [dispatcher] publish attachments (PRODUCER, 3.3 ms) messenger.job.attempt=2
|
||||
- [dispatcher] UPDATE (CLIENT, 0.6 ms)
|
||||
- [worker] process attachments.process.v1 (CONSUMER, 284.4 ms) messenger.job.attempt=2 messenger.job.outcome=ready
|
||||
- [worker] SELECT (CLIENT, 0.7 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.7 ms)
|
||||
- [worker] INSERT (CLIENT, 0.6 ms)
|
||||
- [worker] S3 GetObject (CLIENT, 3.5 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
|
||||
- [worker] verify source sha256 (INTERNAL, 0.1 ms)
|
||||
- [worker] imaging (INTERNAL, 250.7 ms)
|
||||
- [worker] S3 PutObject (CLIENT, 4.7 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/original
|
||||
- [worker] S3 PutObject (CLIENT, 3.2 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/optimized.webp
|
||||
- [worker] S3 PutObject (CLIENT, 3.0 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/thumbnail.jpg
|
||||
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/crop.jpg
|
||||
- [worker] commit result (INTERNAL, 6.6 ms)
|
||||
- [worker] SELECT (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.7 ms)
|
||||
- [worker] INSERT (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.8 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] INSERT (CLIENT, 0.5 ms)
|
||||
- [worker] cleanup staging (INTERNAL, 4.6 ms)
|
||||
- [worker] S3 DeleteObject (CLIENT, 2.7 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
|
||||
- [worker] UPDATE (CLIENT, 1.3 ms)
|
||||
- [worker] INSERT (CLIENT, 0.5 ms)
|
||||
worker log: 'job 9a82f341-ec57-49e5-aa86-6263681529c1 attempt 1: storage_unavailable (temporary) -> retry' error_type=storage_unavailable
|
||||
messenger_job_duration_seconds_count{outcome="retry"}: 0 -> 1
|
||||
PASS: retry in one trace 1abe27ebd519ac0854a844d18d679bf6: attempt 1 ERROR storage_unavailable -> create -> publish -> attempt 2 ready; retry counted in metrics and logged
|
||||
original trace 5b3ea90278cb5e18b6ad08cd32349c0e: 5 attempts, last outcome failed
|
||||
- [ops] ops replay (INTERNAL, 16.5 ms)
|
||||
- [ops] SELECT (CLIENT, 2.3 ms)
|
||||
- [ops] UPDATE (CLIENT, 0.9 ms)
|
||||
- [ops] UPDATE (CLIENT, 0.8 ms)
|
||||
- [ops] INSERT (CLIENT, 0.7 ms)
|
||||
- [ops] create attachments (PRODUCER, 1.1 ms) links=1 messenger.job.attempt=6
|
||||
- [ops] INSERT (CLIENT, 0.7 ms)
|
||||
- [ops] NOTIFY (CLIENT, 0.2 ms)
|
||||
- [dispatcher] publish attachments (PRODUCER, 5.3 ms) messenger.job.attempt=6
|
||||
- [worker] process attachments.process.v1 (CONSUMER, 281.7 ms) messenger.job.attempt=6 messenger.job.outcome=ready
|
||||
- [worker] SELECT (CLIENT, 0.4 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.4 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.2 ms)
|
||||
- [worker] S3 GetObject (CLIENT, 2.7 ms) aws.s3.key=staging/4a1c95c1e3ea46c1b51982aa45344f00
|
||||
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
|
||||
- [worker] imaging (INTERNAL, 251.3 ms)
|
||||
- [worker] S3 PutObject (CLIENT, 3.9 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/original
|
||||
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/optimized.webp
|
||||
- [worker] S3 PutObject (CLIENT, 2.8 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/thumbnail.jpg
|
||||
- [worker] S3 PutObject (CLIENT, 2.5 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/crop.jpg
|
||||
- [worker] commit result (INTERNAL, 6.0 ms)
|
||||
- [worker] SELECT (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.7 ms)
|
||||
- [worker] INSERT (CLIENT, 0.6 ms)
|
||||
- [worker] INSERT (CLIENT, 0.3 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.7 ms)
|
||||
- [worker] UPDATE (CLIENT, 0.5 ms)
|
||||
- [worker] INSERT (CLIENT, 0.4 ms)
|
||||
- [worker] cleanup staging (INTERNAL, 5.9 ms)
|
||||
- [worker] S3 DeleteObject (CLIENT, 3.3 ms) aws.s3.key=staging/4a1c95c1e3ea46c1b51982aa45344f00
|
||||
- [worker] UPDATE (CLIENT, 2.1 ms)
|
||||
- [dispatcher] UPDATE (CLIENT, 1.3 ms)
|
||||
replay trace 6d0327f64ceb5758c4a19b30aceed617: create span links -> ['5b3ea90278cb5e18b6ad08cd32349c0e'] (original upload trace 5b3ea90278cb5e18b6ad08cd32349c0e)
|
||||
PASS: replay = new trace (root 'ops replay') with a link to the original upload; worker finished it
|
||||
4 passed, 0 failed
|
||||
Reference in New Issue
Block a user