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

frontend: refactor subscription metrics #1272

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

simonpasquier
Copy link
Collaborator

What this PR does

This change implements a custom collector for the subscription lifecycle metrics. In practice, the collector maintains a local cache of subscriptions which is refreshed periodically from the database.

The benefits are:

  • The metrics are persisted upon restart of the process (previously a subscription would only exist as a metric if it was accessed by some HTTP operation).
  • All frontend replicas report the same metrics.
  • Only the latest state of a subscription is reported (in the previous implementation, the old state would still be reported after an update).

The cache is refreshed every 30 seconds which should be good enough assuming that the metrics are scraped at a similar (or greater) interval.

Jira:
Link to demo recording:

Special notes for your reviewer

Copy link

github-actions bot commented Feb 7, 2025

Please rebase pull request.

Copy link

Please rebase pull request.

@simonpasquier simonpasquier force-pushed the lifecycle-metric-collector branch from d8e71bf to 195c66b Compare February 10, 2025 13:48
@simonpasquier simonpasquier force-pushed the lifecycle-metric-collector branch from 195c66b to 40d29db Compare February 10, 2025 14:11
Copy link
Collaborator

@mbarnes mbarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested a simplification that would avoid another wait group.

@simonpasquier simonpasquier force-pushed the lifecycle-metric-collector branch from 40d29db to acc859e Compare February 11, 2025 09:04
This change implements a custom collector for the subscription lifecycle
metrics. In practice, the collector maintains a local cache of
subscriptions which is refreshed periodically from the database.

The benefits are:
* The metrics are persisted upon restart of the process (previously a
  subscription would only exist as a metric if it was accessed by some
  HTTP operation).
* All frontend replicas report the same metrics.
* Only the latest state of a subscription is reported (in the previous
  implementation, the old state would still be reported after an
  update).

The cache is refreshed every 30 seconds which should be good enough
assuming that the metrics are scraped at a similar (or greater)
interval.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier simonpasquier force-pushed the lifecycle-metric-collector branch from acc859e to 3c9fbb1 Compare February 11, 2025 09:38
Copy link
Collaborator

@mbarnes mbarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

This will introduce a small conflict with changes I have staged in #1215 - database: Merge Cosmos DB containers but I'll adapt it rather than hold this PR up any longer.

@mbarnes mbarnes merged commit 5be3e00 into main Feb 14, 2025
10 checks passed
@mbarnes mbarnes deleted the lifecycle-metric-collector branch February 14, 2025 16:21
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.

2 participants