Count visible incidents from a fixed severity queue and selected threshold.

severity threshold A queue report can stay deterministic by keeping severities in a local slice and deriving counts from a selected threshold.

Incident Queue Reliability Report

minSeverity
incident_queue_reliability_report.go
Replay: real traced execution (multi-file project)
package main

import "fmt"

func main() {
	var minSeverity = 2
	severities := []int{1, 2, 3, 3}
	visible := 0
	high := 0

	for _, severity := range severities {
		if severity >= minSeverity {
			visible++
		}
		if severity >= 3 {
			high++
		}
	}

	fmt.Printf("min=%d visible=%d high=%d\n", minSeverity, visible, high)
}
package main

import "fmt"

func main() {
	var minSeverity = 1
	severities := []int{1, 2, 3, 3}
	visible := 0
	high := 0

	for _, severity := range severities {
		if severity >= minSeverity {
			visible++
		}
		if severity >= 3 {
			high++
		}
	}

	fmt.Printf("min=%d visible=%d high=%d\n", minSeverity, visible, high)
}
package main

import "fmt"

func main() {
	var minSeverity = 3
	severities := []int{1, 2, 3, 3}
	visible := 0
	high := 0

	for _, severity := range severities {
		if severity >= minSeverity {
			visible++
		}
		if severity >= 3 {
			high++
		}
	}

	fmt.Printf("min=%d visible=%d high=%d\n", minSeverity, visible, high)
}
  1. minSeverity ← 2, severities ← []int{1, 2, 3, 3}, visible ← 0, high ← 0

    5func main() {6  var minSeverity→ 2 = 2 //@minSeverity=1, 37  severities→ []int{1, 2, 3, 3} := []int{1, 2, 3, 3}8  visible→ 0 := 09  high→ 0 := 0
  2. for _, severity := range severities

    pass 1 of 4
    11for _, severity1 := range severities[]int{1, 2, 3, 3} {12  if severity >= minSeverity {
    All 4 passes — pass 1 is the card above
    passseverityhigh
    11
    22
    330 1
    431 2
  3. visible ← 1

    pass 1 of 3
    11for _, severity := range severities {12  if severity2 >= minSeverity2 {13    visible→ 1++14  }
    All 3 passes — pass 1 is the card above
    passseverityvisiblehigh
    120 1
    231 20 1
    332 31 2
  4. high ← 1

    pass 1 of 2
    14}15if severity3 >= 3 {16  high→ 1++17}
  5. high ← 2

    pass 2 of 2
    14}15if severity3 >= 3 {16  high→ 2++17}
  6. fmt.Printf("min=%d visible=%d high=%d ", minSeverity, visible, high)

    20  fmt.Printf("min=%d visible=%d high=%d\n", minSeverity2, visible3, high2)21}
    outputmin=2 visible=3 high=2
  1. minSeverity ← 1, severities ← []int{1, 2, 3, 3}, visible ← 0, high ← 0

    5func main() {6  var minSeverity→ 1 = 17  severities→ []int{1, 2, 3, 3} := []int{1, 2, 3, 3}8  visible→ 0 := 09  high→ 0 := 0
  2. for _, severity := range severities

    pass 1 of 4
    11for _, severity1 := range severities[]int{1, 2, 3, 3} {12  if severity >= minSeverity {
    All 4 passes — pass 1 is the card above
    passseverityhigh
    11
    22
    330 1
    431 2
  3. visible ← 1

    pass 1 of 4
    11for _, severity := range severities {12  if severity1 >= minSeverity1 {13    visible→ 1++14  }
    All 4 passes — pass 1 is the card above
    passseverityvisiblehigh
    110 1
    221 2
    332 30 1
    433 41 2
  4. high ← 1

    pass 1 of 2
    14}15if severity3 >= 3 {16  high→ 1++17}
  5. high ← 2

    pass 2 of 2
    14}15if severity3 >= 3 {16  high→ 2++17}
  6. fmt.Printf("min=%d visible=%d high=%d ", minSeverity, visible, high)

    20  fmt.Printf("min=%d visible=%d high=%d\n", minSeverity1, visible4, high2)21}
    outputmin=1 visible=4 high=2
  1. minSeverity ← 3, severities ← []int{1, 2, 3, 3}, visible ← 0, high ← 0

    5func main() {6  var minSeverity→ 3 = 37  severities→ []int{1, 2, 3, 3} := []int{1, 2, 3, 3}8  visible→ 0 := 09  high→ 0 := 0
  2. for _, severity := range severities

    pass 1 of 4
    11for _, severity1 := range severities[]int{1, 2, 3, 3} {12  if severity >= minSeverity {
    All 4 passes — pass 1 is the card above
    passseverityminSeverityvisiblehigh
    11
    22
    3330 10 1
    4331 21 2
  3. visible ← 1

    pass 1 of 2
    11for _, severity := range severities {12  if severity3 >= minSeverity3 {13    visible→ 1++14  }
  4. high ← 1

    pass 1 of 2
    14}15if severity3 >= 3 {16  high→ 1++17}
  5. visible ← 2

    pass 2 of 2
    11for _, severity := range severities {12  if severity3 >= minSeverity3 {13    visible→ 2++14  }
  6. high ← 2

    pass 2 of 2
    14}15if severity3 >= 3 {16  high→ 2++17}
  7. fmt.Printf("min=%d visible=%d high=%d ", minSeverity, visible, high)

    20  fmt.Printf("min=%d visible=%d high=%d\n", minSeverity3, visible2, high2)21}
    outputmin=3 visible=2 high=2