Skip to content

Commit

Permalink
haproxy json, add another form of request time
Browse files Browse the repository at this point in the history
  • Loading branch information
bentol committed Nov 18, 2021
1 parent 9cfec76 commit 7ed9120
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions parser/haproxyjsonparser/haproxyjsonparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ func (j *HaproxyJsonParser) ParseString(line string) (map[string]string, error)
// convert to second format
result["upstream_response_time"] = fmt.Sprintf("%.3f", float64(intUpstreamTime)/1000)
result["request_time"] = fmt.Sprintf("%.3f", float64(intRequestTime)/1000)
} else if v, ok := parsed["Tw/Tc/Tr"]; ok {
timeSplit := strings.Split(v, "/")
if len(timeSplit) != 3 {
return nil, errors.New("Error parse request time")
}
intRequestTime, err := strconv.Atoi(timeSplit[2])
if err != nil {
return nil, errors.New("Error parse request time")
}
// convert to second format
result["request_time"] = fmt.Sprintf("%.3f", float64(intRequestTime)/1000)
} else {
return nil, errors.New("Error parse request time")
}
Expand Down

0 comments on commit 7ed9120

Please sign in to comment.