MCPcopy
hub / github.com/prometheus/client_golang / main

Function main

examples/customlabels/main.go:33–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.")
32
33func 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
54func startFireKeeper(reg prometheus.Registerer) {
55 firesMaintained := promauto.With(reg).NewCounter(prometheus.CounterOpts{

Callers

nothing calls this directly

Calls 9

MustRegisterMethod · 0.95
NewRegistryFunction · 0.92
NewGoCollectorFunction · 0.92
NewProcessCollectorFunction · 0.92
WrapRegistererWithFunction · 0.92
HandlerForFunction · 0.92
startFireKeeperFunction · 0.85
startSparkForgeFunction · 0.85
HandleMethod · 0.80

Tested by

no test coverage detected