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

Always fall back to string payload if we can't handle structured logs #701

Merged
merged 3 commits into from
Aug 11, 2023

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Aug 8, 2023

Fixes #689

Supersedes #689

This is slightly broader in scope than #689. That PR only handled the case where we are unable to marshal the payload to JSON. It could still fail to export for other reasons, such as map keys or values containing invalid UTF-8. It could also fail if we didn't support the ValueType (e.g. ValueTypeSlice, or ValueTypeInt).

This PR changes the logs exporter to always fall back to attempting to send a raw string payload if we are unable to create a structpb.Struct from the body.

@dashpole dashpole requested a review from a team as a code owner August 8, 2023 18:20
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #701 (f7bde61) into main (0c4b0bb) will increase coverage by 0.32%.
Report is 1 commits behind head on main.
The diff coverage is 86.66%.

@@            Coverage Diff             @@
##             main     #701      +/-   ##
==========================================
+ Coverage   69.07%   69.39%   +0.32%     
==========================================
  Files          36       36              
  Lines        4740     4735       -5     
==========================================
+ Hits         3274     3286      +12     
+ Misses       1316     1298      -18     
- Partials      150      151       +1     
Files Changed Coverage Δ
exporter/collector/integrationtest/diff.go 100.00% <ø> (ø)
...er/collector/integrationtest/inmemoryocexporter.go 87.61% <ø> (ø)
...er/collector/integrationtest/protos/fixtures.pb.go 42.48% <ø> (ø)
...er/collector/integrationtest/testcases/testcase.go 81.51% <ø> (ø)
exporter/collector/logs.go 44.97% <86.66%> (+3.92%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

exporter/collector/logs.go Outdated Show resolved Hide resolved
exporter/collector/logs.go Outdated Show resolved Hide resolved
exporter/collector/logs.go Outdated Show resolved Hide resolved
@dashpole dashpole merged commit c915721 into GoogleCloudPlatform:main Aug 11, 2023
25 checks passed
@dashpole dashpole deleted the invalid_json_bytes branch August 11, 2023 16:03
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.

Exporting log records with a non-JSON Byte body fails
2 participants