mirror of https://github.com/harness/drone.git
Enable http metrics (#3459)
Adding config option to enable http metrics --------- Signed-off-by: Max Knee <max.knee@nytimes.com>pull/3451/head
parent
e1fc66e077
commit
94bcb869dc
|
@ -170,6 +170,7 @@ type (
|
|||
// Prometheus provides the prometheus configuration.
|
||||
Prometheus struct {
|
||||
EnableAnonymousAccess bool `envconfig:"DRONE_PROMETHEUS_ANONYMOUS_ACCESS" default:"false"`
|
||||
EnableHTTPMetrics bool `envconfig:"DRONE_PROMETHEUS_HTTP_METRICS" default:"false"`
|
||||
}
|
||||
|
||||
// Redis provides the redis configuration.
|
||||
|
|
|
@ -60,10 +60,12 @@ var serverSet = wire.NewSet(
|
|||
|
||||
// provideRouter is a Wire provider function that returns a
|
||||
// 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 {
|
||||
func provideRouter(api api.Server, web web.Server, rpcv1 rpcHandlerV1, rpcv2 rpcHandlerV2, healthz healthzHandler, metrics *metric.Server, pprof pprofHandler, config config.Config) *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
m := chiprometheus.NewMiddleware("server")
|
||||
r.Use(m)
|
||||
if config.Prometheus.EnableHTTPMetrics {
|
||||
m := chiprometheus.NewPatternMiddleware("server")
|
||||
r.Use(m)
|
||||
}
|
||||
r.Mount("/healthz", healthz)
|
||||
r.Mount("/metrics", metrics)
|
||||
r.Mount("/api", api.Handler())
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// Code generated by Wire. DO NOT EDIT.
|
||||
|
||||
//go:generate wire
|
||||
//+build !wireinject
|
||||
//go:generate go run github.com/google/wire/cmd/wire
|
||||
//go:build !wireinject
|
||||
// +build !wireinject
|
||||
|
||||
package main
|
||||
|
||||
|
@ -113,7 +114,7 @@ func InitializeApplication(config2 config.Config) (application, error) {
|
|||
mainHealthzHandler := provideHealthz()
|
||||
metricServer := provideMetric(session, config2)
|
||||
mainPprofHandler := providePprof(config2)
|
||||
mux := provideRouter(server, webServer, mainRpcHandlerV1, mainRpcHandlerV2, mainHealthzHandler, metricServer, mainPprofHandler)
|
||||
mux := provideRouter(server, webServer, mainRpcHandlerV1, mainRpcHandlerV2, mainHealthzHandler, metricServer, mainPprofHandler, config2)
|
||||
serverServer := provideServer(mux, config2)
|
||||
mainApplication := newApplication(cronScheduler, reaper, datadog, runner, serverServer, userStore)
|
||||
return mainApplication, nil
|
||||
|
|
|
@ -18,7 +18,6 @@ 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"
|
||||
|
@ -163,8 +162,6 @@ 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,7 +25,6 @@ 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"
|
||||
|
@ -95,8 +94,6 @@ 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)
|
||||
|
|
|
@ -10,7 +10,6 @@ package rpc2
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/drone/drone/operator/manager"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
|
@ -25,8 +24,6 @@ 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