feat: Add custom attribute for cookie header size#28890
Merged
Conversation
jinder1s
approved these changes
Sep 30, 2021
timmc-edx
reviewed
Sep 30, 2021
openedx/core/lib/request_utils.py
Outdated
| """ | ||
|
|
||
| if request.META.get('HTTP_COOKIE', None): | ||
| set_custom_attribute('cookies.header.size', len(request.META['HTTP_COOKIE'].encode('utf-8'))) |
Contributor
There was a problem hiding this comment.
Out of curiosity, why the encode call? I guess that's measure bytes rather than characters?
jinder1s
approved these changes
Sep 30, 2021
|
Your PR has finished running tests. There were no failures. |
Contributor
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
Contributor
|
EdX Release Notice: This PR has been deployed to the production environment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Report the total size of request cookie headers as a custom attribute to New Relic to provide observability into when cookie headers are reaching size limits. Calculated by getting the byte size of request.META['HTTP_COOKIE'], which is the raw string that eventually gets parsed into request.COOKIES (see https://github.com/django/django/blob/2fcafd169b5fcf4bb6711ca8aa4d59d80225ec7a/django/core/handlers/wsgi.py#L135)
The total size ends up being about ~100B more than just adding all the names and values in request.COOKIES, which makes sense considering the string representation has extra semi colons and quotation marks and other delineators.
Update description of CAPTURE_COOKIE_SIZE toggle to specify that it enables more detailed reporting than just the total size
Deadline
None