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

Function ExampleCollector

prometheus/example_clustermanager_test.go:124–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122}
123
124func ExampleCollector() {
125 // Since we are dealing with custom Collector implementations, it might
126 // be a good idea to try it out with a pedantic registry.
127 reg := prometheus.NewPedanticRegistry()
128
129 // Construct cluster managers. In real code, we would assign them to
130 // variables to then do something with them.
131 NewClusterManager("db", reg)
132 NewClusterManager("ca", reg)
133
134 // Add the standard process and Go metrics to the custom registry.
135 reg.MustRegister(
136 prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
137 prometheus.NewGoCollector(),
138 )
139
140 http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
141 log.Fatal(http.ListenAndServe(":8080", nil))
142}

Callers

nothing calls this directly

Calls 7

NewPedanticRegistryFunction · 0.92
NewProcessCollectorFunction · 0.92
NewGoCollectorFunction · 0.92
HandlerForFunction · 0.92
NewClusterManagerFunction · 0.85
HandleMethod · 0.80
MustRegisterMethod · 0.65

Tested by

no test coverage detected