mirror of https://github.com/harness/drone.git
add http prometheus metrics (#3432)
This will add metrics to http endpoints to measure latency and to see if other parts of infra are working This will close #2421 Signed-off-by: Max Knee <max.knee@nytimes.com>pull/3447/head
parent
915212145f
commit
3c37646f3a
|
@ -17,6 +17,7 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/drone/drone/cmd/drone-server/config"
|
||||
"github.com/drone/drone/core"
|
||||
"github.com/drone/drone/handler/api"
|
||||
|
@ -61,6 +62,8 @@ var serverSet = wire.NewSet(
|
|||
// router that is serves the provided handlers.
|
||||
func provideRouter(api api.Server, web web.Server, rpcv1 rpcHandlerV1, rpcv2 rpcHandlerV2, healthz healthzHandler, metrics *metric.Server, pprof pprofHandler) *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
m := chiprometheus.NewMiddleware("server")
|
||||
r.Use(m)
|
||||
r.Mount("/healthz", healthz)
|
||||
r.Mount("/metrics", metrics)
|
||||
r.Mount("/api", api.Handler())
|
||||
|
|
1
go.mod
1
go.mod
|
@ -3,6 +3,7 @@ module github.com/drone/drone
|
|||
replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.20200309214505-aa6a9891b09c+incompatible
|
||||
|
||||
require (
|
||||
github.com/766b/chi-prometheus v0.0.0-20211217152057-87afa9aa2ca8
|
||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e
|
||||
github.com/Azure/azure-storage-blob-go v0.7.0
|
||||
github.com/Azure/go-autorest/autorest/adal v0.8.3 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,5 +1,7 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
docker.io/go-docker v1.0.0/go.mod h1:7tiAn5a0LFmjbPDbyTPOaTTOuG1ZRNXdPA6RvKY+fpY=
|
||||
github.com/766b/chi-prometheus v0.0.0-20211217152057-87afa9aa2ca8 h1:hK1G69lDhhrGqJbRA5i1rmT2KI/W77MSdr7hEGHqWdQ=
|
||||
github.com/766b/chi-prometheus v0.0.0-20211217152057-87afa9aa2ca8/go.mod h1:X/LhbmoBoRu8TxoGIOIraVNhfz3hhikJoaelrOuhdPY=
|
||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e h1:rl2Aq4ZODqTDkeSqQBy+fzpZPamacO1Srp8zq7jf2Sc=
|
||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY=
|
||||
github.com/Azure/azure-pipeline-go v0.2.1 h1:OLBdZJ3yvOn2MezlWvbrBMTEUQC72zAftRZOMdj5HYo=
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/drone/drone/core"
|
||||
"github.com/drone/drone/handler/api/acl"
|
||||
"github.com/drone/drone/handler/api/auth"
|
||||
|
@ -162,6 +163,8 @@ type Server struct {
|
|||
// Handler returns an http.Handler
|
||||
func (s Server) Handler() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
m := chiprometheus.NewMiddleware("api")
|
||||
r.Use(m)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.NoCache)
|
||||
r.Use(logger.Middleware)
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/drone/go-login/login"
|
||||
"github.com/drone/go-scm/scm"
|
||||
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/go-chi/chi/middleware"
|
||||
"github.com/unrolled/secure"
|
||||
|
@ -94,6 +95,8 @@ type Server struct {
|
|||
// Handler returns an http.Handler
|
||||
func (s Server) Handler() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
m := chiprometheus.NewMiddleware("web")
|
||||
r.Use(m)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.NoCache)
|
||||
r.Use(logger.Middleware)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !oss
|
||||
// +build !oss
|
||||
|
||||
package rpc2
|
||||
|
@ -9,6 +10,7 @@ package rpc2
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/drone/drone/operator/manager"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
|
@ -23,6 +25,8 @@ type Server http.Handler
|
|||
// interaction with the build controller using the http transport.
|
||||
func NewServer(manager manager.BuildManager, secret string) Server {
|
||||
r := chi.NewRouter()
|
||||
m := chiprometheus.NewMiddleware("drone")
|
||||
r.Use(m)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.NoCache)
|
||||
r.Use(authorization(secret))
|
||||
|
|
Loading…
Reference in New Issue