prometheus / client_golang

Prometheus instrumentation library for Go applications
https://pkg.go.dev/github.com/prometheus/client_golang
Apache License 2.0
5.43k stars 1.18k forks source link

gocollector tests: Adjust CI to tell us when generated files were manually changed + refactor? #1575

Open ArthurSens opened 3 months ago

ArthurSens commented 3 months ago

While working on https://github.com/prometheus/client_golang/pull/1559, we noticed that the generated files for the go collector can be manually changed and CI won't block the merge.

Let's investigate this and adjust :)

bwplotka commented 3 months ago

Yup, CI is NOT running this generative script.

We only check if metrics given by the runtime is what we expect in those generated _test files and then complain with instruction to potentially rerun that script. This helps us to figure out what metrics changed across Go version. That's the main goal of those files.

You might be right some CI check that would rerun this script and point mismatch on TOP of our existing test would let us know if someone shoveled some custom manual code to those files.

Do you mind adding clear acceptance criteria to description?

bwplotka commented 3 months ago

BTW.. we have two of those scripts 🙈

https://github.com/prometheus/client_golang/blob/main/prometheus/gen_go_collector_metrics_set.go https://github.com/prometheus/client_golang/blob/main/prometheus/collectors/gen_go_collector_set.go

bwplotka commented 3 months ago

This might need proper refactor e.g. have one generated set in internals and separate logic to filter those for test purposes (it's just regex)

bwplotka commented 3 months ago

Ideally I would also have only one script that generates both package files 🤔

bwplotka commented 3 months ago

Acceptance Criteria

augustodsgv commented 3 weeks ago

Hello guys, I would like to start contributing to the project and this issue was recommend to me. Can i start working on this?

ArthurSens commented 3 weeks ago

Sure thing! Is the discussion here enough for you to start working, or do you feel like you need extra guidance?