Skip to content

Log large JSON objects

What does this MR do and why?

Update Gitlab::HTTP and Gitlab::Json.parse to log JSON objects that have many objects

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Start Rails console with GITLAB_JSON_SIZE_THRESHOLD environment variable set

    GITLAB_JSON_SIZE_THRESHOLD=5 bin/rails c
  2. Parse a large JSON string

    Gitlab::Json.parse('{"key1": "value1", "key2": ["item1", "item2"], "key3": {"nested": "value"}}')
  3. Check if you see an entry in log/application_json.log

  4. Make a request using Gitlab::HTTP to an endpoint that returns a JSON response

    Gitlab::HTTP.get('https://gitlab.com/api/v4/projects').parsed_response
  5. Repeat steps 1-4 using different GITLAB_JSON_SIZE_THRESHOLD values.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading