Don't stringify all attribute values before encoding via json.Marshal #6
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.
Hey samber. Thanks for this library – it has been very useful.
This is an attempt to fix this issue.
In the current implementation, a call such as
will send JSON like
where the
Foo
value has been stringified prior to JSON serialization. Similarly, integers and floats will appear as strings in the JSON sent to datadog.This PR passes through types which have a reasonable JSON representation without converting them to strings first. The
slog.Info
call above now sends JSON likeI've attempted to add tests which illustrate the fix and which break if the 'bug fix' commit is reverted. The test for the
Handler
is not ideal as it tests a private function, but I think it's a reasonable alternative to adding some quite complex mocking.