feat(postgres): Log table name with pg errors#5552
Merged
kodiakhq[bot] merged 3 commits intocloudquery:mainfrom Dec 12, 2022
Merged
feat(postgres): Log table name with pg errors#5552kodiakhq[bot] merged 3 commits intocloudquery:mainfrom
kodiakhq[bot] merged 3 commits intocloudquery:mainfrom
Conversation
erezrokah
commented
Dec 12, 2022
7a53bcc to
f35d199
Compare
| } | ||
| atomic.AddUint64(&c.metrics.Errors, 1) | ||
| c.logger.Error().Err(err).Msgf("failed to execute batch with pgerror") | ||
| c.logger.Error().Err(&pgErrorWrap{PgError: pgErr}).Msg("failed to execute batch with pgerror") |
Contributor
There was a problem hiding this comment.
Suggested change
| c.logger.Error().Err(&pgErrorWrap{PgError: pgErr}).Msg("failed to execute batch with pgerror") | |
| c.logger.Error().Err(err).Str("table", table.Name).Msg("failed to execute batch with pgerror") |
Would something like this not achieve the goal of adding the table name to the error log?
Member
Author
There was a problem hiding this comment.
I don't think so, as we only send the batch if batch.Len() >= c.batchSize so if we take the table name from the loop it will print the last table and not necessarily the one generated the error.
But I'll add the table name as a log field instead of a string
Contributor
There was a problem hiding this comment.
Ah okay I see - but yeah having it as a log field sounds good 👍
f35d199 to
394f9cd
Compare
hermanschaaf
approved these changes
Dec 12, 2022
kodiakhq bot
pushed a commit
that referenced
this pull request
Dec 13, 2022
🤖 I have created a release *beep* *boop* --- ## [1.8.0](plugins-destination-postgresql-v1.7.17...plugins-destination-postgresql-v1.8.0) (2022-12-13) ### Features * **postgres:** Log table name with pg errors ([#5552](#5552)) ([ee90823](ee90823)) ### Bug Fixes * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.11.1 ([#5458](#5458)) ([58b7432](58b7432)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.11.2 ([#5497](#5497)) ([c1876cf](c1876cf)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.12.0 ([#5539](#5539)) ([fb71293](fb71293)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
yevgenypats
pushed a commit
that referenced
this pull request
Dec 13, 2022
#### Summary The `Error() string` method of `PgError` doesn't return the table name. This PR ensures we log the table name with the error reported: https://github.com/jackc/pgconn/blob/4c048d40d859bbb702bff9b46cfefd44b89d82c1/errors.go#L52 <!--
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The
Error() stringmethod ofPgErrordoesn't return the table name. This PR ensures we log the table name with the error reported:https://github.com/jackc/pgconn/blob/4c048d40d859bbb702bff9b46cfefd44b89d82c1/errors.go#L52