-
Notifications
You must be signed in to change notification settings - Fork 1
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
Freshness metrics #275
Freshness metrics #275
Conversation
7bad3f2
to
1d27155
Compare
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.
Nice idea adding a metric! Left a couple comments on the implementation.
def get_oldest_postcode | ||
# Cache metric to prevent needless expensive calls to the database | ||
Rails.cache.fetch("metrics:oldest_postcode", expires_in: 1.hour) do | ||
(Time.zone.now.to_i - Postcode.os_places.order(updated_at: :asc).first.updated_at.to_i) |
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.
Using the updated_at
timestamp seems a little flakey as any update to the record would influence the timestamp, have we considered adding a separate time field for OS places request?
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.
I think this is pretty safe because the only way these records get updated is via OS Places API calls (with one exception: bulk CSV import, which is also a reasonable consideration of freshness and is unlikely to happen again anyway).
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.
For now yes, agreed. However, if the code changes in the future and the records are updated outside of OS places requests then this is metric may no longer be meaningful. I think relying on the standard timestamp values for harvesting data will probably trip someone up in the future. Don't think I'd classify this as a blocker as we're only at risk of breaking a metric but one we'd probably want to consider more if we plan to alert on it 👍
1d27155
to
b06fe4d
Compare
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.
LGTM
Adds a freshness metric for OS Places postcodes. Every hour we update the oldest postcode sourced from OS Places APi and allow prometheus to collect its age rounded down to the day. We can then see a graph of the age in seconds of the least-recently updated postcode. Since we're expecting the entire database to be refreshed roughly once a week, we should see this hover around the 7 mark. If it increases significantly above that, we may be seeing problems.
We will evaluate this for a while before deciding if we need to add an alarm state to it.
https://trello.com/c/8P4LRqvl/2171-investigate-how-we-can-handle-os-places-api-being-down