openedx / edx-django-utils

edX utilities for Django Application development.
https://edx.readthedocs.io/projects/edx-django-utils/en/latest/
Apache License 2.0
26 stars 20 forks source link

Reduce monitoring noise from large third party cookies #329

Open rgraber opened 1 year ago

rgraber commented 1 year ago

Context We have a few large cookies in our cookie headers that we are pretty sure we're not going to be able to get rid of or make smaller, mostly from third parties. They may be diverting attention from other large cookies we can fix or remove.

Proposal Split the cookie size calculations into ones that factor in these third party cookies and ones that don't.

Implementation details: Add a new COOKIE_LOGGING_IGNORE_LIST setting that takes a list of prefixes Add a new COOKIE_HEADER_WITH_EXCLUSIONS_SIZE_LOGGING_THRESHOLD setting (needs a better name) Split the large cookie header logging code into two parts:

  1. If the total size is over COOKIE_HEADER_SIZE_LOGGING_THRESHOLD, log everything
  2. Otherwise, check the size of the header excluding cookies matching those in COOKIE_LOGGING_IGNORE_LIST
  3. If the new size is over COOKIE_HEADER_WITH_EXCLUSIONS_SIZE_LOGGING_THRESHOLD, log everything except the cookies that were ignored
    1. Add a new custom attribute for the new size