Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus metric exporter #6

Open
mszostok opened this issue Jul 23, 2022 · 0 comments
Open

Add Prometheus metric exporter #6

mszostok opened this issue Jul 23, 2022 · 0 comments
Labels
area/integration Integration with external libs

Comments

@mszostok
Copy link
Owner

Description

Add built-in extension to export metric for Prometheus. For example:

// NewCollector returns a collector that exports metrics about current version
// information.
func NewCollector(program string) prometheus.Collector {
	return prometheus.NewGaugeFunc(
		prometheus.GaugeOpts{
			Namespace: program,
			Name:      "build_info",
			Help: fmt.Sprintf(
				"A metric with a constant '1' value labeled by version, revision, branch, and goversion from which %s was built.",
				program,
			),
			ConstLabels: prometheus.Labels{
				"version":   Version,
				"revision":  Revision,
				"branch":    Branch,
				"goversion": GoVersion,
			},
		},
		func() float64 { return 1 },
	)
}
@mszostok mszostok added enhancement New feature or request area/integration Integration with external libs and removed enhancement New feature or request labels Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integration Integration with external libs
Projects
Status: No status
Development

No branches or pull requests

1 participant