forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2303 — Лазарев — на 4
Перенесена реализация lab5 (API x2 за HAProxy, PostgreSQL, SeaweedFS S3, RabbitMQ, relay outbox, worker x2, janitor) без изменения бизнес-API. Наблюдаемость: - OpenTelemetry SDK в API, relay, worker, janitor: traces, metrics, logs по OTLP/HTTP; структурные JSON-логи с trace_id/span_id - OTel Collector (memory_limiter, batch, ограниченные очереди и retry), Prometheus (метрики, alert rules), Loki (логи), Tempo (трассы), Grafana с provisioning datasources и dashboard - W3C trace context API -> outbox -> RabbitMQ -> worker (parent-child, включая retry); метрики очереди, пула БД, загрузки worker, CPU/RAM - SLI/SLO, 10 alert rules с unit-тестами promtool и runbooks - инциденты: остановка worker, блокировка БД, отказ telemetry backend; по наблюдениям исправлен простой worker в цикле AMQP (разбор x2.4)
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
{
|
||||
"scenario": "worker outage -> restart api+broker -> worker start -> ready -> redelivery",
|
||||
"date_utc": "2026-11-14T16:50:52+00:00",
|
||||
"steps": [
|
||||
{
|
||||
"t": 1.93,
|
||||
"utc": "16:50:26.742",
|
||||
"step": "worker stopped",
|
||||
"running": []
|
||||
},
|
||||
{
|
||||
"t": 2.41,
|
||||
"utc": "16:50:27.227",
|
||||
"step": "upload while worker is down",
|
||||
"http": 202,
|
||||
"attachment_id": "b2c9460c-4fd5-439b-b55e-79e633aa42f9",
|
||||
"status": "queued"
|
||||
},
|
||||
{
|
||||
"t": 2.43,
|
||||
"utc": "16:50:27.245",
|
||||
"step": "metadata and content while queued",
|
||||
"status": "queued",
|
||||
"content": 409,
|
||||
"thumbnail": 409,
|
||||
"error_code": "conflict"
|
||||
},
|
||||
{
|
||||
"t": 2.44,
|
||||
"utc": "16:50:27.254",
|
||||
"step": "messages while worker is down",
|
||||
"with_queued_attachment": true,
|
||||
"plain_message_id": "6957b7b8-7bc8-4576-85de-fd6cb473d8cf"
|
||||
},
|
||||
{
|
||||
"t": 5.36,
|
||||
"utc": "16:50:30.178",
|
||||
"step": "job is durable in broker",
|
||||
"queue": {
|
||||
"messages": 1,
|
||||
"messages_ready": 1,
|
||||
"messages_unacknowledged": 0,
|
||||
"consumers": 0
|
||||
},
|
||||
"outbox_published": true,
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"job_status": "queued"
|
||||
},
|
||||
{
|
||||
"t": 14.28,
|
||||
"utc": "16:50:39.091",
|
||||
"step": "api restarted",
|
||||
"status": "queued"
|
||||
},
|
||||
{
|
||||
"t": 19.86,
|
||||
"utc": "16:50:44.671",
|
||||
"step": "broker restarted with volume",
|
||||
"queue": {
|
||||
"messages": 1,
|
||||
"messages_ready": 1,
|
||||
"messages_unacknowledged": 0,
|
||||
"consumers": 0
|
||||
},
|
||||
"status": "queued"
|
||||
},
|
||||
{
|
||||
"t": 25.71,
|
||||
"utc": "16:50:50.521",
|
||||
"step": "worker started"
|
||||
},
|
||||
{
|
||||
"t": 25.75,
|
||||
"utc": "16:50:50.564",
|
||||
"step": "ready after worker start",
|
||||
"variants": [
|
||||
[
|
||||
"thumbnail",
|
||||
256,
|
||||
160
|
||||
],
|
||||
[
|
||||
"crop",
|
||||
128,
|
||||
128
|
||||
],
|
||||
[
|
||||
"optimized",
|
||||
320,
|
||||
200
|
||||
]
|
||||
],
|
||||
"original_sha256_ok": true,
|
||||
"thumbnail_bytes": 4679
|
||||
},
|
||||
{
|
||||
"t": 27.52,
|
||||
"utc": "16:50:52.334",
|
||||
"step": "redelivery of the same job is a no-op",
|
||||
"events": [
|
||||
"enqueued",
|
||||
"claimed",
|
||||
"ready",
|
||||
"staging_deleted",
|
||||
"duplicate_ignored"
|
||||
],
|
||||
"invariants": {
|
||||
"variants": [
|
||||
"crop",
|
||||
"optimized",
|
||||
"thumbnail"
|
||||
],
|
||||
"variants_ok": true,
|
||||
"final_objects": 4,
|
||||
"final_objects_ok": true,
|
||||
"staging_left": false,
|
||||
"job_status": "ready",
|
||||
"attempt": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"attachment_id": "b2c9460c-4fd5-439b-b55e-79e633aa42f9",
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"events": [
|
||||
{
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"at": "2026-11-14T16:50:27.224351Z",
|
||||
"event": "enqueued",
|
||||
"attempt": 1,
|
||||
"actor": "api",
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"at": "2026-11-14T16:50:45.408651Z",
|
||||
"event": "claimed",
|
||||
"attempt": 1,
|
||||
"actor": "ff3fb8ef2677:04bb51bc",
|
||||
"detail": {
|
||||
"redelivered_message_attempt": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"at": "2026-11-14T16:50:45.550305Z",
|
||||
"event": "ready",
|
||||
"attempt": 1,
|
||||
"actor": "ff3fb8ef2677:04bb51bc",
|
||||
"detail": {
|
||||
"variants": {
|
||||
"crop": [
|
||||
128,
|
||||
128
|
||||
],
|
||||
"optimized": [
|
||||
320,
|
||||
200
|
||||
],
|
||||
"thumbnail": [
|
||||
256,
|
||||
160
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"at": "2026-11-14T16:50:45.552053Z",
|
||||
"event": "staging_deleted",
|
||||
"attempt": 1,
|
||||
"actor": "ff3fb8ef2677:04bb51bc",
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"job_id": "9a8648c5-8064-40ae-8f9d-f9b3208e4887",
|
||||
"at": "2026-11-14T16:50:51.314454Z",
|
||||
"event": "duplicate_ignored",
|
||||
"attempt": 1,
|
||||
"actor": "ff3fb8ef2677:04bb51bc",
|
||||
"detail": {
|
||||
"status": "ready"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user