add ready and healthy probe endpoints

This commit is contained in:
Markus Muellner
2022-07-01 10:24:23 +02:00
committed by Benj Fassbind
parent 352f4e8772
commit 2020ca9971
8 changed files with 163 additions and 46 deletions
+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)
}
{