sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Issue with the p6spy's PreparedStatementWrapper

Open Akil17 opened this issue 1 year ago • 4 comments

Integration

sentry

Java Version

21

Version

7.1.0

Steps to Reproduce

The toString() method of PreparedStatementWrapper in p6spy doesn't return the SQL query in the same format as PreparedStatement's toString() method does. I require an alternative solution because p6spy is no longer actively maintained, and I need to retrieve the generated query for subsequent processing.

Find more details here.

Expected Result

Actual generated query.

Actual Result

Object ID like this: com.p6spy.engine.wrapper.PreparedStatementWrapper@7b30fd4a

Akil17 avatar Feb 24 '24 05:02 Akil17

Thanks for opening this issue @Akil17 we currently don't know of any replacement library for p6spy. We also have https://github.com/getsentry/sentry-java/issues/3179

adinauer avatar Feb 26 '24 08:02 adinauer

We just discussed and what you could try is opening a PR in p6spy repo to forward .toString() in PreparedStatementWrapper to the delegate PreparedStatement. Not sure if they still merge PR's or do releases tho.

After reading your Stackoverflow post, maybe you could modify the query before it's converted to a PreparedStatement. Maybe your SQL library offers something for pagination.

For future maybe https://github.com/r2dbc/r2dbc-proxy could be used but we need to investigate how many dependencies this drags in, whether it actually works for us and whether we can have some hook to extract query etc.

adinauer avatar Feb 26 '24 13:02 adinauer

@adinauer I appreciate your response.

I can make the change, but I am not certain if the PR will ever get merged.

Regarding the second point, I can't modify the query before it's converted to a PreparedStatement as it sets values in the query. Additionally, my use-case is not limited to pagination; there are other analytics-related use-cases as well where we do need an actual query.

I would suggest Sentry can maintain its own p6spy branch if possible and by default add that as a dependency in the BE SDKs.

Akil17 avatar Feb 26 '24 15:02 Akil17

I would suggest Sentry can maintain its own p6spy branch if possible and by default add that as a dependency in the BE SDKs.

If more problems with p6spy come up, we can consider this. At the moment there are no plans to do so.

Maybe the quickes way to solve your problem is to fork p6spy, make your changes and use your own version.

adinauer avatar Feb 27 '24 07:02 adinauer