forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# Follow one controlled upload through API, broker, worker and all telemetry stores.
|
||||
set -eu
|
||||
: "${BASE_URL:?}" "${PROBE_WORK:?}" "${TEMPO_URL:?}" "${LOKI_URL:?}"
|
||||
mkdir -p evidence/current
|
||||
trace=$(openssl rand -hex 16)
|
||||
parent=$(openssl rand -hex 8)
|
||||
chat=$(cat "$PROBE_WORK/chat-id")
|
||||
curl -fsS --config "$PROBE_WORK/auth.conf" "$BASE_URL/api/v1/chats/$chat/attachments?filename=sample.png" -H 'Content-Type: image/png' -H "traceparent: 00-$trace-$parent-01" --data-binary @tests/fixtures/sample.png > "$PROBE_WORK/attachment.json"
|
||||
id=$(jq -r .id "$PROBE_WORK/attachment.json")
|
||||
ready=false
|
||||
for attempt in $(seq 1 60); do
|
||||
curl -fsS --config "$PROBE_WORK/auth.conf" "$BASE_URL/api/v1/attachments/$id" > "$PROBE_WORK/status.json"
|
||||
if jq -e '.status=="ready"' "$PROBE_WORK/status.json" >/dev/null; then ready=true;break;fi
|
||||
sleep 1
|
||||
done
|
||||
$ready
|
||||
jq -n --arg trace "$trace" --arg attachment "$id" '{trace_id:$trace,attachment_id:$attachment,ready:true}' > evidence/current/correlation.json
|
||||
# Batch exporters flush asynchronously; query boundedly until the worker span is indexed.
|
||||
found=false
|
||||
for attempt in $(seq 1 30); do
|
||||
curl -fsS -H 'Accept: application/json' "$TEMPO_URL/api/traces/$trace" > evidence/current/correlated-trace.json || true
|
||||
if jq -e '..|objects|select(.name?=="attachment.process")' evidence/current/correlated-trace.json >/dev/null 2>&1; then found=true;break;fi
|
||||
sleep 1
|
||||
done
|
||||
$found
|
||||
curl -fsS --get "$LOKI_URL/loki/api/v1/query_range" --data-urlencode "query={service_name=~\"messenger-api|messenger-worker\"} | trace_id=\"$trace\"" --data-urlencode 'limit=100' > evidence/current/correlated-logs.json
|
||||
jq -e '.data.result|length>0' evidence/current/correlated-logs.json >/dev/null
|
||||
printf 'PASS: upload and worker share trace %s; correlated structured logs found\n' "$trace"
|
||||
Reference in New Issue
Block a user