-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: Export last check and last update to prometheus #188
Conversation
Reported in #187, this PR adds prometheus and creates two gauges, one for keeping track of last update (an actual refresh of feature toggles) as well as last call to upstream Unleash. sidenote: moved to biome and copied Unleash/unleash config to fall more in line, should've been a separate PR, but once I got stuck into adding prometheus, I couldn't help myself, I had to boyscout
export const lastMetricsUpdate: Gauge = createGauge({ | ||
name: 'last_metrics_update_epoch_timestamp_ms', | ||
help: 'An epoch timestamp (in milliseconds) set to when our unleash-client last got an update from upstream Unleash', | ||
}); | ||
|
||
export const lastMetricsFetch: Gauge = createGauge({ | ||
name: 'last_metrics_fetch_epoch_timestamp_ms', | ||
help: 'An epoch timestamp (in milliseconds) set to when our unleash-client last checked (regardless if there was an update or not)', | ||
}); | ||
|
||
createCounter({ | ||
name: 'unleash_proxy_up', | ||
help: 'Indication that the service is up.', | ||
}).inc(1); |
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.
The gist of the PR is here. Copies Nuno's great work on creating typechecked labels (though we don't actually use labels here) from unleash/unleash, but sets up for the future. Could consider removing histogram and summary, since it's currently unused.
this.unleash.on(UnleashEvents.Unchanged, () => { | ||
lastMetricsFetch.set(new Date().getTime()); | ||
}); | ||
this.unleash.on(UnleashEvents.Changed, () => { | ||
const updated = new Date().getTime(); | ||
lastMetricsFetch.set(updated); | ||
lastMetricsUpdate.set(updated); | ||
}); | ||
} |
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.
Other important behavior change, adds an event listener to Unchanged updating the fetch counter, and to Changed events updating both last fetch and last update.
F this. Will remake PR without the linting, and make a separate PR with those changes. |
Reported in #187, this PR adds prometheus and creates two gauges, one for keeping track of last update (an actual refresh of feature toggles) as well as last call to upstream Unleash.
sidenote: moved to biome and copied Unleash/unleash config to fall more in line, should've been a separate PR, but once I got stuck into adding prometheus, I couldn't help myself, I had to boyscout
2nd sidenote: We really should boyscout this a bit more, we're still using node 16, our nvmrc was locked to node 14, and we should move to yarn v4 here as well. Separate PR for that at least.