Skip to content

feat: enhance cookie monitoring and logging - #30027

Merged
robrap merged 2 commits into
masterfrom
robrap/ARCHBOM-2055-update-cookie-logging
Mar 10, 2022
Merged

feat: enhance cookie monitoring and logging#30027
robrap merged 2 commits into
masterfrom
robrap/ARCHBOM-2055-update-cookie-logging

Conversation

@robrap

@robrap robrap commented Mar 8, 2022

Copy link
Copy Markdown
Contributor

Description

Contains a number of cookie monitoring changes.

Enhancements:

  • Add sampling capability for cookie logging on headers
    smaller than the threshold. For details, see
    COOKIE_SAMPLING_REQUEST_COUNT.
  • Add cookie header size to log message.
  • Sort logged cookies starting with largest cookie.
  • Move logging from Middleware request processing
    to response processing to ensure the user id is
    available for logging for authenticated calls.
  • Added cookies.header.size.computed to check
    if there are any large hidden duplicate cookies.
    Can be compared against the cookies.header.size
    custom attribute.

Removed:

  • Legacy cookie capture code. This code was dangerous to
    to enable and provided more limited insight than the
    newer logging, so this was removed to simplify the code.

Other refactors:

  • Switched Middleware to use new Django format, rather
    than the Mixin.
  • Moved tests to its own test class. Note: this
    middleware is likely to move to a separate
    library.

Supporting information

ARCHBOM-2055

Other information

Apologies that this is all in one commit, but it made my life much simpler. If it is too difficult for reviewing, we can discuss splitting this up.

Comment thread openedx/core/lib/request_utils.py Outdated
Comment thread openedx/core/lib/request_utils.py Outdated
Comment thread openedx/core/lib/request_utils.py Outdated
Comment thread openedx/core/lib/tests/test_request_utils.py Outdated
@robrap

robrap commented Mar 9, 2022

Copy link
Copy Markdown
Contributor Author

@timmc-edx: When parsing cookie logs, I found some issues. The new commit (64d1e2f) addresses some of them. I'll discuss the others separately.

@robrap
robrap force-pushed the robrap/ARCHBOM-2055-update-cookie-logging branch from 64d1e2f to 8fd3cb5 Compare March 9, 2022 19:36
@robrap
robrap force-pushed the robrap/ARCHBOM-2055-update-cookie-logging branch from 8fd3cb5 to 0d210e0 Compare March 9, 2022 21:43
Contains a number of cookie monitoring changes.

Enhancements:
- Add sampling capability for cookie logging on headers
 smaller than the threshold. For details, see
 COOKIE_SAMPLING_REQUEST_COUNT.
- Add cookie header size to log message.
- Sort logged cookies starting with largest cookie.
- Move logging from Middleware request processing
 to response processing to ensure the user id is
 available for logging for authenticated calls.
- Added cookies.header.size.computed to check
 if there are any large hidden duplicate cookies.
 Can be compared against the cookies.header.size
 custom attribute.
- Add delimiters into logs to make it simpler to parse
 when the logging tools accidentally exports multiple
 log lines together.

Removed:
- Legacy cookie capture code. This code was dangerous to
  to enable and provided more limited insight than the
  newer logging, so this was removed to simplify the code.

Other refactors:
- Switched Middleware to use new Django format, rather
 than the Mixin.
- Moved tests to its own test class. Note: this
 middleware is likely to move to a separate
 library.

ARCHBOM-2055
@robrap
robrap force-pushed the robrap/ARCHBOM-2055-update-cookie-logging branch from b216817 to 29e5071 Compare March 10, 2022 01:39
@robrap
robrap merged commit 3065048 into master Mar 10, 2022
@robrap
robrap deleted the robrap/ARCHBOM-2055-update-cookie-logging branch March 10, 2022 14:28
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

3 participants