feat: status pages with custom domains, tls, themes and export (M7) #55
No files matched your search
@@ -98,7 +98,7 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
}
|
||||
names := map[uuid.UUID]string{}
|
||||
worst := agentapi.PageOperational
|
||||
allUnknown := true
|
||||
allUnknown, allDown := true, len(listed) > 0
|
||||
for _, m := range listed {
|
||||
name := m.Label
|
||||
if name == "" {
|
||||
@@ -119,6 +119,9 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
if comp.Status != agentapi.PageUnknown {
|
||||
allUnknown = false
|
||||
}
|
||||
if comp.Status != agentapi.PageOutage {
|
||||
allDown = false
|
||||
}
|
||||
worst = worse(worst, comp.Status)
|
||||
if n := len(snap.Sections); n == 0 || snap.Sections[n-1].Name != m.Section {
|
||||
snap.Sections = append(snap.Sections, agentapi.Section{Name: m.Section})
|
||||
@@ -126,9 +129,14 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
last := &snap.Sections[len(snap.Sections)-1]
|
||||
last.Components = append(last.Components, comp)
|
||||
}
|
||||
// A single failed component is a partial problem; only a complete
|
||||
// failure is reported as an outage of the whole page.
|
||||
snap.Status = worst
|
||||
if allUnknown {
|
||||
switch {
|
||||
case allUnknown:
|
||||
snap.Status = agentapi.PageUnknown
|
||||
case worst == agentapi.PageOutage && !allDown:
|
||||
snap.Status = agentapi.PageDegraded
|
||||
}
|
||||
for _, i := range incidents {
|
||||
snap.Incidents = append(snap.Incidents, agentapi.PageIncident{Component: names[i.MonitorID], StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt})
|
||||
|
||||
@@ -91,8 +91,9 @@ func TestStatusPages(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Page() failed: %v", err)
|
||||
}
|
||||
if snap.Status != agentapi.PageOutage || len(snap.Sections) != 2 || snap.Sections[1].Components[0].Name != "Public API" {
|
||||
t.Errorf("snapshot = %+v, want outage with Frontend and Backend sections", snap)
|
||||
if snap.Status != agentapi.PageDegraded || len(snap.Sections) != 2 || snap.Sections[1].Components[0].Status != agentapi.PageOutage ||
|
||||
snap.Sections[1].Components[0].Name != "Public API" {
|
||||
t.Errorf("snapshot = %+v, want degraded page with the Public API in outage", snap)
|
||||
}
|
||||
raw, _ := json.Marshal(snap)
|
||||
for _, secret := range []string{up.URL, down.URL, "unexpected status"} {
|
||||
|
||||
Reference in new issue
Block a user