()
| 31 | var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.") |
| 32 | |
| 33 | func main() { |
| 34 | flag.Parse() |
| 35 | |
| 36 | // Create a new registry. |
| 37 | reg := prometheus.NewRegistry() |
| 38 | reg.MustRegister( |
| 39 | collectors.NewGoCollector(), |
| 40 | collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}), |
| 41 | ) |
| 42 | |
| 43 | // We should see the following metrics with an extra source label. But |
| 44 | // other collectors registered above are expected not to have the extra |
| 45 | // label. |
| 46 | // See also https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels |
| 47 | startFireKeeper(prometheus.WrapRegistererWith(prometheus.Labels{"component": "FireKeeper"}, reg)) |
| 48 | startSparkForge(prometheus.WrapRegistererWith(prometheus.Labels{"component": "SparkForge"}, reg)) |
| 49 | |
| 50 | http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) |
| 51 | log.Fatal(http.ListenAndServe(*addr, nil)) |
| 52 | } |
| 53 | |
| 54 | func startFireKeeper(reg prometheus.Registerer) { |
| 55 | firesMaintained := promauto.With(reg).NewCounter(prometheus.CounterOpts{ |
nothing calls this directly
no test coverage detected