Skip to content

Skip analytics for configured ignore header - #1

Closed
Gutts-n wants to merge 2 commits into
datopian:mainfrom
Gutts-n:feat/request-source-field
Closed

Skip analytics for configured ignore header#1
Gutts-n wants to merge 2 commits into
datopian:mainfrom
Gutts-n:feat/request-source-field

Conversation

@Gutts-n

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

Copy link
Copy Markdown
Collaborator

What changed

A request carrying the configured ignore header/value now skips analytics
entirely - not logged with a distinguishing field, just never recorded.
New config (module-level, read from env at import like the existing
CKANEXT_ANALYTICS_SERVICE):

  • CKANEXT_ANALYTICS_IGNORE_HEADER - header name to check (e.g.
    Request-Source)
  • CKANEXT_ANALYTICS_IGNORE_VALUES - comma-separated values that trigger
    the skip (e.g. data-explorer), matched case-insensitively

Both empty (the default) disables the check - every tracked request is
logged, same as before this PR.

Why

Part of the NESO API-usage-metrics work (neso-nextgen-shared#152). Data
Explorer sends Request-Source: data-explorer on its calls
(neso-nextgen-shared#145). Original version of this PR captured the header
into the event and left filtering to the BigQuery/dashboard layer -
@sagargg pointed out on the matching datastore
PR

that's the wrong layer: better to not log this traffic at all than log it
and filter downstream. Reworked accordingly, same change applied to
datopian/datastore#19 (the Datastore API's own analytics middleware).

Verified

  • pytest ckanext/analytics/tests/test_event.py - 48 passed (ran locally
    with a minimal flask+pytest venv, --ckan-ini addopts overridden since
    no CKAN environment was available locally).
  • Tests cover: header+value match skips (case-insensitive), no header sent
    still records, header present with a non-matching value still records,
    check disabled by default (unconfigured) never skips.

Not verified: end-to-end against a live CKAN + Loki + BigQuery pipeline.

@coderabbitai

coderabbitai Bot commented Aug 26, 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: f7fe4506-2c8f-4179-9561-e5c94e0aa826


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 changed the title Add request_source field Skip analytics for configured ignore header Aug 27, 2026
@Gutts-n

Gutts-n commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #2 - now that I have push access to this repo, opened the same branch directly against it instead of from the fork.

@Gutts-n Gutts-n closed this Aug 27, 2026
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