To enable trace when transaction commit or rollback in jdbc
Contribute for #10381
To enable trace when transaction commit or rollback in jdbc.
like below
There are a few things to consider with this instrumentation. Firstly it only updates the jdbc library instrumentation, ideally we'd like to have the same features in the library instrumentation and the javaagent instrumentation. Secondly the implementation assumes that calling Connection.commit() executes sql COMMIT statement, which I suspect isn't always true. It is an internal detail of the driver that depends on the database, it might as well execute COMMIT TRANSACTION instead. https://stackoverflow.com/questions/5248649/jdbc-commit-what-happens-behind-the-scenes suggests that for sql server it is executing IF @@TRANCOUNT > 0 COMMIT TRAN (note that the linked stack overflow question is quite old). If we don't know what statement is really executed perhaps we shouldn't fill db.statement at all? @trask do you any suggestions for this? Does the spec provide guidelines for something like this?
hi @tkmsaaaam! can you put this behavior behind an experimental feature flag for now, and open an issue in https://github.com/open-telemetry/semantic-conventions about how to model commit and rollback in database semantic conventions?
hi @tkmsaaaam! can you put this behavior behind an experimental feature flag for now, and open an issue in https://github.com/open-telemetry/semantic-conventions about how to model commit and rollback in database semantic conventions?
Thank you for your review. I opened the issue. https://github.com/open-telemetry/semantic-conventions/issues/1134