-
Notifications
You must be signed in to change notification settings - Fork 801
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
Add support for resolving bind variables in recorded SQL statements #7413
Comments
can i use extensions to support? when replace sky agent to open-telemetry agent , I also have to face this problem |
Hey @freshgeek , |
@freshgeek I think this could be added to the existing jdbc instrumentation under an There have been discussions of adding this eventually to the specification (as an opt-in feature due to PII concerns): open-telemetry/opentelemetry-specification#3092 |
Thank you for your reply. Can you provide a simple idea or step? Thank you
Thank you for your reply. Can you provide a simple idea or step? Thank you |
this is a hack idea for Urgent need' devlepmenter:
hack code in mysql jdbc 8 :
then , build agent , replace |
Any updates? |
Hey @e-balashov , |
@freshgeek can you tell me if this worked? i.e if the bind parameters were shown in query? |
i try it at 1.30.0,it does not work. com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl@?dd8fbb |
Is it possible to support this. |
Each project environment is different, and it cannot be guaranteed that all are valid. If the official does not fix it, I can only provide my feasible example reference. If you need an agent jar, can email it |
@freshgeek We got the same error when using Oracle database with Hibernate. When I used the solution that you provided, it did not work. Could you give me some suggestions or ideas to resolve this issue?
|
I don't have the equipment or experience to use Oracle, so the logic may be similar. Find the corresponding statement to extract the code, and then replace |
Is your feature request related to a problem? Please describe.
Currently, for
PreparedStatement
the recorded SQL statement will be the parameterized SQL statement that was used i.e.When troubleshooting issues it could be useful to resolve the bind variables to provide more context i.e.
Benefits include:
a. Database engine performing bind-peeking where particular arguments can significantly affect the execution plan
b. Data distribution that significantly affects query performance
c. Database locking i.e. long running
update my_table where id = ?
vsupdate my_table where id = 10
- I can tell there's lock contention onid=10
.a. Audit history for applications that do not provide this out of box i.e. in APM backend searching for all spans that updated
my_table
with the ID9999
(this probably won't be exact i.e. not being able to know ID=9999 in the SQL but I currently use Elastic APM backend with a modification to analyzespan.db.statement
to run full text queries on it i.e.span.db.statement: "update my_table" AND span.db.statement: 9999
)b. Understanding user behavior i.e. user is updating this entity frequently (can sometimes be gleaned from other context like API URL or something but not always)
Describe the solution you'd like
An opt-in option to resolve bind variables in the recorded SQL statement, possibly conditionally i.e. based on:
<X>ms
Preferably these would be resolved inline in the SQL text rather than adding a separate span attribute for them although there's probably pros/cons to each approach.
This likely has performance (tracking and resolving binds, CPU/memory) as well as security and privacy concerns (capturing sensitive data) that need to be considered. At the very least this would be opt-in though under the appropriate circumstances. For example, I work with an application that:
Describe alternatives you've considered
Writing a custom instrumentation to handle this i.e. wrapping something like what P6Spy does
Additional context
Similar features exist in other APM agents i.e. AppDynamics and New Relic
The text was updated successfully, but these errors were encountered: