-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
OpenTelemetry JDBC instrumentation - fix Oracle and DB2 in native mode #28921
OpenTelemetry JDBC instrumentation - fix Oracle and DB2 in native mode #28921
Conversation
/cc @brunobat, @radcortez |
Could you have a look @Sanne, please? |
This comment has been minimized.
This comment has been minimized.
(Windows) failures are not related. |
Interesting, unfortunately my options are limited as the Oracle driver is not open source. In general I would suggest to not rely on the Would that be possible? It also happens to solve this issue, but I also believe it would be better overall. |
OpenTelemetry driver is relying on DriverManager https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java#L103 and do not offer other way to set drivers, so there are 2 ways we can work around this:
Registering Oracle driver for now and opening issue in OT (yet to do) felt like the easiest way to work around the issue. |
I am also -1 for this unless there is absolutely no other way to go about it. @radcortez @brunobat can't we contribute something to OTel around this? |
This might indeed be our only option though. Anyone knows why it's a problem specific for Oracle and why we shuouldn't register all drivers on |
We can undoubtedly contribute something to OTel. We did that in the past successfully. |
|
Hey @brunobat & @radcortez , I hope I didn't block solution with this PR - e.g. hope you don't wait for me. Here is my suggestion: I'll open an issue in OpenTelemetry and also provide a PR that close it. The issue should allow us to register drivers without I propose it takes a while to get this fixed in OT and get it released, so it would be nice to have workaround till then. This PR does that, should you prefer different one, please, bring it on! |
Hi @michalvavrik, |
Yeah, but that will mean 3 new IT modules, right? (fine with me, just checking).
I checked manually https://github.com/michalvavrik/quarkus-native-oracle-otel-reproducer and PG and MariaDB are fine, which confuses me heavily as they all (including OracleDriver) works pretty same way - register themselves in static initializer block. Not sure what's different and will try to identify exact reason, but avoiding DriverManager still seems like a good way around this (with OT PR).
Thank you, I opened an issue open-telemetry/opentelemetry-java-instrumentation#7028 and will draft a PR over weekend and ask you for review/kindly provide help if I go in a wrong direction etc. |
We can go with TestContainers and have just one JDBC Driver related project with different test classes. One different test resource for each test class: https://quarkus.io/guides/getting-started-testing#quarkus-test-resource
|
2bb9acc
to
878b15c
Compare
Thanks, done. |
878b15c
to
81bd209
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good @michalvavrik. Thanks very much.
Left a small comment.
6f60c12
to
94aebd0
Compare
This comment has been minimized.
This comment has been minimized.
Thanks, help really appreciated! I can see you added it to OT module, I'm really interested whether I could reproduce without OT, but I'm busy today. Let me have a look next week, or if you submit Quarkus PR, I will test it ex post. |
I'll let you run with it. |
e5120d9
to
01547ca
Compare
fyi @jerboaa - the issue is not related to OT, but comes from combination of |
This comment has been minimized.
This comment has been minimized.
Quarkus QE experienced exactly same native build failures as described above, logs are here https://github.com/quarkus-qe/quarkus-test-suite/actions/runs/3814140863/jobs/6488338890; I verified it's fixed by this PR too. I won't open an issue as there is a chance that @brunobat will review this PR and we can have it fixed in no time; in case that's a false hope, I'll open an issue later this week. |
I checked out the PR and executed the db tests in my M1, in native mode and they pass... |
I think so, thank you for checking. Please review the PR (or merge it) when times is right for you. I'm sure you've got a lot to catch up after holidays period. Thank you very much. |
What's the status of this one? |
I guess we are waiting for additional reviewers. |
@gsmet needs to review it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added one small question for something I don't understand fully. Could you check?
.../jdbc/jdbc-db2/deployment/src/main/java/io/quarkus/jdbc/db2/deployment/JDBCDB2Processor.java
Show resolved
Hide resolved
Fixes native build when `jdbc-oracle` is combined with `jdbc-db2`. This fix was kindly provided Severin Gehwolf and is added as second commit of this PR as 1. integration tests need the fix 2. no point of creating additional integration test module that combines jdbc-oracle and jdbc-db2 as we already have them here.
01547ca
to
24735ab
Compare
Rebased the PR to resolve merge conflicts. No changes made, still waiting for the review. |
fixes: #28915
fixes: #30176
Oracle driver is not registered with DriverManager in native mode. When Oracle driver is used directly, e.g. by Agroal here it's not a problem, however OpenTelemetry driver uses
DriverManager
and thus the Oracle driver is missing. I wonder if we should initialize it at runtime, however there is a warning inOracleMetadataOverrides
that deferred me from doing it. Instead, this PR register driver whenquarkus-oracle-jdbc
extension is used together with OpenTelemetry extension. Way I understandjava.sql.DriverManager#registerDriver(java.sql.Driver)
implementation, it's simply ignored if the driver is already there, however it would be nice to find better way in the future (or now if you have one!).DB2 driver wasn't registered for reflection when used with OT driver as then Agroal registered OT driver and not DB2 driver in native mode.