diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/metrics/metrics.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 9030775..74f9ffb 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go | |||
| @@ -288,12 +288,20 @@ const ( | |||
| 288 | //go:embed dashboard.html | 288 | //go:embed dashboard.html |
| 289 | var dashboardHTML []byte | 289 | var dashboardHTML []byte |
| 290 | 290 | ||
| 291 | func (m *Metrics) Serve(addr, path string) error { | 291 | func (m *Metrics) PrometheusHandler() http.Handler { |
| 292 | mux := http.NewServeMux() | 292 | return promhttp.Handler() |
| 293 | mux.Handle(path, promhttp.Handler()) | 293 | } |
| 294 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | 294 | |
| 295 | func (m *Metrics) DashboardHandler() http.Handler { | ||
| 296 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| 295 | w.Header().Set("Content-Type", "text/html; charset=utf-8") | 297 | w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 296 | w.Write(dashboardHTML) | 298 | w.Write(dashboardHTML) |
| 297 | }) | 299 | }) |
| 300 | } | ||
| 301 | |||
| 302 | func (m *Metrics) Serve(addr, path string) error { | ||
| 303 | mux := http.NewServeMux() | ||
| 304 | mux.Handle(path, m.PrometheusHandler()) | ||
| 305 | mux.Handle("/", m.DashboardHandler()) | ||
| 298 | return http.ListenAndServe(addr, mux) | 306 | return http.ListenAndServe(addr, mux) |
| 299 | } | 307 | } |
