Better locals data, and truncation improvements #922
Merged
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.
Improvements related to: #117
Previously, locals were added to the payload by calling
#to_s
on each object. With this update, hashes and arrays are traversed. Then all types except strings and immediates are exported using#inspect
. (Sending the object itself to the serializer can result in large recursive expansions after truncation has already run. Other export options could be#to_s
,#to_h
, and#as_json
. Several of these will omit the class name, or are not implemented for many types.)#inspect
has the advantage that it is specifically intended for debugging output. If the user wants more or different information in the payload about a specific type, #inspect is the correct place to implement it. Likewise the default implementation of#inspect
for any type should already be oriented toward usefulness in debugging.Because
#inspect
outputs a string, it can be handled well by the string truncation strategy for large payloads.Truncation improvements
The Frames and Strings strategies are designed to preserve as much data as possible. However if these fail, the remaining strategies can have a severe impact on the usefulness of the payload. It is better to let the Frames and Strings strategies be more aggressive and avoid the later strategies.