Skip to content

Add source-IP fallback to analytics ignore check - #3

Merged
Gutts-n merged 1 commit into
mainfrom
feat/ignore-by-source-ip
Aug 28, 2026
Merged

Add source-IP fallback to analytics ignore check#3
Gutts-n merged 1 commit into
mainfrom
feat/ignore-by-source-ip

Conversation

@Gutts-n

@Gutts-n Gutts-n commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

What changed

Added CKANEXT_ANALYTICS_IGNORE_IPS (comma-separated) alongside the
existing 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_ip to share its resolution logic with the new
is_ignored check (_request_ip static 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 (minimal
    flask+pytest venv, --ckan-ini addopts overridden).
  • New tests: IP match skips, non-matching IP still records, header and IP
    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_IPS should reconfirm with the DXP team first.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5564195d-d2ad-4408-ad8f-5a064b11c379


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Gutts-n
Gutts-n merged commit ca0a903 into main Aug 28, 2026
1 of 3 checks passed
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