Add source-IP fallback to analytics ignore check - #3
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Added
CKANEXT_ANALYTICS_IGNORE_IPS(comma-separated) alongside theexisting
CKANEXT_ANALYTICS_IGNORE_HEADER/CKANEXT_ANALYTICS_IGNORE_VALUES.A request from a configured IP skips analytics logging the same way a
matching header does - either check alone is enough. Also refactored
RequestEvent.request_ipto share its resolution logic with the newis_ignoredcheck (_request_ipstatic helper) instead of duplicating it.Why
Part of the NESO API-usage-metrics work (neso-nextgen-shared#152). The DXP
frontend still doesn't send an identifying header - that part of the
original ask (neso-nextgen-shared#145) is still open. In the meantime, the
DXP team reported their web server's static egress IPs for production:
https://github.com/datopian/client-national-grid-shared/issues/496#issuecomment-3158622385
(
54.247.74.82,63.32.18.228).IP is explicitly a weaker, secondary signal - #145's original ask called
this out too. Stopgap until the header lands, not a replacement for it.
Same change applied to datopian/datastore#21.
Verified
pytest ckanext/analytics/tests/test_event.py- 51 passed (minimalflask+pytest venv,
--ckan-iniaddopts overridden).checks are independent.
Not verified: end-to-end against a live pipeline, and I have no way to
confirm those two IPs are still current - production traffic isn't
ingested into the monitoring stack I have access to. Whoever sets
CKANEXT_ANALYTICS_IGNORE_IPSshould reconfirm with the DXP team first.