mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-08-23 21:36:25 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -36,6 +36,9 @@ definitions:
|
||||
status-code:
|
||||
type: integer
|
||||
format: int32
|
||||
response-time:
|
||||
type: number
|
||||
format: float64
|
||||
CheckResults:
|
||||
type: object
|
||||
additionalProperties:
|
||||
|
||||
Reference in New Issue
Block a user