conclude takes the data in result from the attempts and computes remaining values needed to fill out the result. It detects degraded (high-latency) responses and makes the conclusion about the result's status.
(result types.Result)
| 134 | // It detects degraded (high-latency) responses and makes |
| 135 | // the conclusion about the result's status. |
| 136 | func (c Checker) conclude(result types.Result) types.Result { |
| 137 | result.ThresholdRTT = c.ThresholdRTT |
| 138 | |
| 139 | warning := c.Raise == "warn" || c.Raise == "warning" |
| 140 | |
| 141 | // Check errors (down) |
| 142 | for i := range result.Times { |
| 143 | if result.Times[i].Error != "" { |
| 144 | if warning { |
| 145 | result.Notice = result.Times[i].Error |
| 146 | result.Degraded = true |
| 147 | return result |
| 148 | } |
| 149 | result.Down = true |
| 150 | return result |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // Check round trip time (degraded) |
| 155 | if c.ThresholdRTT > 0 { |
| 156 | stats := result.ComputeStats() |
| 157 | if stats.Median > c.ThresholdRTT { |
| 158 | result.Notice = fmt.Sprintf("median round trip time exceeded threshold (%s)", c.ThresholdRTT) |
| 159 | result.Degraded = true |
| 160 | return result |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | result.Healthy = true |
| 165 | return result |
| 166 | } |
| 167 | |
| 168 | // checkDown checks whether the endpoint is down based on resp and |
| 169 | // the configuration of c. It returns a non-nil error if down. |