From 689d4ba2adc05b2abc4baf7c989d3fa48b5d06ee Mon Sep 17 00:00:00 2001 From: Ashhar Hasan Date: Tue, 12 Sep 2023 18:13:27 +0530 Subject: [PATCH] Revert "Add support for OpenTelemetry in JDBC connectors" This reverts commit 7b269fac5c9056c42f7d0ea713a05ec11a508036. We've observed NullPointerException being thrown like: Error listing schemas for catalog bootcamppostgresql: java.lang.NullPointerException: Cannot invoke "java.sql.Connection.getMetaData()" because "connection" is null. The error comes from OpenTelemetry code https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/9cf710f17c028d017ae0520d595ef72b9917e241/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcUtils.java#L102. After a proper fix is available the reverted commit can be reintroduced. --- plugin/trino-base-jdbc/pom.xml | 11 -- .../plugin/jdbc/DriverConnectionFactory.java | 19 +-- .../plugin/jdbc/JdbcConnectorFactory.java | 2 - .../trino/plugin/jdbc/TracingDataSource.java | 124 ------------------ .../jdbc/TestJdbcConnectionCreation.java | 3 +- .../io/trino/plugin/jdbc/TestingDatabase.java | 3 +- .../clickhouse/ClickHouseClientModule.java | 5 +- .../plugin/druid/DruidJdbcClientModule.java | 6 +- .../plugin/example/ExampleClientModule.java | 5 +- .../plugin/ignite/IgniteClientModule.java | 11 +- .../plugin/mariadb/MariaDbClientModule.java | 5 +- .../trino/plugin/mysql/MySqlClientModule.java | 6 +- .../plugin/oracle/OracleClientModule.java | 6 +- .../plugin/phoenix5/PhoenixClientModule.java | 6 +- .../phoenix5/PhoenixConnectorFactory.java | 2 - .../PostgreSqlConnectionFactoryModule.java | 5 +- .../TestPostgreSqlJdbcConnectionCreation.java | 3 +- .../plugin/redshift/RedshiftClientModule.java | 6 +- .../singlestore/SingleStoreClientModule.java | 6 +- .../sqlserver/SqlServerClientModule.java | 15 +-- 20 files changed, 31 insertions(+), 218 deletions(-) delete mode 100644 plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/TracingDataSource.java diff --git a/plugin/trino-base-jdbc/pom.xml b/plugin/trino-base-jdbc/pom.xml index 085dc82295e01..c44b16923f2b6 100644 --- a/plugin/trino-base-jdbc/pom.xml +++ b/plugin/trino-base-jdbc/pom.xml @@ -83,11 +83,6 @@ units - - io.opentelemetry.instrumentation - opentelemetry-jdbc - - io.trino trino-cache @@ -134,12 +129,6 @@ jmxutils - - io.opentelemetry - opentelemetry-api - provided - - io.trino trino-spi diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DriverConnectionFactory.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DriverConnectionFactory.java index 4c6bcae53c869..58f40a2561083 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DriverConnectionFactory.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DriverConnectionFactory.java @@ -13,7 +13,6 @@ */ package io.trino.plugin.jdbc; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.credential.CredentialPropertiesProvider; import io.trino.plugin.jdbc.credential.CredentialProvider; import io.trino.plugin.jdbc.credential.DefaultCredentialPropertiesProvider; @@ -35,7 +34,6 @@ public class DriverConnectionFactory private final String connectionUrl; private final Properties connectionProperties; private final CredentialPropertiesProvider credentialPropertiesProvider; - private final TracingDataSource dataSource; public DriverConnectionFactory(Driver driver, BaseJdbcConfig config, CredentialProvider credentialProvider) { @@ -47,27 +45,16 @@ public DriverConnectionFactory(Driver driver, BaseJdbcConfig config, CredentialP public DriverConnectionFactory(Driver driver, String connectionUrl, Properties connectionProperties, CredentialProvider credentialProvider) { - this(driver, connectionUrl, connectionProperties, new DefaultCredentialPropertiesProvider(credentialProvider), OpenTelemetry.noop()); + this(driver, connectionUrl, connectionProperties, new DefaultCredentialPropertiesProvider(credentialProvider)); } - public DriverConnectionFactory(Driver driver, String connectionUrl, Properties connectionProperties, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) - { - this(driver, connectionUrl, connectionProperties, new DefaultCredentialPropertiesProvider(credentialProvider), openTelemetry); - } - - public DriverConnectionFactory( - Driver driver, - String connectionUrl, - Properties connectionProperties, - CredentialPropertiesProvider credentialPropertiesProvider, - OpenTelemetry openTelemetry) + public DriverConnectionFactory(Driver driver, String connectionUrl, Properties connectionProperties, CredentialPropertiesProvider credentialPropertiesProvider) { this.driver = requireNonNull(driver, "driver is null"); this.connectionUrl = requireNonNull(connectionUrl, "connectionUrl is null"); this.connectionProperties = new Properties(); this.connectionProperties.putAll(requireNonNull(connectionProperties, "connectionProperties is null")); this.credentialPropertiesProvider = requireNonNull(credentialPropertiesProvider, "credentialPropertiesProvider is null"); - this.dataSource = new TracingDataSource(requireNonNull(openTelemetry, "openTelemetry is null"), driver, connectionUrl); } @Override @@ -75,7 +62,7 @@ public Connection openConnection(ConnectorSession session) throws SQLException { Properties properties = getCredentialProperties(session.getIdentity()); - Connection connection = dataSource.getConnection(properties); + Connection connection = driver.connect(connectionUrl, properties); checkState(connection != null, "Driver returned null connection, make sure the connection URL '%s' is valid for the driver %s", connectionUrl, driver); return connection; } diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcConnectorFactory.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcConnectorFactory.java index 6b0d90082c70d..29f3df70cf876 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcConnectorFactory.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcConnectorFactory.java @@ -16,7 +16,6 @@ import com.google.inject.Injector; import com.google.inject.Module; import io.airlift.bootstrap.Bootstrap; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.base.CatalogName; import io.trino.spi.NodeManager; import io.trino.spi.VersionEmbedder; @@ -62,7 +61,6 @@ public Connector create(String catalogName, Map requiredConfig, binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()), binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()), binder -> binder.bind(VersionEmbedder.class).toInstance(context.getVersionEmbedder()), - binder -> binder.bind(OpenTelemetry.class).toInstance(context.getOpenTelemetry()), binder -> binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName)), new JdbcModule(), module); diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/TracingDataSource.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/TracingDataSource.java deleted file mode 100644 index c9a1a91dca7fb..0000000000000 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/TracingDataSource.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.trino.plugin.jdbc; - -import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.jdbc.datasource.OpenTelemetryDataSource; - -import javax.sql.DataSource; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.SQLException; -import java.util.Properties; -import java.util.logging.Logger; - -import static java.util.Objects.requireNonNull; - -public class TracingDataSource -{ - private final OpenTelemetry openTelemetry; - private final Driver driver; - private final String connectionUrl; - - public TracingDataSource(OpenTelemetry openTelemetry, Driver driver, String connectionUrl) - { - this.openTelemetry = requireNonNull(openTelemetry, "openTelemetry is null"); - this.driver = requireNonNull(driver, "driver is null"); - this.connectionUrl = requireNonNull(connectionUrl, "connectionUrl is null"); - } - - public Connection getConnection(Properties properties) - throws SQLException - { - DataSource dataSource = new JdbcDataSource(driver, connectionUrl, properties); - try (OpenTelemetryDataSource openTelemetryDataSource = new OpenTelemetryDataSource(dataSource, openTelemetry)) { - return openTelemetryDataSource.getConnection(); - } - catch (Exception e) { - throw new SQLException(e); - } - } - - private static class JdbcDataSource - implements DataSource - { - private final Driver driver; - private final String connectionUrl; - private final Properties properties; - - public JdbcDataSource(Driver driver, String connectionUrl, Properties properties) - { - this.driver = requireNonNull(driver, "driver is null"); - this.connectionUrl = requireNonNull(connectionUrl, "connectionUrl is null"); - this.properties = requireNonNull(properties, "properties is null"); - } - - @Override - public Connection getConnection() - throws SQLException - { - return driver.connect(connectionUrl, properties); - } - - @Override - public Connection getConnection(String username, String password) - { - throw new UnsupportedOperationException(); - } - - @Override - public PrintWriter getLogWriter() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setLogWriter(PrintWriter out) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setLoginTimeout(int seconds) - { - throw new UnsupportedOperationException(); - } - - @Override - public int getLoginTimeout() - { - throw new UnsupportedOperationException(); - } - - @Override - public Logger getParentLogger() - { - throw new UnsupportedOperationException(); - } - - @Override - public T unwrap(Class iface) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isWrapperFor(Class iface) - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectionCreation.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectionCreation.java index a31a026eb1059..f2969e99c68ec 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectionCreation.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectionCreation.java @@ -19,7 +19,6 @@ import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.Singleton; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.base.mapping.IdentifierMapping; import io.trino.plugin.jdbc.credential.EmptyCredentialProvider; import io.trino.testing.QueryRunner; @@ -47,7 +46,7 @@ protected QueryRunner createQueryRunner() throws Exception { String connectionUrl = createH2ConnectionUrl(); - DriverConnectionFactory delegate = new DriverConnectionFactory(new Driver(), connectionUrl, new Properties(), new EmptyCredentialProvider(), OpenTelemetry.noop()); + DriverConnectionFactory delegate = new DriverConnectionFactory(new Driver(), connectionUrl, new Properties(), new EmptyCredentialProvider()); this.connectionFactory = new ConnectionCountingConnectionFactory(delegate); return createH2QueryRunner( ImmutableList.of(NATION, REGION), diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingDatabase.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingDatabase.java index 02ec936eeb8f9..5477d8e5ba3f8 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingDatabase.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestingDatabase.java @@ -13,7 +13,6 @@ */ package io.trino.plugin.jdbc; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.credential.EmptyCredentialProvider; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorSplitSource; @@ -46,7 +45,7 @@ public TestingDatabase() String connectionUrl = "jdbc:h2:mem:" + databaseName + ";NON_KEYWORDS=KEY,VALUE"; // key and value are reserved keywords in H2 2.x jdbcClient = new TestingH2JdbcClient( new BaseJdbcConfig(), - new DriverConnectionFactory(new Driver(), connectionUrl, new Properties(), new EmptyCredentialProvider(), OpenTelemetry.noop())); + new DriverConnectionFactory(new Driver(), connectionUrl, new Properties(), new EmptyCredentialProvider())); connection = DriverManager.getConnection(connectionUrl); connection.createStatement().execute("CREATE SCHEMA example"); diff --git a/plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClientModule.java b/plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClientModule.java index a343b3f6d9815..a203b809ebe17 100644 --- a/plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClientModule.java +++ b/plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClientModule.java @@ -20,7 +20,6 @@ import com.google.inject.Scopes; import com.google.inject.Singleton; import io.airlift.configuration.ConfigBinder; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; @@ -55,11 +54,11 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { Properties properties = new Properties(); // The connector expects byte array for FixedString and String types properties.setProperty(USE_BINARY_STRING.getKey(), "true"); - return new ClickHouseConnectionFactory(new DriverConnectionFactory(new ClickHouseDriver(), config.getConnectionUrl(), properties, credentialProvider, openTelemetry)); + return new ClickHouseConnectionFactory(new DriverConnectionFactory(new ClickHouseDriver(), config.getConnectionUrl(), properties, credentialProvider)); } } diff --git a/plugin/trino-druid/src/main/java/io/trino/plugin/druid/DruidJdbcClientModule.java b/plugin/trino-druid/src/main/java/io/trino/plugin/druid/DruidJdbcClientModule.java index b5e1f88f2939e..d90da9c3b312a 100644 --- a/plugin/trino-druid/src/main/java/io/trino/plugin/druid/DruidJdbcClientModule.java +++ b/plugin/trino-druid/src/main/java/io/trino/plugin/druid/DruidJdbcClientModule.java @@ -18,7 +18,6 @@ import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.Singleton; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -46,14 +45,13 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { Properties connectionProperties = new Properties(); return new DriverConnectionFactory( new Driver(), config.getConnectionUrl(), connectionProperties, - credentialProvider, - openTelemetry); + credentialProvider); } } diff --git a/plugin/trino-example-jdbc/src/main/java/io/trino/plugin/example/ExampleClientModule.java b/plugin/trino-example-jdbc/src/main/java/io/trino/plugin/example/ExampleClientModule.java index fc76c6f394588..328f65d1d808b 100644 --- a/plugin/trino-example-jdbc/src/main/java/io/trino/plugin/example/ExampleClientModule.java +++ b/plugin/trino-example-jdbc/src/main/java/io/trino/plugin/example/ExampleClientModule.java @@ -18,7 +18,6 @@ import com.google.inject.Scopes; import com.google.inject.Singleton; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -42,10 +41,10 @@ public void setup(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) throws SQLException { Properties connectionProperties = new Properties(); - return new DriverConnectionFactory(DriverManager.getDriver(config.getConnectionUrl()), config.getConnectionUrl(), connectionProperties, credentialProvider, openTelemetry); + return new DriverConnectionFactory(DriverManager.getDriver(config.getConnectionUrl()), config.getConnectionUrl(), connectionProperties, credentialProvider); } } diff --git a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClientModule.java b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClientModule.java index 3526f634be262..81db0757b63ec 100644 --- a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClientModule.java +++ b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClientModule.java @@ -18,7 +18,6 @@ import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.Singleton; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; @@ -29,8 +28,6 @@ import io.trino.plugin.jdbc.credential.CredentialProvider; import org.apache.ignite.IgniteJdbcThinDriver; -import java.util.Properties; - import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder; import static io.airlift.configuration.ConfigBinder.configBinder; import static io.trino.plugin.jdbc.JdbcModule.bindTablePropertiesProvider; @@ -51,13 +48,11 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { return new DriverConnectionFactory( new IgniteJdbcThinDriver(), - config.getConnectionUrl(), - new Properties(), - credentialProvider, - openTelemetry); + config, + credentialProvider); } } diff --git a/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClientModule.java b/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClientModule.java index c516a8ee9195f..dea89f09351db 100644 --- a/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClientModule.java +++ b/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClientModule.java @@ -18,7 +18,6 @@ import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.Singleton; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; @@ -50,9 +49,9 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { - return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), getConnectionProperties(), credentialProvider, openTelemetry); + return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), getConnectionProperties(), credentialProvider); } private static Properties getConnectionProperties() diff --git a/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClientModule.java b/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClientModule.java index 46dd48b5e9c2b..5a13fe34e43cf 100644 --- a/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClientModule.java +++ b/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClientModule.java @@ -19,7 +19,6 @@ import com.google.inject.Singleton; import com.mysql.cj.jdbc.Driver; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; @@ -56,15 +55,14 @@ protected void setup(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, MySqlConfig mySqlConfig, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, MySqlConfig mySqlConfig) throws SQLException { return new DriverConnectionFactory( new Driver(), config.getConnectionUrl(), getConnectionProperties(mySqlConfig), - credentialProvider, - openTelemetry); + credentialProvider); } public static Properties getConnectionProperties(MySqlConfig mySqlConfig) diff --git a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java index 118c8728299a6..ea626b8eae64b 100644 --- a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java +++ b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClientModule.java @@ -19,7 +19,6 @@ import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.Singleton; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -58,7 +57,7 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory connectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OracleConfig oracleConfig, OpenTelemetry openTelemetry) + public static ConnectionFactory connectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OracleConfig oracleConfig) throws SQLException { Properties connectionProperties = new Properties(); @@ -79,7 +78,6 @@ public static ConnectionFactory connectionFactory(BaseJdbcConfig config, Credent new OracleDriver(), config.getConnectionUrl(), connectionProperties, - credentialProvider, - openTelemetry)); + credentialProvider)); } } diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java index d7f653d097730..696aaca6ce3c9 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java @@ -19,7 +19,6 @@ import com.google.inject.Scopes; import com.google.inject.Singleton; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata; import io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider; import io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider; @@ -168,7 +167,7 @@ private void checkConfiguration(String connectionUrl) @Provides @Singleton @ForBaseJdbc - public ConnectionFactory getConnectionFactory(PhoenixConfig config, OpenTelemetry openTelemetry) + public ConnectionFactory getConnectionFactory(PhoenixConfig config) throws SQLException { return new ConfiguringConnectionFactory( @@ -176,8 +175,7 @@ public ConnectionFactory getConnectionFactory(PhoenixConfig config, OpenTelemetr PhoenixDriver.INSTANCE, // Note: for some reason new PhoenixDriver won't work. config.getConnectionUrl(), getConnectionProperties(config), - new EmptyCredentialProvider(), - openTelemetry), + new EmptyCredentialProvider()), connection -> { // Per JDBC spec, a Driver is expected to have new connections in auto-commit mode. // This seems not to be true for PhoenixDriver, so we need to be explicit here. diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConnectorFactory.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConnectorFactory.java index da46fa3a21273..5e27a1d6e242e 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConnectorFactory.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConnectorFactory.java @@ -16,7 +16,6 @@ import com.google.inject.Injector; import io.airlift.bootstrap.Bootstrap; import io.airlift.json.JsonModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.base.CatalogName; import io.trino.spi.NodeManager; import io.trino.spi.classloader.ThreadContextClassLoader; @@ -61,7 +60,6 @@ public Connector create(String catalogName, Map requiredConfig, binder.bind(ClassLoader.class).toInstance(PhoenixConnectorFactory.class.getClassLoader()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); - binder.bind(OpenTelemetry.class).toInstance(context.getOpenTelemetry()); }); Injector injector = app diff --git a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlConnectionFactoryModule.java b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlConnectionFactoryModule.java index 9faa4c0c71fd5..84dab79e42fd9 100644 --- a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlConnectionFactoryModule.java +++ b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlConnectionFactoryModule.java @@ -17,7 +17,6 @@ import com.google.inject.Provides; import com.google.inject.Singleton; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -38,10 +37,10 @@ public void setup(Binder binder) {} @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider, OpenTelemetry openTelemetry) + public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { Properties connectionProperties = new Properties(); connectionProperties.put(REWRITE_BATCHED_INSERTS.getName(), "true"); - return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), connectionProperties, credentialProvider, openTelemetry); + return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), connectionProperties, credentialProvider); } } diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java index fb0803c9b1852..236d551f406d6 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java @@ -19,7 +19,6 @@ import com.google.inject.Provides; import com.google.inject.Singleton; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConnectionCreationTest; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -62,7 +61,7 @@ protected QueryRunner createQueryRunner() CredentialProvider credentialProvider = new StaticCredentialProvider( Optional.of(postgreSqlServer.getUser()), Optional.of(postgreSqlServer.getPassword())); - DriverConnectionFactory delegate = new DriverConnectionFactory(new Driver(), postgreSqlServer.getJdbcUrl(), connectionProperties, credentialProvider, OpenTelemetry.noop()); + DriverConnectionFactory delegate = new DriverConnectionFactory(new Driver(), postgreSqlServer.getJdbcUrl(), connectionProperties, credentialProvider); this.connectionFactory = new ConnectionCountingConnectionFactory(delegate); return createPostgreSqlQueryRunner(postgreSqlServer, ImmutableList.of(NATION, REGION), connectionFactory); } diff --git a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClientModule.java b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClientModule.java index 983585b4fe32d..35dc0ed8e58b0 100644 --- a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClientModule.java +++ b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClientModule.java @@ -18,7 +18,6 @@ import com.google.inject.Provides; import com.google.inject.Singleton; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; @@ -57,13 +56,12 @@ public void setup(Binder binder) @ForBaseJdbc public static ConnectionFactory getConnectionFactory( BaseJdbcConfig config, - CredentialProvider credentialProvider, - OpenTelemetry openTelemetry) + CredentialProvider credentialProvider) { Properties properties = new Properties(); properties.put("reWriteBatchedInserts", "true"); properties.put("reWriteBatchedInsertsSize", "512"); - return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), properties, credentialProvider, openTelemetry); + return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), properties, credentialProvider); } } diff --git a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClientModule.java b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClientModule.java index 95e72cc6b0592..23fe707d3b83a 100644 --- a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClientModule.java +++ b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClientModule.java @@ -19,7 +19,6 @@ import com.google.inject.Scopes; import com.google.inject.Singleton; import com.singlestore.jdbc.Driver; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DecimalModule; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -50,7 +49,7 @@ public void configure(Binder binder) @Provides @Singleton @ForBaseJdbc - public static ConnectionFactory createConnectionFactory(SingleStoreJdbcConfig config, CredentialProvider credentialProvider, SingleStoreConfig singleStoreConfig, OpenTelemetry openTelemetry) + public static ConnectionFactory createConnectionFactory(SingleStoreJdbcConfig config, CredentialProvider credentialProvider, SingleStoreConfig singleStoreConfig) { Properties connectionProperties = new Properties(); // we don't want to interpret tinyInt type (with cardinality as 2) as boolean/bit @@ -62,7 +61,6 @@ public static ConnectionFactory createConnectionFactory(SingleStoreJdbcConfig co new Driver(), config.getConnectionUrl(), connectionProperties, - credentialProvider, - openTelemetry); + credentialProvider); } } diff --git a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClientModule.java b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClientModule.java index 04dda541845a3..c0b2f399a581d 100644 --- a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClientModule.java +++ b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClientModule.java @@ -20,7 +20,6 @@ import com.google.inject.Singleton; import com.microsoft.sqlserver.jdbc.SQLServerDriver; import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.opentelemetry.api.OpenTelemetry; import io.trino.plugin.jdbc.BaseJdbcConfig; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.DriverConnectionFactory; @@ -34,8 +33,6 @@ import io.trino.plugin.jdbc.ptf.Query; import io.trino.spi.function.table.ConnectorTableFunction; -import java.util.Properties; - import static com.google.inject.multibindings.Multibinder.newSetBinder; import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder; import static io.airlift.configuration.ConditionalModule.conditionalModule; @@ -71,16 +68,8 @@ protected void setup(Binder binder) public static ConnectionFactory getConnectionFactory( BaseJdbcConfig config, SqlServerConfig sqlServerConfig, - CredentialProvider credentialProvider, - OpenTelemetry openTelemetry) + CredentialProvider credentialProvider) { - return new SqlServerConnectionFactory( - new DriverConnectionFactory( - new SQLServerDriver(), - config.getConnectionUrl(), - new Properties(), - credentialProvider, - openTelemetry), - sqlServerConfig.isSnapshotIsolationDisabled()); + return new SqlServerConnectionFactory(new DriverConnectionFactory(new SQLServerDriver(), config, credentialProvider), sqlServerConfig.isSnapshotIsolationDisabled()); } }