rpc: a bit less metrics allocations (#8084)

This commit is contained in:
Alex Sharov 2023-08-26 11:20:08 +07:00 committed by GitHub
parent f5cc67fe5b
commit ddf608f866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,10 +28,8 @@ var (
)
func newRPCServingTimerMS(method string, valid bool) *metrics.Summary {
flag := "success"
if !valid {
flag = "failure"
if valid {
return metrics.GetOrCreateSummary(fmt.Sprintf(`rpc_duration_seconds{method="%s",success="success"}`, method))
}
m := fmt.Sprintf(`rpc_duration_seconds{method="%s",success="%s"}`, method, flag)
return metrics.GetOrCreateSummary(m)
return metrics.GetOrCreateSummary(fmt.Sprintf(`rpc_duration_seconds{method="%s",success="failure"}`, method))
}