Add HTTP status code to histogram

The histogram for gateway_functions_seconds excluded the status
code that gives important information for setting up SLOs.

Fixes: #1725

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2022-06-01 09:33:36 +01:00
committed by Alex Ellis
parent 96cfdee085
commit cc2f38938e
7 changed files with 25 additions and 85 deletions

View File

@ -56,16 +56,17 @@ func (p PrometheusFunctionNotifier) Notify(method string, URL string, originalUR
}
}
code := strconv.Itoa(statusCode)
labels := prometheus.Labels{"function_name": serviceName, "code": code}
if event == "completed" {
seconds := duration.Seconds()
p.Metrics.GatewayFunctionsHistogram.
WithLabelValues(serviceName).
With(labels).
Observe(seconds)
code := strconv.Itoa(statusCode)
p.Metrics.GatewayFunctionInvocation.
With(prometheus.Labels{"function_name": serviceName, "code": code}).
With(labels).
Inc()
} else if event == "started" {
p.Metrics.GatewayFunctionInvocationStarted.WithLabelValues(serviceName).Inc()