| 1234567891011121314151617181920212223242526272829303132 |
- package apiutil
- import (
- "net/http"
- "net/http/pprof"
- "github.com/julienschmidt/httprouter"
- "github.com/opencost/opencost/core/pkg/env"
- )
- func ApplyContainerDiagnosticEndpoints(router *httprouter.Router) {
- router.HandlerFunc("GET", "/healthz", healthz)
- router.GET("/logs/level", GetLogLevel)
- router.POST("/logs/level", SetLogLevel)
- if env.IsPProfEnabled() {
- router.HandlerFunc(http.MethodGet, "/debug/pprof/", pprof.Index)
- router.HandlerFunc(http.MethodGet, "/debug/pprof/cmdline", pprof.Cmdline)
- router.HandlerFunc(http.MethodGet, "/debug/pprof/profile", pprof.Profile)
- router.HandlerFunc(http.MethodGet, "/debug/pprof/symbol", pprof.Symbol)
- router.HandlerFunc(http.MethodGet, "/debug/pprof/trace", pprof.Trace)
- router.Handler(http.MethodGet, "/debug/pprof/goroutine", pprof.Handler("goroutine"))
- router.Handler(http.MethodGet, "/debug/pprof/heap", pprof.Handler("heap"))
- }
- }
- func healthz(w http.ResponseWriter, _ *http.Request) {
- w.WriteHeader(200)
- w.Header().Set("Content-Length", "0")
- w.Header().Set("Content-Type", "text/plain")
- }
|