forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/observation"
|
||||
)
|
||||
|
||||
// Snapshot observes current-version backlog and local pool occupancy under a short deadline.
|
||||
func (s *Store) Snapshot(ctx context.Context) (observation.Snapshot, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 250*time.Millisecond)
|
||||
defer cancel()
|
||||
result := observation.Snapshot{PoolUsed: int64(s.pool.Stat().AcquiredConns())}
|
||||
err := s.pool.QueryRow(ctx, `SELECT count(*),COALESCE(EXTRACT(EPOCH FROM clock_timestamp()-min(j.created_at)),0)::double precision FROM attachment_jobs j JOIN attachments a ON a.id=j.attachment_id AND a.pipeline_version=j.pipeline_version WHERE j.status IN ('queued','processing')`).Scan(&result.QueueDepth, &result.OldestSeconds)
|
||||
return result, normalize(err)
|
||||
}
|
||||
Reference in New Issue
Block a user