cloudapi: record error metrics

Hook up the compose error metric for
the prometheus alerts and grafana dashboard.
This commit is contained in:
Gianluca Zuccarelli 2021-10-29 13:19:43 +01:00 committed by Tom Gundersen
parent f8199ec41d
commit 297a60d238

View file

@ -3,8 +3,10 @@ package v2
import (
"fmt"
"net/http"
"strings"
"github.com/labstack/echo/v4"
"github.com/osbuild/osbuild-composer/internal/prometheus"
)
const (
@ -249,6 +251,12 @@ func (s *Server) HTTPErrorHandler(echoError error, c echo.Context) {
return
}
if he.Code == http.StatusInternalServerError {
if strings.HasSuffix(c.Path(), "/compose") {
prometheus.ComposeFailures.Inc()
}
}
sec, ok := he.Message.(ServiceErrorCode)
if !ok {
// No service code was set, so Echo threw this error