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

Gauge.setToCurrentTime() : TypeScript definition says the time is set in milliseconds, but implementation sets the time in epoch seconds #568

Closed
Totalus opened this issue May 11, 2023 · 1 comment · Fixed by #585

Comments

@Totalus
Copy link

Totalus commented May 11, 2023

TypeScript doc says it sets the value to epoch milliseconds:

prom-client/index.d.ts

Lines 361 to 365 in 1df34ed

/**
* Set gauge value to current epoch time in ms
* @param labels Object with label keys and values
*/
setToCurrentTime(labels?: LabelValues<T>): void;

Actual implementation sets the value to epoch seconds:

prom-client/lib/gauge.js

Lines 74 to 86 in 1df34ed

/**
* Set the gauge to current unix epoch
* @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
* @returns {void}
*/
setToCurrentTime(labels) {
const now = Date.now() / 1000;
if (labels === undefined) {
this.set(now);
} else {
this.set(labels, now);
}
}

I guess it was not updated properly after changed to seconds (#167)

@SimenB
Copy link
Collaborator

SimenB commented May 12, 2023

Wanna send a PR updating? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants