Conversation
Signed-off-by: Techno Freak <freak12techno@gmail.com>
e6cf027 to
fe8dec6
Compare
| { | ||
| title: "Template using since", | ||
| in: "{{ . | since | humanizeDuration }}", | ||
| data: time.Now().Add(-1 * time.Hour), |
There was a problem hiding this comment.
tbh I am not sure how to test this one properly without mocking time.Since, which as far as I know cannot be done without some kinds of workaround, this one looks ugly and flaky (as it relies on local time and will fail if the time between creating this variable and rendering is more than 1 second), but it kinda works, let me know if there's a better way to do it
Signed-off-by: Techno Freak <freak12techno@gmail.com>
13f7681 to
ac7d8b7
Compare
|
@gotjosh can you review or ping somebody to do that? |
|
@freak12techno how do you feel about moving the helper into https://github.com/prometheus/common so that we don't have to copy/pate here? |
|
@gotjosh I am ok with this, I can do the following:
does this sound decent? |
|
Sounds perfect to me! |
|
I'll close this one as it'll be required to rewrite it anyways. |
Fixes #3717.
The
humanizeDirectionhelper is 100% copied from Prometheus, thesinceis added by me.The tests are also copied from Prometheus and adapted, plus I added my own
sincetest.Tested it locally: creating an alert like this one:
with a template like this one
produces the following output: