open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.79k stars 785 forks source link

Instrumentation for JDBC transaction commits #10381

Open zhenlin-pay2 opened 5 months ago

zhenlin-pay2 commented 5 months ago

Is your feature request related to a problem? Please describe.

For the database we are using in our application, SQL COMMIT commands can take as long as typical DML commands (SELECT, INSERT, UPDATE, DELETE) to execute, and in edge cases, even longer, so we need visibility into when and how long COMMIT commands are running, especially in individual traces but perhaps also in aggregate.

Describe the solution you'd like

We would like to have instrumentation for COMMIT of a similar nature to the instrumentation already provided for DML commands. For JDBC this entails adding instrumentation to the commit method of java.sql.Connection.

Describe alternatives you've considered

We tried adding java.sql.Connection[commit] to otel.instrumentation.methods.include but the results were unsatisfactory for our setup: there were two layers of proxy objects, so each COMMIT resulted in three (nested) spans in the trace.

Additional context

For symmetry, it might also be nice to have instrumentation for ROLLBACK (java.sql.Connection[rollback]) too.

tkmsaaaam commented 1 month ago

I try to contribute for this issue in the PR #11517 . So please check it.