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

Function main

examples/versioncollector/main.go:35–51  ·  view source on GitHub ↗

Build using ldflags, for example: go build -ldflags "-X github.com/prometheus/common/version.Version=1.0.0 -X github.com/prometheus/common/version.Branch=abc123" .

()

Source from the content-addressed store, hash-verified

33// Build using ldflags, for example:
34// go build -ldflags "-X github.com/prometheus/common/version.Version=1.0.0 -X github.com/prometheus/common/version.Branch=abc123" .
35func main() {
36 flag.Parse()
37
38 // Create a new registry.
39 reg := prometheus.NewRegistry()
40
41 // Register version collector.
42 reg.MustRegister(version.NewCollector("example"))
43
44 // Expose the registered metrics via HTTP.
45 http.Handle("/metrics", promhttp.HandlerFor(
46 reg,
47 promhttp.HandlerOpts{},
48 ))
49 fmt.Println("Hello world from new Version Collector!")
50 log.Fatal(http.ListenAndServe(*addr, nil))
51}

Callers

nothing calls this directly

Calls 6

MustRegisterMethod · 0.95
NewRegistryFunction · 0.92
NewCollectorFunction · 0.92
HandlerForFunction · 0.92
HandleMethod · 0.80
PrintlnMethod · 0.65

Tested by

no test coverage detected