feat: provide metrics endpoint (#3902)

* feat: provide metrics endpoint

* config

* enable otel metrics by default

Co-authored-by: Florian Forster <florian@caos.ch>
This commit is contained in:
Livio Spring
2022-07-18 10:42:32 +02:00
committed by GitHub
parent 7ef9dcbf50
commit 9b6dad18cb
9 changed files with 72 additions and 59 deletions

View File

@@ -17,6 +17,7 @@ import (
http_util "github.com/zitadel/zitadel/internal/api/http"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/internal/telemetry/metrics"
"github.com/zitadel/zitadel/internal/telemetry/tracing"
)
@@ -132,6 +133,7 @@ func (a *API) healthHandler() http.Handler {
handler.HandleFunc("/healthz", handleHealth)
handler.HandleFunc("/ready", handleReadiness(checks))
handler.HandleFunc("/validate", handleValidate(checks))
handler.Handle("/metrics", metricsExporter())
return handler
}
@@ -175,3 +177,11 @@ func validate(ctx context.Context, validations []ValidationFunction) []error {
}
return errs
}
func metricsExporter() http.Handler {
exporter := metrics.GetExporter()
if exporter == nil {
return http.NotFoundHandler()
}
return exporter
}