Skip to content

Skip analytics for configured ignore header - #19

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

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

Conversation

@Gutts-n

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

Copy link
Copy Markdown
Contributor

What changed

AnalyticsMiddleware now skips analytics entirely for a request whose
configured header matches a configured value - not logged with a
distinguishing field, just never recorded. New config:

  • ANALYTICS_IGNORE_HEADER - header name to check (e.g. Request-Source)
  • 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. The check runs before any capture/body-tee
work, so a matched request costs nothing extra.

Why

Part of the NESO API-usage-metrics work (neso-nextgen-shared#152). Data
Explorer sends Request-Source: data-explorer on its calls to this service
(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
that's the wrong layer: better to not log this traffic at all than log it
and filter downstream. Reworked accordingly.

Same change going into ckanext-analytics (CKAN Action API side). The
neso-monitoring dashboard PR's BigQuery filter is now unnecessary and will
be reverted separately.

Verified

  • pytest - 484 passed.
  • ruff check / mypy - clean.
  • 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 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: d50a8121-6166-420c-80c5-f5ca81eb55c6


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.

Comment thread datastore/analytics.py Outdated
@Gutts-n Gutts-n changed the title Add request_source field Skip analytics for configured ignore header Aug 27, 2026
@Gutts-n
Gutts-n merged commit 426d058 into main Aug 27, 2026
2 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.

2 participants