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
Cd/add metrics logger #11
Conversation
Module that keeps maintains a global singleton variable to retain metric state and log them on demand. References: connectedcars/api#854
Global singletons are close to impossible to mock properly.
concats name and labels into a key
Function getPrometheusMetrics assumed that metrics.labels was always set. This commit makes a precheck to handle the case of no labels.
@mathiastj do we have any node 6 projects that we should be compatible with? |
I can't find any, so I think we're good. |
Should probably update the README to show how to use the new format. |
Keys did not include the label name, thus causing possible colissions. Also, logMetrics was iterating the values instead of the keys.
The default switch can never be reached. Only if the API consumer is fiddling around with this.metrics and adds bogus keys and values.
startTime is not used on gauge type. Only cumulative type.
Also adapts existing tests to cover the changes in the prev. commits
Just talked to @mathiastj : It probably makes sense to make |
the `gauge()` function now takes an extra argument, thus making it possible to do other than takes the last value
const key = this.createKey(name, labels) | ||
const metric = this.metrics[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to be consistent, i.e. in the cumulative function too
Eventually the timestamps will end up on Google Custom Metrics and they expect ISO-8601 timestamps
No description provided.