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 a simple buildInfoCollector #595

Merged
merged 1 commit into from
Jun 7, 2019
Merged

Add a simple buildInfoCollector #595

merged 1 commit into from
Jun 7, 2019

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented Jun 6, 2019

This is now kind of meant as complementary to https://github.com/povilasv/prommod , see doc comment. https://github.com/povilasv/prommod is concerned with the dependencies, while this simple collector is only doing the main module. It is, if you want, the poor person's version of prometheus/common/version. If you build your binaries in the "right" (modules) way, you get the version info for free without setting any build variables.

Since many users might not build their binaries in that "right" way yet, and some might not want to disclose their package path or version, this collector is not registered with the default registry.

@beorn7
Copy link
Member Author

beorn7 commented Jun 6, 2019

Yeah, the example needs to get a build tag, too.

@beorn7 beorn7 force-pushed the beorn7/go-collector branch 2 times, most recently from 6bfe478 to a2f08db Compare June 6, 2019 19:24
@beorn7
Copy link
Member Author

beorn7 commented Jun 6, 2019

@povilasv What do you think?
@brian-brazil Does this fix #539 in the intended way?

prometheus/build_info_collector.go Outdated Show resolved Hide resolved
prometheus/build_info_collector.go Outdated Show resolved Hide resolved
@beorn7 beorn7 force-pushed the beorn7/go-collector branch 3 times, most recently from f3a4137 to 575e78f Compare June 6, 2019 20:16
@beorn7
Copy link
Member Author

beorn7 commented Jun 6, 2019

This works, but I'll change the file structure to not repeat so much doc comment.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented Jun 6, 2019

OK, all done.

@brian-brazil
Copy link
Contributor

👍

@beorn7
Copy link
Member Author

beorn7 commented Jun 6, 2019

You can try it out:

$ GO111MODULE=on go get github.com/prometheus/client_golang/examples/random@8576729
go: finding github.com/prometheus/client_golang/examples/random 8576729
go: finding github.com/prometheus/client_golang/examples 8576729
go: finding github.com/prometheus/client_golang 8576729
$ random &
[1] 18036
$ curl -s localhost:8080/metrics | grep go_build_info
# HELP go_build_info Build information about the main Go module.
# TYPE go_build_info gauge
go_build_info{checksum="h1:4ngA1sNiO1owrwGu/W+yaCOpGrIVnhf7MYTxQMXwtFM=",path="github.com/prometheus/client_golang",version="v0.9.4-0.20190606202423-8576729b6f65"} 1

@beorn7 beorn7 merged commit b8b56b5 into master Jun 7, 2019
@beorn7 beorn7 deleted the beorn7/go-collector branch June 7, 2019 08:33
@beorn7
Copy link
Member Author

beorn7 commented Jun 7, 2019

Merging now. @povilasv your input is still welcome.

@povilasv
Copy link
Contributor

Nice work :) Read thru the code and tested examples, everything works as documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants