[fix: plugin-pg] Support Query config object again #3085
Closed
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.
Fixes #3007
What does this PR do?
There are multiple formats for querying the pg client. Previously dd-trace supported all of them, but this broke in a recent refactor. The call signatures are:
(query, ...)
(query, values, ...)
(object: {}, ...)
https://node-postgres.com/features/queries
I don't totally understand what's going on with the
queryQueue
but it seems like since we set the query as a let we are anticipating the object might get shoved onto a queue. This means we need to copy the full arguments object to initially log it and then to later apply it (i.e. just copying the query text didn't seem like enough)The bigger problem is that we have two formats for this from PG, but we are expecting one in the pg plugin itself. This could potentially be simpler if we just had that plugin check for .text on the object instead of doing it here. So feel free to take that approach too!
Motivation
This broke in 3.17 from bad code in #2938.