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

Alert templates type conflict: SampleValue v. float64 #556

Closed
aecolley opened this Issue Feb 25, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@aecolley
Copy link

aecolley commented Feb 25, 2015

Attempts to interpolate {{humanizeDuration $value}} fail with a type error:

wrong type for value; expected float64; got model.SampleValue

There's no way to work around this.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 25, 2015

Hmm, try {{value $value | humanizeDuration}}

Sounds like a bug.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 25, 2015

Ah, it's a casting problem. We need to cast to float64 in

Value clientmodel.SampleValue

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Mar 2, 2015

One thing to watch out for when changing this: we currently have a nice String() method for serializing clientmodel.SampleValue:

https://github.com/prometheus/client_golang/blob/master/model/samplevalue.go#L35-L37

If we cast everything to float64, then the default string representation will look less nice for many use cases. For example, timestamps will by default be printed in scientific notation (1.413989023e+09) and shenanigans like that.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.