-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Is there any specific reason to not expose now property in the metric options struct? #1354
Comments
Hmmmm, good point... when implementing this though, we were afraid that people would override the now() function with some super weird function that would eventually trigger weird behaviors in Prometheus. It was basically to avoid users to shooting their own foots. I understand that it makes testing a lot harder now. WDYT @bwplotka @kakkoyun ? |
Thanks! Let's find together a good solution, sorry for breaking your tests.
How you compare those exactly @myarjunar? I would love to avoid making test-focused fields public in important APIs and add full compatibility guarantee on those. I think there are ways to avoid it:
|
Hello, we've also stumbled upon this.
I think Opts.Now could be exported with a clear description what it does. |
In one of my unit tests, I am comparing the equality of
MetricFamily
objects, which include aCounter
type metric. Prior to the v1.17.0 release, theCreatedTimestamp
field did not include a timestamp value at the time of creation. However, with this recent release, theCreatedTimestamp
is automatically populated with the current timestamp at the time of metric creation.I also noticed that the metric options include a
now
property. Based on the description in the code, it appears that this property is used for testing purposes internally within the package. I would like to suggest making thenow
property public in the library. This would provide users like me with the ability to mock thenow
function, enabling us to conduct comprehensive testing externally.Would love to hear your opinion on this or if there is indeed a specific reason not to do it that way. Thanks in advance!
The text was updated successfully, but these errors were encountered: