-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28921 from michalvavrik/feature/ot-jdbc-oracle-re…
…gister-driver OpenTelemetry JDBC instrumentation - fix Oracle and DB2 in native mode
- Loading branch information
Showing
33 changed files
with
1,278 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...oracle/runtime/src/main/java/io/quarkus/jdbc/oracle/runtime/graal/ObjIdSubstitutions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.jdbc.oracle.runtime.graal; | ||
|
||
import java.security.SecureRandom; | ||
|
||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.InjectAccessors; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
/** | ||
* Substitutions required when `jdbc-oracle` is combined with `jdbc-db2`. | ||
*/ | ||
@TargetClass(className = "java.rmi.server.ObjID") | ||
public final class ObjIdSubstitutions { | ||
|
||
@Alias | ||
@InjectAccessors(SecureRandomAccessor.class) | ||
private static SecureRandom secureRandom; | ||
|
||
} | ||
|
||
class SecureRandomAccessor { | ||
private static volatile SecureRandom RANDOM; | ||
|
||
static SecureRandom get() { | ||
SecureRandom result = RANDOM; | ||
if (result == null) { | ||
/* Lazy initialization on first access. */ | ||
result = initializeOnce(); | ||
} | ||
return result; | ||
} | ||
|
||
private static synchronized SecureRandom initializeOnce() { | ||
SecureRandom result = RANDOM; | ||
if (result != null) { | ||
/* Double-checked locking is OK because INSTANCE is volatile. */ | ||
return result; | ||
} | ||
|
||
result = new SecureRandom(); | ||
RANDOM = result; | ||
return result; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...java/io/quarkus/opentelemetry/deployment/OpenTelemetryDriverJdbcDataSourcesBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.quarkus.opentelemetry.deployment; | ||
|
||
import java.util.List; | ||
|
||
import io.quarkus.agroal.spi.JdbcDataSourceBuildItem; | ||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* Contains list of all {@link io.quarkus.agroal.spi.JdbcDataSourceBuildItem} using OpenTelemetryDriver. | ||
*/ | ||
public final class OpenTelemetryDriverJdbcDataSourcesBuildItem extends SimpleBuildItem { | ||
|
||
public final List<JdbcDataSourceBuildItem> jdbcDataSources; | ||
|
||
OpenTelemetryDriverJdbcDataSourcesBuildItem(List<JdbcDataSourceBuildItem> jdbcDataSources) { | ||
this.jdbcDataSources = List.copyOf(jdbcDataSources); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
integration-tests/opentelemetry-jdbc-instrumentation/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# OpenTelemetry JDBC instrumentation example | ||
|
||
## Running the tests | ||
|
||
|
||
To run the tests in a standard JVM with an Oracle, PostgreSQL and MariaDB databases started as a Docker containers, you can run the following command: | ||
|
||
``` | ||
mvn verify -Dtest-containers -Dstart-containers | ||
``` | ||
|
||
To also test as a native image, add `-Dnative`: | ||
|
||
``` | ||
mvn verify -Dtest-containers -Dstart-containers -Dnative | ||
``` | ||
|
||
You can also run tests with a specific database image, just set the following parameters: | ||
|
||
- `oracle.image` for Oracle | ||
- `postgres.image` for PostgreSQL | ||
- `mariadb.image` for MariaDB | ||
- `db2.image` for Db2 | ||
|
||
For example to run tests with the latest PostgreSQL database image, you can run the following command: | ||
|
||
``` | ||
mvn verify -Dtest-containers -Dstart-containers -Dpostgres.image=docker.io/postgres:latest | ||
``` | ||
|
||
Unfortunately booting DB2 is slow and needs to set a generous timeout, therefore the DB2 test is disabled by default. | ||
You can enable it with `enable-db2` system property like this: | ||
|
||
``` | ||
mvn verify -Dtest-containers -Dstart-containers -Denable-db2 | ||
``` |
Oops, something went wrong.