mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-27 01:48:09 -07:00
pkg/metrics: move profiles into the metrics server
This change: - renames pkg/prometheus into pkg/metrics - renames the prometheus_addr config to metrics_addr - adds pprof endpoints to the metrics server - removes profile/trace cli flags - adds endpoints for profiling to the metrics server
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// Package prometheus implements a standalone HTTP server for serving a
|
||||
// Prometheus metrics endpoint.
|
||||
package prometheus
|
||||
// Package metrics implements a standalone HTTP server for serving pprof
|
||||
// profiles and Prometheus metrics.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
@@ -31,10 +32,19 @@ func (s *Server) Stop() stop.Result {
|
||||
// NewServer creates a new instance of a Prometheus server that asynchronously
|
||||
// serves requests.
|
||||
func NewServer(addr string) *Server {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
|
||||
s := &Server{
|
||||
srv: &http.Server{
|
||||
Addr: addr,
|
||||
Handler: promhttp.Handler(),
|
||||
Handler: mux,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user