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

Function main

examples/middleware/main.go:28–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26)
27
28func 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}

Callers

nothing calls this directly

Calls 8

MustRegisterMethod · 0.95
NewRegistryFunction · 0.92
NewGoCollectorFunction · 0.92
NewProcessCollectorFunction · 0.92
NewFunction · 0.92
HandlerForFunction · 0.92
HandleMethod · 0.80
WrapHandlerMethod · 0.65

Tested by

no test coverage detected