Files
mtusi2026lab5/evidence/worker/logs.md
T
ricoromaandClaude Opus 5.5 acc6584dd3 docs: record async-attachments evidence and report
Evidence taken on ff1a83b. The report covers level 3; levels 4 and 5 are
closed by the following changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 08:30:46 +03:00

65 lines
6.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Журнал worker
- Что сделано: на рабочем стенде разовая проба — синтетические пользователи и чат; `tests/fixtures/sample.png` с `filename` вида `logsprobe-<метка>-ready.png` (становится `ready`), JPEG с точностью 12 бит из `student-tests/images.py` с `filename` `logsprobe-<метка>-failed.jpg` (становится `failed`), сообщение не по схеме `{"schema_version": 99, "probe": true}` в рабочую очередь (через клиент брокера в контейнере API, без печати пароля). Затем чтение `docker compose logs --no-log-prefix worker` и `… api`, отбор по `attachment_id` и `request_id`
- Дата: 2026-10-31, 03:59 UTC
- Commit: `ff1a83b`, рабочее дерево без правок кода (на момент прогона добавлены только файлы `evidence/`)
- Стенд: проект compose `mtusi-lab5`, собран `make run_docker` из `HEAD`
- Спек: `service-logging`, «Журнал worker»
- Итог: у записей одного задания общий `request_id` (равен `job_id`), он же связывает их с записью API через `job_id`; `filename` и тело сообщения в журнале нет — метка `filename` и строка `"probe"` встречаются 0 раз; запись `error` о сообщении не по схеме содержит только размер
## Вложения
```text
ready e94eaf4e-66d7-4404-b285-9883ea45297b ready None 1
failed 90c41ac3-85e8-4a6e-9e29-093b5dbe2837 failed invalid_image 0
```
## Готовое вложение: записи worker (`request_id` = `job_id`)
```json
{"request_id": "972aaa67-933d-4715-b788-5ccd0bdb712e", "event": "Started job attempt", "instance_id": "f5a34a124c60", "module": "attachment_processing_service", "job_id": "972aaa67-933d-4715-b788-5ccd0bdb712e", "attachment_id": "e94eaf4e-66d7-4404-b285-9883ea45297b", "attempt": 1, "redelivered": false, "level": "info", "timestamp": "2026-10-31T03:59:26.257758Z", "filename": "attachment_processing.py", "lineno": 137, "func_name": "_run"}
{"request_id": "972aaa67-933d-4715-b788-5ccd0bdb712e", "event": "Attachment became ready", "instance_id": "f5a34a124c60", "module": "attachment_processing_service", "job_id": "972aaa67-933d-4715-b788-5ccd0bdb712e", "attachment_id": "e94eaf4e-66d7-4404-b285-9883ea45297b", "attempt": 1, "variant_width": 256, "variant_height": 160, "variant_size_bytes": 5813, "duration_ms": 14, "level": "info", "timestamp": "2026-10-31T03:59:26.271628Z", "filename": "attachment_processing.py", "lineno": 176, "func_name": "_run"}
```
Поле `filename` этих записей — имя файла исходного кода из `structlog`, а не имя вложения.
## `failed`: записи worker
```json
{"request_id": "70c02c1b-9358-4634-9282-bc07ddca7857", "event": "Started job attempt", "instance_id": "f5a34a124c60", "module": "attachment_processing_service", "job_id": "70c02c1b-9358-4634-9282-bc07ddca7857", "attachment_id": "90c41ac3-85e8-4a6e-9e29-093b5dbe2837", "attempt": 1, "redelivered": false, "level": "info", "timestamp": "2026-10-31T03:59:26.574266Z", "filename": "attachment_processing.py", "lineno": 137, "func_name": "_run"}
{"request_id": "70c02c1b-9358-4634-9282-bc07ddca7857", "event": "Attachment failed", "instance_id": "f5a34a124c60", "module": "attachment_processing_service", "job_id": "70c02c1b-9358-4634-9282-bc07ddca7857", "attachment_id": "90c41ac3-85e8-4a6e-9e29-093b5dbe2837", "attempt": 1, "error_code": "invalid_image", "reason": "undecodable", "level": "warning", "timestamp": "2026-10-31T03:59:26.581909Z", "filename": "attachment_processing.py", "lineno": 504, "func_name": "_fail"}
```
## Записи API о тех же загрузках
```json
{"request_id": "355f1e3c54d34c22a147f699f766269c", "event": "Uploaded attachment", "user_id": "a138b02d-ac2f-456d-8f3b-7f580e041fe5", "instance_id": "f83660c720d2", "module": "attachment_service", "method": "upload", "chat_id": "99cf13c0-7aae-46ff-93a3-495ec6dfc3ce", "filename_length": 30, "attachment_id": "e94eaf4e-66d7-4404-b285-9883ea45297b", "job_id": "972aaa67-933d-4715-b788-5ccd0bdb712e", "size_bytes": 111817, "content_type": "<ImageType.PNG: 'image/png'>", "width": 320, "height": 200, "waited_ms": 0, "duration_ms": 15, "level": "info", "timestamp": "2026-10-31T03:59:26.254821Z", "filename": "attachment.py", "func_name": "_store", "lineno": 272}
{"request_id": "62af8277c7d04340b195422e48cca6bc", "event": "Uploaded attachment", "user_id": "a138b02d-ac2f-456d-8f3b-7f580e041fe5", "instance_id": "3ce76b35e8aa", "module": "attachment_service", "method": "upload", "chat_id": "99cf13c0-7aae-46ff-93a3-495ec6dfc3ce", "filename_length": 31, "attachment_id": "90c41ac3-85e8-4a6e-9e29-093b5dbe2837", "job_id": "70c02c1b-9358-4634-9282-bc07ddca7857", "size_bytes": 1500, "content_type": "<ImageType.JPEG: 'image/jpeg'>", "width": 64, "height": 48, "waited_ms": 0, "duration_ms": 41, "level": "info", "timestamp": "2026-10-31T03:59:26.574754Z", "lineno": 272, "func_name": "_store", "filename": "attachment.py"}
```
## Сообщение не по схеме
```json
{"event": "Dropped malformed job message", "instance_id": "f5a34a124c60", "module": "attachment_processing_service", "size_bytes": 37, "level": "error", "timestamp": "2026-10-31T03:59:27.337780Z", "filename": "attachment_processing.py", "lineno": 100, "func_name": "handle"}
```
## Записи `error` библиотеки клиента при рестартах брокера
Рестарты — предыдущие прогоны `driver.py` на этом стенде. Логгер `aiormq.connection` пишет адрес с замаскированным паролем (`******`):
```json
{"event": "Unexpected connection close from remote \"amqp://messenger:******@rabbitmq:5672//\", Connection.Close(reply_code=320, reply_text=\"CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'\")", "instance_id": "f5a34a124c60", "level": "error", "logger": "aiormq.connection", "timestamp": "2026-10-31T03:55:34.347950Z"}
{"event": "error when creating transport: <AMQPConnectionError: (111, \"Connect call failed ('172.31.0.4', 5672)\")>", "instance_id": "f5a34a124c60", "level": "error", "logger": "aiormq.connection", "timestamp": "2026-10-31T03:55:36.351206Z"}
```
## Подсчёт
```text
publish malformed exit 0
filename mark in worker log: 0
filename mark in api log: 0
probe body in worker log: 0
```
Значения секретов из `.env` в этом файле проверены поиском (`evidence/tests/secrets.md`).