Skip to content
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

Don't escape / in StackdriverApplicationLogger logs and optionally in other JSON #61

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

acoulton
Copy link
Member

Reduce the payload size on the wire for the JSON StackdriverApplicationLogger entries, by avoiding the redundant encoding of / as \/ in the output.

Additionally, provide an escaped_slashes option to JSON::encode (defaulting true to match current behaviour) to allow for not escaping slashes in application-generated JSON.

…tionLogger

The logs contain fairly regular occurrences of `/` in URLs, file paths, etc.
By default PHP json_encode will encode these as `\/` but this is not required
by the JSON spec.

Use JSON_UNESCAPED_SLASHES to leave these as-is which will slightly reduce the
size of the encoded payloads over the wire. Should not affect any JSON-compliant
parser, so this is not a breaking change.
By default, we'll continue to escape them for backwards compatibility
(primarily if e.g. consuming projects have got tests for the explicit
encoded value). But provide an option for the caller to control this.
Still want to throw our own custom exception for BC, but might as well
use the native flag to catch and rethrow JSONException rather than
asserting against json_last_error_message manually.
@acoulton acoulton merged commit 9f63045 into 2.x Sep 13, 2024
4 checks passed
@acoulton acoulton deleted the 2.1-log-json-payload-size branch September 13, 2024 11:53
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