()
| 26 | ) |
| 27 | |
| 28 | func main() { |
| 29 | // Create non-global registry. |
| 30 | registry := prometheus.NewRegistry() |
| 31 | |
| 32 | // Add go runtime metrics and process collectors. |
| 33 | registry.MustRegister( |
| 34 | collectors.NewGoCollector(), |
| 35 | collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}), |
| 36 | ) |
| 37 | |
| 38 | // Expose /metrics HTTP endpoint using the created custom registry. |
| 39 | http.Handle( |
| 40 | "/metrics", |
| 41 | httpmiddleware.New( |
| 42 | registry, nil). |
| 43 | WrapHandler("/metrics", promhttp.HandlerFor( |
| 44 | registry, |
| 45 | promhttp.HandlerOpts{}), |
| 46 | )) |
| 47 | |
| 48 | log.Fatalln(http.ListenAndServe(":8080", nil)) |
| 49 | } |
nothing calls this directly
no test coverage detected