Instrument durable messenger with OTel, provision Grafana and prove SLO incident detection

This commit is contained in:
2026-11-21 00:58:18 +03:00
parent 470d9d6f1e
commit bd2c7f7b37
89 changed files with 15839 additions and 25 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
"""Prove the SLI also observes a 503 generated by HAProxy, outside API SDKs."""
import json,time,urllib.request,urllib.error
from observability import ROOT,BASE,Client,check,dc,scalar,wait_for
c=Client(BASE);a,b,e,chat=c.bootstrap();before=scalar('sum(haproxy_backend_http_responses_total{proxy="replicas",code="5xx"})') or 0
try:
dc('stop','api');time.sleep(2)
req=urllib.request.Request(BASE+'/api/v1/users/me',headers={'Authorization':'Bearer '+a['token']})
try:response=urllib.request.urlopen(req,timeout=4)
except urllib.error.HTTPError as error:response=error
with response:check(response.code==503,'expected LB 503');status=response.code
after,delay=wait_for(lambda: (lambda n:n if n is not None and n>before else None)(scalar('sum(haproxy_backend_http_responses_total{proxy="replicas",code="5xx"})')),15)
result={'client_status':status,'api_processes_stopped':True,'ingress_5xx_before':before,'ingress_5xx_after':after,'observation_seconds':delay,'lb_generated_error_counted':True}
(ROOT/'evidence/ingress-guard.json').write_text(json.dumps(result,indent=2)+'\n');print('PASS: LB-generated 503 included in business ingress SLI')
finally:dc('up','-d','--no-deps','--wait','api')
c.call('GET','/api/v1/users/me',actor=a,schema='User')