Skip to content

perf: improve enforce_payload_size_limit #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

miquelbeltran
Copy link
Contributor

@miquelbeltran miquelbeltran commented Jun 17, 2025

Description 📝

Purpose:

As reported internally:

I needed to initialise Raygun with config={'enforce_payload_size_limit': False})

Without this setting, I ran into internal issues with Raygun4Py in the current version (inside of its JSON handling code). I didn't investigate that further at this stage and will let [@]miquelbeltran know about the issue in the RG4Py repo.

I am not sure what exactly the error here was, but I investigated a bit and saw that the code handling the enforce_payload_size_limit was performing a deep copy of the error payload before applying the size limits:

error = jsonpickle.loads(jsonpickle.dumps(raygunMessage.get_error()))

This seems unnecessary, as we are just going to send the payload and then discard it.

Approach:

The code has been simplified, and now it uses the error payload directly:

error = raygunMessage.get_error()

However, we need to be careful with global variables.

If transmitGlobalVariables is set to true (which is default), then global variables are also included in the payload. Because the enforce_payload_size_limit logic removes them, we need to ensure those global variables are copied and not modified.

For that, we do a copy of the global variables when adding them to the error payload info:

self.globalVariables = frames[-1][0].f_globals.copy()

Note: Maybe in the context of the mentioned project, we want to use transmitGlobalVariables set to false.

Type of change

  • fix: Bug fix (non-breaking change which fixes an issue)
  • feat: New feature (non-breaking change which adds functionality)
  • chore: Chore task, release or small impact change
  • ci: CI configuration change
  • Other type of change (specify)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Updates

  • Modified the enforce_payload_size_limit handling code

Related issues

  • Internal

Test plan 🧪

Run the tests and samples to verify everything works as before

Author to check 👓

  • Project and all contained modules builds successfully
  • Self-/dev-tested
  • Unit/UI/Automation/Integration tests provided where applicable
  • Code is written to standards
  • Appropriate documentation written (code comments, internal docs)

Reviewer to check ✔️

  • Project and all contained modules builds successfully
  • Change has been dev-/reviewer-tested, where possible
  • Unit/UI/Automation/Integration tests provided where applicable
  • Code is written to standards
  • Appropriate documentation written (code comments, internal docs)

@miquelbeltran
Copy link
Contributor Author

Some tests failing, needs more research

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