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

feat: Export last check and last update to prometheus #188

Closed
wants to merge 4 commits into from

Conversation

chriswk
Copy link
Member

@chriswk chriswk commented Aug 1, 2024

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.

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
@chriswk chriswk self-assigned this Aug 1, 2024
Comment on lines +9 to +22
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);
Copy link
Member Author

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.

Comment on lines +82 to 90
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);
});
}
Copy link
Member Author

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.

@chriswk
Copy link
Member Author

chriswk commented Aug 1, 2024

F this. Will remake PR without the linting, and make a separate PR with those changes.

@chriswk chriswk closed this Aug 1, 2024
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 this pull request may close these issues.

1 participant