Skip to content

Commit

Permalink
Removing deprecation code for 3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsoro committed Oct 17, 2024
1 parent 5c3944b commit ec57a10
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ void build(
for (AggregatedDataSourceBuildTimeConfigBuildItem aggregatedDataSourceBuildTimeConfig : aggregatedDataSourceBuildTimeConfigs) {
validateBuildTimeConfig(aggregatedDataSourceBuildTimeConfig);

if (aggregatedDataSourceBuildTimeConfig.getJdbcConfig().tracing()) {
reflectiveClass
.produce(ReflectiveClassBuildItem.builder(DataSources.TRACING_DRIVER_CLASSNAME).methods()
.build());
}

if (aggregatedDataSourceBuildTimeConfig.getJdbcConfig().telemetry()) {
otelJdbcInstrumentationActive = true;
}
Expand Down Expand Up @@ -165,14 +159,6 @@ private static void validateBuildTimeConfig(AggregatedDataSourceBuildTimeConfigB
String fullDataSourceName = aggregatedConfig.isDefault() ? "default datasource"
: "datasource named '" + aggregatedConfig.getName() + "'";

if (jdbcBuildTimeConfig.tracing()) {
if (!QuarkusClassLoader.isClassPresentAtRuntime(DataSources.TRACING_DRIVER_CLASSNAME)) {
throw new ConfigurationException(
"Unable to load the tracing driver " + DataSources.TRACING_DRIVER_CLASSNAME + " for the "
+ fullDataSourceName);
}
}

String driverName = aggregatedConfig.getResolvedDriverClass();
Class<?> driver;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ public interface DataSourceJdbcBuildTimeConfig {
*/
Optional<Boolean> enableMetrics();

/**
* Enable JDBC tracing. Disabled by default.
*/
@WithDefault("false")
boolean tracing();

/**
* Enable OpenTelemetry JDBC instrumentation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ public interface DataSourceJdbcRuntimeConfig {
@ConfigDocMapKey("property-key")
Map<String, String> additionalJdbcProperties();

/**
* Enable JDBC tracing.
*
* @deprecated in favor of OpenTelemetry {@link #telemetry()}
*/
@Deprecated(forRemoval = true, since = "3.16")
DataSourceJdbcTracingRuntimeConfig tracing();

/**
* Enable OpenTelemetry JDBC instrumentation.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.sql.Connection;
import java.sql.Driver;
import java.sql.Statement;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -68,10 +67,6 @@ public class DataSources {

private static final Logger log = Logger.getLogger(DataSources.class.getName());

public static final String TRACING_DRIVER_CLASSNAME = "io.opentracing.contrib.jdbc.TracingDriver";
private static final String JDBC_URL_PREFIX = "jdbc:";
private static final String JDBC_TRACING_URL_PREFIX = "jdbc:tracing:";

private final DataSourcesBuildTimeConfig dataSourcesBuildTimeConfig;
private final DataSourcesRuntimeConfig dataSourcesRuntimeConfig;
private final DataSourcesJdbcBuildTimeConfig dataSourcesJdbcBuildTimeConfig;
Expand Down Expand Up @@ -206,45 +201,6 @@ public AgroalDataSource doCreateDataSource(String dataSourceName, boolean failIf

String jdbcUrl = dataSourceJdbcRuntimeConfig.url().get();

if (dataSourceJdbcBuildTimeConfig.tracing()) {
boolean tracingEnabled = dataSourceJdbcRuntimeConfig.tracing().enabled()
.orElse(dataSourceJdbcBuildTimeConfig.tracing());

if (tracingEnabled) {
String rootTracingUrl = !jdbcUrl.startsWith(JDBC_TRACING_URL_PREFIX)
? jdbcUrl.replace(JDBC_URL_PREFIX, JDBC_TRACING_URL_PREFIX)
: jdbcUrl;

StringBuilder tracingURL = new StringBuilder(rootTracingUrl);

if (dataSourceJdbcRuntimeConfig.tracing().traceWithActiveSpanOnly()) {
if (!tracingURL.toString().contains("?")) {
tracingURL.append("?");
}

tracingURL.append("traceWithActiveSpanOnly=true");
}

if (dataSourceJdbcRuntimeConfig.tracing().ignoreForTracing().isPresent()) {
if (!tracingURL.toString().contains("?")) {
tracingURL.append("?");
}

Arrays.stream(dataSourceJdbcRuntimeConfig.tracing().ignoreForTracing().get().split(";"))
.filter(query -> !query.isEmpty())
.forEach(query -> tracingURL.append("ignoreForTracing=")
.append(query.replaceAll("\"", "\\\""))
.append(";"));
}

// Override datasource URL with tracing driver prefixed URL
jdbcUrl = tracingURL.toString();

//remove driver class so that agroal connectionFactory will use the tracking driver anyway
driver = null;
}
}

String resolvedDbKind = matchingSupportEntry.resolvedDbKind;
AgroalConnectionConfigurer agroalConnectionConfigurer = Arc.container()
.instance(AgroalConnectionConfigurer.class, new JdbcDriverLiteral(resolvedDbKind))
Expand Down

0 comments on commit ec57a10

Please sign in to comment.