prometheus / common

Go libraries shared across Prometheus components and libraries.
Apache License 2.0
259 stars 306 forks source link

feat: add time template helpers #627

Closed freak12techno closed 3 weeks ago

freak12techno commented 2 months ago

Copied from here https://github.com/prometheus/prometheus/blob/34ee8c607809cca973a1d7383713035045f681d8/template/template.go#L267, the eventual goal is to reuse it in Alertmanager as well to allow it as a template helper, and also in Prometheus.

Related: https://github.com/prometheus/alertmanager/issues/3717 Related: https://github.com/prometheus/alertmanager/pull/3720#issuecomment-1968901170

Function itself is moved as is, tests are updated as there's no templates rendering here.

Also added the .idea to .gitignore (as I use Goland IDE and it creates some files that are probably not to be committed) and added the go.mod entry to go.mod and go.sum (otherwise make test would fail).

freak12techno commented 1 month ago

@gotjosh can you look at this?

LMantovan commented 1 month ago

Hi @freak12techno, in the old PR https://github.com/prometheus/alertmanager/pull/3720 you also included time.since. Is it possible to add here?

freak12techno commented 1 month ago

@LMantovan I'll still need to make a PR towards alertmanager to use this template, my plan is to add time.Since in the next PR which will supersede the one I closed.

This one needs to be merged first regardless though.

freak12techno commented 1 month ago

@gotjosh ping?

beorn7 commented 1 month ago

@gotjosh are you up to reviewing this? Either way, could you comment so that we at least know you have seen this PR?

gotjosh commented 3 weeks ago

I apologise for missing the notifications for these - like everyone else, managing Github notifications has become an impossible task at this point.

@grobinson-grafana do you have any spare cycles to review this?

EDIT: I already reviewed.

freak12techno commented 3 weeks ago

@gotjosh done, can you review?

gotjosh commented 3 weeks ago

@freak12techno thank you very much for your contribution 🙏

freak12techno commented 3 weeks ago

@gotjosh can you bump a new version of this repo so I can use it in alertmanager (and I guess in prometheus as well)?

gotjosh commented 3 weeks ago

@ArthurSens can you help me bump a new patch version? Is it the same process as other repositories? TIA.

gotjosh commented 3 weeks ago

I think I've figured it out - you should be good to go @freak12techno.

ArthurSens commented 3 weeks ago

Yeah, there's no release process here as far as I know. Just go to the release pages and do things manually :)