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

fix: Delete invocation_id log field when streaming plugins logs #366

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

erezrokah
Copy link
Member

@erezrokah erezrokah commented Jul 19, 2024

Summary

Part of cloudquery/cloudquery#18443. Both CLI and plugins add the invocation ID field to the log.
When the CLI invokes plugins it streams their logs into its own log so it all shows up in the same file.
This happens here

if err := json.Unmarshal(line, &structuredLogLine); err != nil {

We parse the log line as JSON, then log it with the CLI logger.
zerolog doesn't remove duplicate fields (see https://github.com/rs/zerolog?tab=readme-ov-file#field-duplication ) we need to remove the duplicate ourselves (similar to level).
Please note that the duplicates only show up when passing --log-format json as it seems the text format does remove duplicates (zerolog saves the message to be printed internally in JSON format so probably the conversion to text removes the duplicate somewhere, didn't bother to check).

CLI PR in cloudquery/cloudquery#18641


Use the following steps to ensure your PR is ready to be reviewed

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt ./... to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests 🧪
  • Ensure the status checks below are successful ✅

@erezrokah erezrokah added the automerge Add to automerge PRs once requirements are met label Jul 19, 2024
@kodiakhq kodiakhq bot merged commit 148b167 into main Jul 19, 2024
10 checks passed
@kodiakhq kodiakhq bot deleted the fix/delete_plugin_invocation_id branch July 19, 2024 16:13
@github-actions github-actions bot added fix and removed fix labels Jul 19, 2024
kodiakhq bot pushed a commit that referenced this pull request Jul 19, 2024
🤖 I have created a release *beep* *boop*
---


## [1.20.7](v1.20.6...v1.20.7) (2024-07-19)


### Bug Fixes

* Delete `invocation_id` log field when streaming plugins logs ([#366](#366)) ([148b167](148b167))
* **deps:** Update module github.com/cloudquery/cloudquery-api-go to v1.12.3 ([#364](#364)) ([28fae3f](28fae3f))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Jul 22, 2024
…#18641)

#### Summary

Fixes #18443
Also needs cloudquery/plugin-pb-go#366 so the field isn't duplicated in JSON logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to automerge PRs once requirements are met fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants