add ready and healthy probe endpoints

This commit is contained in:
Markus Muellner authored and Benj Fassbind committed 2022-12-12 13:39:07 +01:00
1 parent 352f4e8772
commit 2020ca9971
8 files changed
+163 -46

No files matched your search

+8 -5
View File
@@ -2,6 +2,7 @@ package api
import (
"net/http"
"sync/atomic"
ctx "github.com/aptly-dev/aptly/context"
"github.com/gin-gonic/gin"
@@ -25,11 +26,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
router.Use(gin.ErrorLogger())
if c.Config().EnableMetricsEndpoint {
router.Use(instrumentHandlerInFlight(apiRequestsInFlightGauge, getBasePath))
router.Use(instrumentHandlerCounter(apiRequestsTotalCounter, getBasePath))
router.Use(instrumentHandlerRequestSize(apiRequestSizeSummary, getBasePath))
router.Use(instrumentHandlerResponseSize(apiResponseSizeSummary, getBasePath))
router.Use(instrumentHandlerDuration(apiRequestsDurationSummary, getBasePath))
MetricsCollectorRegistrar.Register(router)
}
if context.Flags().Lookup("no-lock").Value.Get().(bool) {
@@ -71,6 +68,12 @@ func Router(c *ctx.AptlyContext) http.Handler {
root.GET("/metrics", apiMetricsGet())
}
root.GET("/version", apiVersion)
isReady := &atomic.Value{}
isReady.Store(false)
defer isReady.Store(true)
root.GET("/ready", apiReady(isReady))
root.GET("/healthy", apiHealthy)
}
{