Skip to content

Skip analytics for configured ignore header - #2

Merged
Gutts-n merged 2 commits into
mainfrom
feat/request-source-field
Aug 27, 2026
Merged

Skip analytics for configured ignore header#2
Gutts-n merged 2 commits into
mainfrom
feat/request-source-field

Conversation

@Gutts-n

@Gutts-n Gutts-n commented Aug 27, 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). An earlier version of this work 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).

Replaces #1 (opened from a fork before push access was granted on this
repo) - same commits, now against this repo directly.

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 27, 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: f5f784f2-117f-481d-94e6-c69d9888ebc5


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 d1e7abc into main Aug 27, 2026
1 of 4 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