Include response time in PodResult

Signed-off-by: tfinethy <tfinethy@cogolabs.com>

Remove all swagger updates

Change response-time to match status-code formatting

Switch to float64 and use milliseconds as the unit
This commit is contained in:
tfinethy
2019-02-17 12:38:53 -05:00
committed by Tyler Finethy
parent d483117a28
commit 871b86471d
4 changed files with 19 additions and 3 deletions
+5 -3
View File
@@ -65,12 +65,14 @@ func PingAllPods(pods map[string]string) models.CheckResults {
CountCall("made", "ping")
timer := GetLabeledPeersCallsTimer("ping", hostIP, podIP)
start := time.Now()
resp, err := getClient(pickPodHostIP(podIP, hostIP)).Operations.Ping(nil)
channelResult.hostIPv4.UnmarshalText([]byte(hostIP))
var OK = (err == nil)
if OK {
channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Response: resp.Payload, StatusCode: 200}
responseTime := float64(time.Since(start).Nanoseconds()) / float64(int64(time.Millisecond))
channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Response: resp.Payload, StatusCode: 200, ResponseTime: responseTime}
timer.ObserveDuration()
} else {
channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Error: err.Error(), StatusCode: 500}
@@ -167,8 +169,8 @@ func HealthCheck() *models.HealthCheckResults {
ok := true
start := time.Now()
result := models.HealthCheckResults{
OK: &ok,
DurationNs: time.Since(start).Nanoseconds(),
OK: &ok,
DurationNs: time.Since(start).Nanoseconds(),
GeneratedAt: strfmt.DateTime(start),
}
return &result
+3
View File
@@ -30,6 +30,9 @@ type PodResult struct {
// response
Response *PingResults `json:"response,omitempty"`
// response time
ResponseTime float64 `json:"response-time,omitempty"`
// status code
StatusCode int32 `json:"status-code,omitempty"`
}
+8
View File
@@ -227,6 +227,10 @@ func init() {
"response": {
"$ref": "#/definitions/PingResults"
},
"response-time": {
"type": "number",
"format": "float64"
},
"status-code": {
"type": "integer",
"format": "int32"
@@ -445,6 +449,10 @@ func init() {
"response": {
"$ref": "#/definitions/PingResults"
},
"response-time": {
"type": "number",
"format": "float64"
},
"status-code": {
"type": "integer",
"format": "int32"
+3
View File
@@ -36,6 +36,9 @@ definitions:
status-code:
type: integer
format: int32
response-time:
type: number
format: float64
CheckResults:
type: object
additionalProperties: