Добавил наблюдаемость: OpenTelemetry, Prometheus, Loki, Tempo, Grafana

This commit is contained in:
gera
2026-11-19 23:10:55 +03:00
parent 470d9d6f1e
commit 4adc6c58c8
77 changed files with 8031 additions and 16 deletions
+1
View File
@@ -0,0 +1 @@
PASS: attachment validation, limits and access control
+2
View File
@@ -0,0 +1,2 @@
grafana: 3 datasources and dashboard "Messenger observability" provisioned from Git, 28 panels, 34 queries executed without errors
PASS: provisioning and dashboard queries
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 138, "failed_attempts": 0, "first_recovery_seconds": 3.483}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 138, "failed_attempts": 0, "first_recovery_seconds": 3.506}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+71
View File
@@ -0,0 +1,71 @@
{
"baseline": {
"window_seconds": 6,
"successful_requests": 2689,
"failed_attempts": 0,
"successful_rps": 448.2,
"last_error_offset_seconds": null,
"instances": [
"1dbf9e0d259e",
"638505d2d88b"
]
},
"replicas": [
{
"stopped_replica": "638505d2d88b",
"during_failure": {
"window_seconds": 15.37,
"successful_requests": 4298,
"failed_attempts": 7,
"successful_rps": 279.7,
"last_error_offset_seconds": 1.06,
"instances": [
"1dbf9e0d259e",
"638505d2d88b"
]
},
"seen_stopped_replica_after_stop": false,
"stop_command_seconds": 3.37,
"restore_seconds": 6.79,
"after_restore": {
"window_seconds": 7.0,
"successful_requests": 3123,
"failed_attempts": 0,
"successful_rps": 446.1,
"last_error_offset_seconds": null,
"instances": [
"1dbf9e0d259e",
"638505d2d88b"
]
}
},
{
"stopped_replica": "1dbf9e0d259e",
"during_failure": {
"window_seconds": 15.49,
"successful_requests": 4470,
"failed_attempts": 2,
"successful_rps": 288.5,
"last_error_offset_seconds": 1.04,
"instances": [
"1dbf9e0d259e",
"638505d2d88b"
]
},
"seen_stopped_replica_after_stop": false,
"stop_command_seconds": 3.49,
"restore_seconds": 6.8,
"after_restore": {
"window_seconds": 7.0,
"successful_requests": 3129,
"failed_attempts": 0,
"successful_rps": 447.0,
"last_error_offset_seconds": null,
"instances": [
"1dbf9e0d259e",
"638505d2d88b"
]
}
}
]
}
+7
View File
@@ -0,0 +1,7 @@
1) api crashed after COMMIT before 202/publish: attachment=8bcd0ac3-c34d-45d0-8f48-55a0283f7832 recovered by outbox relay (published rows=1) -> ready attempt=1
2) worker crashed after S3 write before COMMIT: lease expired, reaper requeued, attempt=2 ready, variants=3
3) worker crashed after COMMIT before ack: message redelivered after restart, skipped as no-op, attempt=1, variants=3
4) s3 down: transient errors retried with backoff+jitter delays_ms=[895, 1219, 3028, 5245], then failed retry_exhausted, listed in registry
replay: failed -> queued -> ready (audit rows=1); replay of ready job skipped, variants=3
5) corrupted IDAT (passes header/tail check in API): failed invalid_image on attempt 1, no retries
PASS: outbox recovery, lease recovery, redelivery after commit, backoff with jitter, retry_exhausted, replay, permanent error
+1
View File
@@ -0,0 +1 @@
PASS: 32 parallel requests, 1 message, 2 instances
+4
View File
@@ -0,0 +1,4 @@
2) database lock on messages: ApiHighErrorRate firing after 52s; 5xx ratio=0.47 only on ['/api/v1/chats/{chat_id}/messages']; p99=4.9s; pool used=0.0 acquire wait=0.01 s/s
diagnosis from stored data: error trace 17a3258b1897cd36f88418fb1adc23c5, server span 3006 ms, child "db INSERT" 2997 ms (100%) with status error, handler has no other slow child; requests: {503: 52, 201: 164}
restored: lock released, alert resolved after 40s
PASS: slow database detected by alert and diagnosed from telemetry
+5
View File
@@ -0,0 +1,5 @@
3) prometheus, loki and tempo stopped for ~80s under load: requests={201: 942, 'upload': 99}, 3/3 uploads ready, message 201, no 5xx
collector rss MiB: start=64 peak=71 during outage (limit 256, memory_limiter 160), restarts/oom=0 false
telemetry lost and counted: collector send_failed spans +2443, log records +254, metric points +456; sdk export errors=0
after restore new logs and metrics are stored again; data from the outage window is lost, data before it remains
PASS: telemetry storage outage does not affect the API and loss is bounded and counted
+4
View File
@@ -0,0 +1,4 @@
1) worker stopped: QueueLagGrowing firing after 60s; oldest job age=58s depth=57 jobs/s=0.00 worker_busy=0.0
diagnosis from stored data: trace 4710543929ec0f33fc13ce8565b5bc6a has the api server and "attachments.jobs publish" spans and no consumer span; no "job ready" worker log in Loki during the last minute (0 lines)
restored: worker started, alert resolved after 20s, backlog drained in 21s
PASS: stopped worker detected by alert and diagnosed from telemetry
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 6,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.116,
"concurrency": 4,
"successful_requests": 11666,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 387.368,
"successful_latency_ms": {
"p50": 5.802,
"p95": 44.802,
"p99": 55.465
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+5
View File
@@ -0,0 +1,5 @@
chain: request_id=77a5a56d-55b7-4fb1-9849-a4c39d03d114 trace_id=391ac5aeb8757b980131897c9b96322b spans=30 api->producer->consumer->s3/db linked, api and worker logs carry trace_id
metrics: 13 signals present, labels=['deployment_environment_name', 'http_request_method', 'http_response_status_class', 'http_route', 'instance', 'job', 'job_type', 'le', 'outcome', 'queue', 'service_version', 'state'], routes are templates (10)
secrets: message body and session token absent from Loki and Tempo
retry: one trace 9bb4fe6dc99b3dbde778e1758a85acd9 holds 6 attempts (5 failed with S3 down, attempt 6 ready after replay)
PASS: signals, producer/consumer trace chain, log correlation, retry in trace, no secrets in telemetry
+32
View File
@@ -0,0 +1,32 @@
== before
postgres 2026-11-19T19:48:24.393646212Z
valkey 2026-11-19T19:48:24.279274086Z
broker 2026-11-19T19:48:24.52160412Z
s3 2026-11-19T19:48:34.104469144Z
prometheus 2026-11-19T19:48:24.131549676Z
loki 2026-11-19T19:48:25.768218547Z
tempo 2026-11-19T19:48:25.585571452Z
otel-collector 2026-11-19T19:49:10.223513181Z
grafana 2026-11-19T19:49:10.079005478Z
api 2026-11-19T19:49:13.028782328Z
api 2026-11-19T19:49:13.082849306Z
lb 2026-11-19T19:49:10.26422772Z
janitor 2026-11-19T19:49:10.239020362Z
worker 2026-11-19T19:49:11.105495834Z
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
== after
postgres 2026-11-19T19:49:23.902795389Z
valkey 2026-11-19T19:49:23.736355641Z
broker 2026-11-19T19:49:23.770551967Z
s3 2026-11-19T19:49:33.778194628Z
prometheus 2026-11-19T19:49:23.880621282Z
loki 2026-11-19T19:49:25.646714025Z
tempo 2026-11-19T19:49:24.313008245Z
otel-collector 2026-11-19T19:50:10.305030304Z
grafana 2026-11-19T19:50:10.322614526Z
api 2026-11-19T19:50:13.127529668Z
api 2026-11-19T19:50:13.147392359Z
lb 2026-11-19T19:50:10.154157227Z
janitor 2026-11-19T19:50:10.272224264Z
worker 2026-11-19T19:50:14.68861531Z
+5
View File
@@ -0,0 +1,5 @@
accepted: attachment=e91cf4d7-c48d-43cd-9a1e-633ca1dabb90 job=ca2f9db6-c303-4663-b204-eb589ee11616 status=queued, job in stream, worker stopped
restarted broker and api: job still in stream, attachment still queued
worker started: attachment ready, attempt=1, variants=3
duplicate delivery: skipped as no-op, acked, variants=3, updated_at unchanged
PASS: worker stop, broker/api restart, redelivery idempotency
+24
View File
@@ -0,0 +1,24 @@
{
"old_replicas": [
"638505d2d88b",
"1dbf9e0d259e"
],
"new_replicas": [
"02a35d2fcbe0",
"20278f44f3e4"
],
"update_window": {
"window_seconds": 16.31,
"successful_requests": 7541,
"failed_attempts": 2,
"successful_rps": 462.3,
"last_error_offset_seconds": 12.63,
"instances": [
"02a35d2fcbe0",
"1dbf9e0d259e",
"20278f44f3e4",
"638505d2d88b"
]
},
"old_replicas_served_after_update": []
}
+1
View File
@@ -0,0 +1 @@
PASS: private bucket, limited credentials, s3 outage, orphan and staging cleanup
+1
View File
@@ -0,0 +1 @@
PASS: token revoked while valkey was stopped stays revoked after valkey restart (401)
+4
View File
@@ -0,0 +1,4 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
+2
View File
@@ -0,0 +1,2 @@
persistence: trace c23eec016505cb2f6cd5dd7d6b400c15 (30 spans), its request log and 18 metric series survived a restart of prometheus, loki and tempo
PASS: telemetry history is kept on volumes
+18
View File
@@ -0,0 +1,18 @@
{
"file_bytes": 9722608,
"concurrent_uploads": 12,
"rounds": 3,
"uploads_ok": 36,
"uploads_failed": 0,
"elapsed_seconds": 18.72,
"api_memory_limit_mib": 192,
"idle_memory_mib": {
"mtusi2026lab6-fork-api-1": 67.2,
"mtusi2026lab6-fork-api-2": 70.4
},
"peak_memory_mib": {
"mtusi2026lab6-fork-api-1": 115.8,
"mtusi2026lab6-fork-api-2": 135.4
},
"buffering_all_files_would_need_mib": 111.3
}
+1
View File
@@ -0,0 +1 @@
PASS: thumbnail/crop/optimized sizes, formats, checksums, no upscale, alpha on white, EXIF orientation, no EXIF in variants
+26
View File
@@ -0,0 +1,26 @@
{
"huge_images": {
"count": 6,
"pixels": 39942400,
"bytes": 116545
},
"small_images": 20,
"worker_concurrency": 2,
"max_processing_jobs_observed": 2,
"all_ready": true,
"accept_seconds": 0.35,
"all_ready_seconds": 13.1,
"worker_peak_rss_mib": 607.7,
"worker_memory_limit_mib": 768,
"worker_restarts_oom": [
"0",
"false"
],
"timeout_case": {
"job_timeout_seconds": 1,
"status": "failed",
"error_code": "retry_exhausted",
"attempts": 5,
"last_error": "context deadline exceeded"
}
}