diff --git a/pom.xml b/pom.xml
index dc8eafd64..759ad46a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,8 @@
5.3.2
5.3.2
1.3.7
+ 1.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
@@ -174,6 +176,16 @@
${xmlunit.version}
test
+
+ org.mule.sdk
+ mule-sdk-compatibility-api
+ ${muleSdkCompatibilityApiVersion}
+
+
+ org.mule.sdk
+ mule-sdk-api
+ ${muleSdkApiVersion}
+
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/ConnectionBasedDbConnectionTracingMetadata.java b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/ConnectionBasedDbConnectionTracingMetadata.java
new file mode 100644
index 000000000..6c12f482c
--- /dev/null
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/ConnectionBasedDbConnectionTracingMetadata.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+package org.mule.extension.db.internal.domain.connection.datasource;
+
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getHostFrom;
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getProtocolFrom;
+import static org.mule.extension.db.internal.domain.connection.datasource.NoConnectionMetadata.getMetadata;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import static java.util.Optional.empty;
+import static java.util.Optional.ofNullable;
+
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.Optional;
+
+import org.slf4j.Logger;
+
+/**
+ * A {@link DbConnectionTracingMetadata} based on the connection metadata
+ */
+public class ConnectionBasedDbConnectionTracingMetadata implements DbConnectionTracingMetadata {
+
+ public static final String UNSET = "unset";
+ private static final Logger LOGGER = getLogger(ConnectionBasedDbConnectionTracingMetadata.class);
+ private final Connection connection;
+ private DatabaseMetaData metadata;
+
+ public ConnectionBasedDbConnectionTracingMetadata(Connection connection) {
+ this.connection = connection;
+ }
+
+ @Override
+ public String getDbSystem() {
+ try {
+ return getMetaData().getDatabaseProductName();
+ } catch (SQLException e) {
+ LOGGER.debug("Unable to retrieve connection metadata for tracing.", e);
+ }
+
+ return UNSET;
+ }
+
+ private DatabaseMetaData getMetaData() throws SQLException {
+ // In case the information cannot be retrieved it will not be present.
+ if (metadata == null) {
+ try {
+ metadata = connection.getMetaData();
+ } catch (Throwable e) {
+ LOGGER.debug("Unable to retrieve database metadata from connection", e);
+ metadata = getMetadata();
+ }
+
+ }
+
+ return metadata;
+ }
+
+ @Override
+ public String getConnectionString() {
+ try {
+ return getMetaData().getURL();
+ } catch (SQLException e) {
+ LOGGER.debug("Unable to retrieve connection metadata for tracing.", e);
+ }
+
+ return UNSET;
+ }
+
+ @Override
+ public String getUser() {
+ try {
+ return getMetaData().getUserName();
+ } catch (SQLException e) {
+ LOGGER.debug("Unable to retrieve connection metadata for tracing.", e);
+ }
+
+ return UNSET;
+ }
+
+ @Override
+ public Optional getPeerName() {
+ try {
+ return ofNullable(getHostFrom(getMetaData().getURL()));
+ } catch (SQLException e) {
+ LOGGER.debug("Unable to retrieve connection metadata for tracing.", e);
+ }
+
+ return empty();
+ }
+
+ @Override
+ public Optional getPeerTransport() {
+ try {
+ return ofNullable(getProtocolFrom(getMetaData().getURL()));
+ } catch (SQLException e) {
+ LOGGER.debug("Unable to retrieve connection metadata for tracing.", e);
+ }
+
+ return empty();
+ }
+}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/DbDataSourceReferenceConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/DbDataSourceReferenceConnectionProvider.java
index e0c66e3f6..a256c41b3 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/DbDataSourceReferenceConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/DbDataSourceReferenceConnectionProvider.java
@@ -12,6 +12,7 @@
import javax.sql.DataSource;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.datasource.DataSourceReferenceConnectionProvider;
import org.mule.db.commons.internal.domain.type.ResolvedDbType;
@@ -41,11 +42,12 @@ public class DbDataSourceReferenceConnectionProvider extends DataSourceReference
@Override
protected DbConnection createDbConnection(Connection connection) throws Exception {
+ DbConnectionTracingMetadata dbConnectionTracingMetadata = new ConnectionBasedDbConnectionTracingMetadata(connection);
if (isOracle(connection)) {
return new OracleDbConnection(connection, super.resolveCustomTypes(), resolvedDbTypesCache,
- super.getCacheQueryTemplateSize());
+ super.getCacheQueryTemplateSize(), dbConnectionTracingMetadata);
} else {
- return super.createDbConnection(connection);
+ return super.createDbConnection(connection, dbConnectionTracingMetadata);
}
}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/NoConnectionMetadata.java b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/NoConnectionMetadata.java
new file mode 100644
index 000000000..9404979b5
--- /dev/null
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/datasource/NoConnectionMetadata.java
@@ -0,0 +1,920 @@
+/*
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+package org.mule.extension.db.internal.domain.connection.datasource;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+
+/**
+ * A {@link DatabaseMetaData} to use when no metadata is available.
+ */
+public class NoConnectionMetadata implements DatabaseMetaData {
+
+ public static final String UNSET = "unset";
+
+ private static final NoConnectionMetadata INSTANCE = new NoConnectionMetadata();
+
+ private NoConnectionMetadata() {}
+
+ public static DatabaseMetaData getMetadata() {
+ return INSTANCE;
+ }
+
+ @Override
+ public boolean allProceduresAreCallable() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean allTablesAreSelectable() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public String getURL() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getUserName() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedHigh() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedLow() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedAtStart() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedAtEnd() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public String getDatabaseProductName() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getDatabaseProductVersion() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getDriverName() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getDriverVersion() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public int getDriverMajorVersion() {
+ return 0;
+ }
+
+ @Override
+ public int getDriverMinorVersion() {
+ return 0;
+ }
+
+ @Override
+ public boolean usesLocalFiles() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean usesLocalFilePerTable() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMixedCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesUpperCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesLowerCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesMixedCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public String getIdentifierQuoteString() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getSQLKeywords() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getNumericFunctions() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getStringFunctions() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getSystemFunctions() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getTimeDateFunctions() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getSearchStringEscape() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getExtraNameCharacters() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsColumnAliasing() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean nullPlusNonNullIsNull() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsConvert() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsConvert(int fromType, int toType) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsTableCorrelationNames() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsDifferentTableCorrelationNames() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExpressionsInOrderBy() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupBy() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupByUnrelated() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupByBeyondSelect() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsLikeEscapeClause() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleResultSets() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleTransactions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsNonNullableColumns() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMinimumSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCoreSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExtendedSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92IntermediateSQL() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92FullSQL() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsLimitedOuterJoins() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public String getSchemaTerm() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getProcedureTerm() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public String getCatalogTerm() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public boolean isCatalogAtStart() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public String getCatalogSeparator() throws SQLException {
+ return UNSET;
+ }
+
+ @Override
+ public boolean supportsSchemasInDataManipulation() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInProcedureCalls() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInTableDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInDataManipulation() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsPositionedDelete() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsPositionedUpdate() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelectForUpdate() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsStoredProcedures() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInComparisons() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInExists() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInIns() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnion() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnionAll() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public int getMaxBinaryLiteralLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxCharLiteralLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInGroupBy() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInIndex() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInOrderBy() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInSelect() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInTable() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxConnections() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxCursorNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxIndexLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxSchemaNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxProcedureNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxCatalogNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxRowSize() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public int getMaxStatementLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxStatements() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxTableNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxTablesInSelect() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getMaxUserNameLength() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getDefaultTransactionIsolation() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public boolean supportsTransactions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern,
+ String columnNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getSchemas() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getCatalogs() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getTableTypes() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog,
+ String foreignSchema, String foreignTable)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getTypeInfo() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean supportsResultSetType(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean ownUpdatesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean ownDeletesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean ownInsertsAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean othersUpdatesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean othersDeletesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean othersInsertsAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean updatesAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean deletesAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean insertsAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBatchUpdates() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean supportsSavepoints() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsNamedParameters() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleOpenResults() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGetGeneratedKeys() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean supportsResultSetHoldability(int holdability) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public int getResultSetHoldability() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getDatabaseMajorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getDatabaseMinorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getJDBCMajorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getJDBCMinorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getSQLStateType() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public boolean locatorsUpdateCopy() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean supportsStatementPooling() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public ResultSet getClientInfoProperties() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public T unwrap(Class iface) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class> iface) throws SQLException {
+ return false;
+ }
+}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnection.java b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnection.java
index 0ff903e62..bacff25e6 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnection.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnection.java
@@ -6,8 +6,11 @@
*/
package org.mule.extension.db.internal.domain.connection.derby;
+import static org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata.getNotResolvedDbConnectionTracingMetadata;
+
import org.mule.db.commons.internal.domain.connection.DefaultDbConnection;
import org.mule.db.commons.internal.domain.type.DbType;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
import java.sql.Connection;
import java.util.List;
@@ -20,7 +23,12 @@
public class DerbyConnection extends DefaultDbConnection {
DerbyConnection(Connection connection, List dbTypes, long cacheQueryTemplateSize) {
- super(connection, dbTypes, cacheQueryTemplateSize);
+ this(connection, dbTypes, cacheQueryTemplateSize, getNotResolvedDbConnectionTracingMetadata());
+ }
+
+ DerbyConnection(Connection connection, List dbTypes, long cacheQueryTemplateSize,
+ DbConnectionTracingMetadata dbConnectionTracingMetadata) {
+ super(connection, dbTypes, cacheQueryTemplateSize, dbConnectionTracingMetadata);
}
// We are disabling content streaming for Derby because of a incompatibility between the connector logic and the
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnectionProvider.java
index 6b0373094..1a762f07e 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/DerbyConnectionProvider.java
@@ -27,6 +27,7 @@
import org.mule.db.commons.internal.domain.connection.DataSourceConfig;
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.DbConnectionProvider;
+import org.mule.extension.db.internal.domain.connection.derby.tracing.DerbyDbConnectionTracingMetadata;
import org.mule.runtime.extension.api.annotation.Alias;
import org.mule.runtime.extension.api.annotation.ExternalLib;
import org.mule.runtime.extension.api.annotation.param.ParameterGroup;
@@ -64,7 +65,8 @@ public java.util.Optional getDataSourceConfig() {
@Override
protected DbConnection createDbConnection(Connection connection) throws Exception {
- return new DerbyConnection(connection, resolveCustomTypes(), super.getCacheQueryTemplateSize());
+ return new DerbyConnection(connection, resolveCustomTypes(), super.getCacheQueryTemplateSize(),
+ new DerbyDbConnectionTracingMetadata(derbyParameters));
}
@Override
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/derby/tracing/DerbyDbConnectionTracingMetadata.java b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/tracing/DerbyDbConnectionTracingMetadata.java
new file mode 100644
index 000000000..4785991c1
--- /dev/null
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/derby/tracing/DerbyDbConnectionTracingMetadata.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+package org.mule.extension.db.internal.domain.connection.derby.tracing;
+
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getHostFrom;
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getProtocolFrom;
+
+import static java.util.Optional.ofNullable;
+
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
+import org.mule.extension.db.internal.domain.connection.derby.DerbyConnectionParameters;
+
+import java.util.Optional;
+
+/**
+ * a {@link DbConnectionTracingMetadata} for derby.
+ */
+public class DerbyDbConnectionTracingMetadata implements DbConnectionTracingMetadata {
+
+ public static final String DERBY_DB_SYSTEM = "DERBY";
+ private final DerbyConnectionParameters derbyParameters;
+
+ public DerbyDbConnectionTracingMetadata(DerbyConnectionParameters derbyParameters) {
+ this.derbyParameters = derbyParameters;
+ }
+
+ @Override
+ public String getDbSystem() {
+ return DERBY_DB_SYSTEM;
+ }
+
+ @Override
+ public String getConnectionString() {
+ return derbyParameters.getUrl();
+ }
+
+ @Override
+ public String getUser() {
+ return derbyParameters.getUser();
+ }
+
+ @Override
+ public Optional getPeerName() {
+ return ofNullable(getHostFrom(derbyParameters.getUrl()));
+ }
+
+ @Override
+ public Optional getPeerTransport() {
+ return ofNullable(getProtocolFrom(derbyParameters.getUser()));
+ }
+}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/generic/DbGenericConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/generic/DbGenericConnectionProvider.java
index 306215754..ed4ca590f 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/generic/DbGenericConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/generic/DbGenericConnectionProvider.java
@@ -13,6 +13,7 @@
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.generic.GenericConnectionProvider;
import org.mule.db.commons.internal.domain.type.ResolvedDbType;
+import org.mule.extension.db.internal.domain.connection.datasource.ConnectionBasedDbConnectionTracingMetadata;
import org.mule.extension.db.internal.domain.connection.oracle.OracleDbConnection;
import org.mule.runtime.extension.api.annotation.Alias;
import org.mule.runtime.extension.api.annotation.ExternalLib;
@@ -38,10 +39,13 @@ public class DbGenericConnectionProvider extends GenericConnectionProvider {
@Override
protected DbConnection createDbConnection(Connection connection) throws Exception {
+ ConnectionBasedDbConnectionTracingMetadata connectionTracingMetadata =
+ new ConnectionBasedDbConnectionTracingMetadata(connection);
if (isOracle(connection)) {
- return new OracleDbConnection(connection, resolveCustomTypes(), resolvedDbTypesCache, super.getCacheQueryTemplateSize());
+ return new OracleDbConnection(connection, resolveCustomTypes(), resolvedDbTypesCache, super.getCacheQueryTemplateSize(),
+ connectionTracingMetadata);
} else {
- return super.createDbConnection(connection);
+ return super.createDbConnection(connection, connectionTracingMetadata);
}
}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/MySqlConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/MySqlConnectionProvider.java
index 319feaabc..b19b3c50f 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/MySqlConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/MySqlConnectionProvider.java
@@ -23,6 +23,8 @@
import org.mule.db.commons.api.exception.connection.DbError;
import org.mule.db.commons.internal.domain.connection.DataSourceConfig;
import org.mule.db.commons.internal.domain.connection.DbConnectionProvider;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
+import org.mule.extension.db.internal.domain.connection.mysql.tracing.MySqlConnectionTracingMetadata;
import org.mule.runtime.extension.api.annotation.Alias;
import org.mule.runtime.extension.api.annotation.ExternalLib;
import org.mule.runtime.extension.api.annotation.param.ParameterGroup;
@@ -72,4 +74,8 @@ public java.util.Optional getDbVendorErrorType(SQLException e) {
return empty();
}
+ @Override
+ protected DbConnectionTracingMetadata getDbConnectionTracingMetadata() {
+ return new MySqlConnectionTracingMetadata(mySqlParameters);
+ }
}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/tracing/MySqlConnectionTracingMetadata.java b/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/tracing/MySqlConnectionTracingMetadata.java
new file mode 100644
index 000000000..8b705bb2b
--- /dev/null
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/mysql/tracing/MySqlConnectionTracingMetadata.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+package org.mule.extension.db.internal.domain.connection.mysql.tracing;
+
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
+import org.mule.extension.db.internal.domain.connection.mysql.MySqlConnectionParameters;
+
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getHostFrom;
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getProtocolFrom;
+
+import static java.util.Optional.ofNullable;
+
+import java.util.Optional;
+
+/**
+ * a {@link DbConnectionTracingMetadata} for mysql.
+ */
+public class MySqlConnectionTracingMetadata implements DbConnectionTracingMetadata {
+
+ public static final String MYSQL = "mysql";
+ private final MySqlConnectionParameters mySqlParameter;
+
+ public MySqlConnectionTracingMetadata(MySqlConnectionParameters mySqlParameters) {
+ this.mySqlParameter = mySqlParameters;
+ }
+
+ @Override
+ public String getDbSystem() {
+ return MYSQL;
+ }
+
+ @Override
+ public String getConnectionString() {
+ return mySqlParameter.getUrl();
+ }
+
+ @Override
+ public String getUser() {
+ return mySqlParameter.getUser();
+ }
+
+ @Override
+ public Optional getPeerName() {
+ return ofNullable(getHostFrom(mySqlParameter.getUrl()));
+ }
+
+ @Override
+ public Optional getPeerTransport() {
+ return ofNullable(getProtocolFrom(mySqlParameter.getUrl()));
+ }
+}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnection.java b/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnection.java
index a7ba6e61f..a8298bb16 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnection.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnection.java
@@ -10,6 +10,7 @@
import static java.util.Optional.empty;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata.getNotResolvedDbConnectionTracingMetadata;
import static org.mule.extension.db.internal.domain.connection.oracle.OracleConnectionUtils.getOwnerFrom;
import static org.mule.extension.db.internal.domain.connection.oracle.OracleConnectionUtils.getTypeSimpleName;
@@ -26,6 +27,7 @@
import org.mule.extension.db.internal.domain.connection.oracle.types.OracleSQLXMLType;
import org.mule.extension.db.internal.domain.connection.oracle.types.OracleSYSXMLType;
import org.mule.extension.db.internal.domain.connection.oracle.types.OracleXMLType;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
import java.sql.Array;
import java.sql.Connection;
@@ -77,10 +79,16 @@ public class OracleDbConnection extends DefaultDbConnection {
private final Map> resolvedDbTypesCache;
-
public OracleDbConnection(Connection jdbcConnection, List customDataTypes,
Map> resolvedDbTypesCache, long cacheQueryTemplateSize) {
- super(jdbcConnection, customDataTypes, cacheQueryTemplateSize);
+ this(jdbcConnection, customDataTypes, resolvedDbTypesCache, cacheQueryTemplateSize,
+ getNotResolvedDbConnectionTracingMetadata());
+ }
+
+ public OracleDbConnection(Connection jdbcConnection, List customDataTypes,
+ Map> resolvedDbTypesCache, long cacheQueryTemplateSize,
+ DbConnectionTracingMetadata dbConnectionTracingMetadata) {
+ super(jdbcConnection, customDataTypes, cacheQueryTemplateSize, dbConnectionTracingMetadata);
this.resolvedDbTypesCache = resolvedDbTypesCache;
}
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnectionProvider.java
index 09ea28576..48dcff936 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/oracle/OracleDbConnectionProvider.java
@@ -7,10 +7,6 @@
package org.mule.extension.db.internal.domain.connection.oracle;
-import static java.util.Optional.empty;
-import static java.util.Optional.of;
-import static java.util.Optional.ofNullable;
-
import static org.mule.db.commons.api.exception.connection.DbError.CANNOT_REACH;
import static org.mule.db.commons.api.exception.connection.DbError.INVALID_CREDENTIALS;
import static org.mule.db.commons.api.exception.connection.DbError.INVALID_DATABASE;
@@ -21,6 +17,10 @@
import static org.mule.runtime.extension.api.annotation.param.ParameterGroup.CONNECTION;
import static org.mule.extension.db.internal.util.MigrationUtils.mapDataSourceConfig;
+import static java.util.Optional.empty;
+import static java.util.Optional.of;
+import static java.util.Optional.ofNullable;
+
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
@@ -30,6 +30,7 @@
import org.mule.db.commons.api.exception.connection.DbError;
import org.mule.db.commons.internal.domain.connection.DataSourceConfig;
+import org.mule.db.commons.internal.domain.connection.GenericConfigDbConnectionTracingMetadata;
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.DbConnectionProvider;
import org.mule.db.commons.internal.domain.type.ResolvedDbType;
@@ -79,7 +80,8 @@ public java.util.Optional getDataSourceConfig() {
@Override
protected DbConnection createDbConnection(Connection connection) throws Exception {
return new OracleDbConnection(connection, super.resolveCustomTypes(), resolvedDbTypesCache,
- super.getCacheQueryTemplateSize());
+ super.getCacheQueryTemplateSize(),
+ new GenericConfigDbConnectionTracingMetadata(getDataSourceConfig().get()));
}
@Override
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnection.java b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnection.java
index bb501c0d0..77928f9dd 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnection.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnection.java
@@ -6,11 +6,14 @@
*/
package org.mule.extension.db.internal.domain.connection.sqlserver;
+import static org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata.getNotResolvedDbConnectionTracingMetadata;
+
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.DefaultDbConnection;
import org.mule.extension.db.internal.domain.connection.sqlserver.types.SqlServerBinaryDbType;
import org.mule.extension.db.internal.domain.connection.sqlserver.types.SqlServerVarBinaryDbType;
import org.mule.db.commons.internal.domain.type.DbType;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
import java.sql.Connection;
import java.util.ArrayList;
@@ -24,7 +27,12 @@
public class SqlServerConnection extends DefaultDbConnection {
SqlServerConnection(Connection jdbcConnection, List customDataTypes, long cacheQueryTemplateSize) {
- super(jdbcConnection, customDataTypes, cacheQueryTemplateSize);
+ super(jdbcConnection, customDataTypes, cacheQueryTemplateSize, getNotResolvedDbConnectionTracingMetadata());
+ }
+
+ SqlServerConnection(Connection jdbcConnection, List customDataTypes, long cacheQueryTemplateSize,
+ DbConnectionTracingMetadata dbConnectionTracingMetadata) {
+ super(jdbcConnection, customDataTypes, cacheQueryTemplateSize, dbConnectionTracingMetadata);
}
/**
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnectionProvider.java b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnectionProvider.java
index a3b384554..f89bc02df 100644
--- a/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnectionProvider.java
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/SqlServerConnectionProvider.java
@@ -23,10 +23,12 @@
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
+
import org.mule.db.commons.api.exception.connection.DbError;
import org.mule.db.commons.internal.domain.connection.DataSourceConfig;
import org.mule.db.commons.internal.domain.connection.DbConnection;
import org.mule.db.commons.internal.domain.connection.DbConnectionProvider;
+import org.mule.extension.db.internal.domain.connection.sqlserver.tracing.SqlServerDbConnectionTracingMetadata;
import org.mule.runtime.extension.api.annotation.Alias;
import org.mule.runtime.extension.api.annotation.ExternalLib;
import org.mule.runtime.extension.api.annotation.param.ParameterGroup;
@@ -56,7 +58,8 @@ public class SqlServerConnectionProvider extends DbConnectionProvider {
@Override
protected DbConnection createDbConnection(Connection connection) throws Exception {
- return new SqlServerConnection(connection, super.resolveCustomTypes(), super.getCacheQueryTemplateSize());
+ return new SqlServerConnection(connection, super.resolveCustomTypes(), super.getCacheQueryTemplateSize(),
+ new SqlServerDbConnectionTracingMetadata(connectionParameters));
}
@Override
diff --git a/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/tracing/SqlServerDbConnectionTracingMetadata.java b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/tracing/SqlServerDbConnectionTracingMetadata.java
new file mode 100644
index 000000000..357f6518a
--- /dev/null
+++ b/src/main/java/org/mule/extension/db/internal/domain/connection/sqlserver/tracing/SqlServerDbConnectionTracingMetadata.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+package org.mule.extension.db.internal.domain.connection.sqlserver.tracing;
+
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
+import org.mule.extension.db.internal.domain.connection.sqlserver.SqlServerConnectionParameters;
+
+import java.util.Optional;
+
+import static java.util.Optional.ofNullable;
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getHostFrom;
+import static org.mule.db.commons.internal.domain.connection.ConnectionTracingMetadataUtils.getProtocolFrom;
+
+/**
+ * a {@link DbConnectionTracingMetadata} for sql server.
+ */
+public class SqlServerDbConnectionTracingMetadata implements DbConnectionTracingMetadata {
+
+ public static final String SQL_SERVER_DB_SYSTEM = "SQL_SERVER";
+ private final SqlServerConnectionParameters connectionParameters;
+
+ public SqlServerDbConnectionTracingMetadata(SqlServerConnectionParameters connectionParameters) {
+ this.connectionParameters = connectionParameters;
+ }
+
+ @Override
+ public String getDbSystem() {
+ return SQL_SERVER_DB_SYSTEM;
+ }
+
+ @Override
+ public String getConnectionString() {
+ return connectionParameters.getUrl();
+ }
+
+ @Override
+ public String getUser() {
+ return connectionParameters.getUser();
+ }
+
+ @Override
+ public Optional getPeerName() {
+ return ofNullable(getHostFrom(connectionParameters.getUrl()));
+ }
+
+ @Override
+ public Optional getPeerTransport() {
+ return ofNullable(getProtocolFrom(connectionParameters.getUrl()));
+ }
+}
diff --git a/src/main/java/org/mule/extension/db/internal/operation/DbBulkOperations.java b/src/main/java/org/mule/extension/db/internal/operation/DbBulkOperations.java
index 4a0c36c0a..9416f6605 100644
--- a/src/main/java/org/mule/extension/db/internal/operation/DbBulkOperations.java
+++ b/src/main/java/org/mule/extension/db/internal/operation/DbBulkOperations.java
@@ -8,6 +8,7 @@
import org.mule.db.commons.AbstractDbConnector;
import org.mule.db.commons.internal.domain.connection.DbConnection;
+import org.mule.db.commons.internal.domain.connection.DbConnectionTracingMetadata;
import org.mule.db.commons.internal.domain.metadata.DbInputMetadataResolver;
import org.mule.db.commons.internal.operation.BulkOperations;
import org.mule.db.commons.internal.operation.OperationErrorTypeProvider;
@@ -25,13 +26,19 @@
import org.mule.extension.db.api.param.BulkQueryDefinition;
import org.mule.extension.db.api.param.BulkScript;
import org.mule.extension.db.api.param.QuerySettings;
+import org.mule.sdk.api.runtime.parameter.CorrelationInfo;
+import org.mule.sdk.compatibility.api.utils.ForwardCompatibilityHelper;
+import javax.inject.Inject;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
+import static org.mule.db.commons.internal.domain.query.QueryType.DELETE;
+import static org.mule.db.commons.internal.domain.query.QueryType.UPDATE;
import static org.mule.db.commons.internal.operation.BaseDbOperations.QUERY_GROUP;
import static org.mule.db.commons.internal.operation.BaseDbOperations.QUERY_SETTINGS;
+import static org.mule.extension.db.internal.operation.tracing.TracingUtils.setAttributesForDbClientOperation;
import static org.mule.extension.db.internal.util.MigrationUtils.mapBulkQueryDefinition;
import static org.mule.extension.db.internal.util.MigrationUtils.mapBulkScript;
import static org.mule.extension.db.internal.util.MigrationUtils.mapQuerySettings;
@@ -47,6 +54,9 @@ public class DbBulkOperations implements Initialisable {
private BulkOperations bulkOperations;
+ @Inject
+ private java.util.Optional forwardCompatibilityHelper;
+
@Override
public void initialise() throws InitialisationException {
this.bulkOperations = new BulkOperations.Builder().build();
@@ -70,8 +80,15 @@ public int[] bulkInsert(@DisplayName("Input Parameters") @Content @Placement(
@ParameterGroup(name = QUERY_GROUP) BulkQueryDefinition query,
@Config AbstractDbConnector connector,
@Connection DbConnection connection,
+ CorrelationInfo correlationInfo,
StreamingHelper streamingHelper)
throws SQLException {
+ forwardCompatibilityHelper.ifPresent(fwh -> {
+ DbConnectionTracingMetadata dbConnectionTracingMetadata = connection.getDbConnectionTracingMetadata();
+ setAttributesForDbClientOperation(dbConnectionTracingMetadata,
+ fwh.getDistributedTraceContextManager(correlationInfo),
+ query.getSql());
+ });
return bulkOperations.bulkInsert(bulkInputParameters, mapBulkQueryDefinition(query), connector, connection, streamingHelper);
}
@@ -94,8 +111,16 @@ public int[] bulkUpdate(@DisplayName("Input Parameters") @Content @Placement(
@ParameterGroup(name = QUERY_GROUP) BulkQueryDefinition query,
@Config AbstractDbConnector connector,
@Connection DbConnection connection,
+ CorrelationInfo correlationInfo,
StreamingHelper streamingHelper)
throws SQLException {
+ forwardCompatibilityHelper.ifPresent(fwh -> {
+ DbConnectionTracingMetadata dbConnectionTracingMetadata = connection.getDbConnectionTracingMetadata();
+ setAttributesForDbClientOperation(dbConnectionTracingMetadata,
+ UPDATE.name() + " " + dbConnectionTracingMetadata.getDbSystem(),
+ fwh.getDistributedTraceContextManager(correlationInfo),
+ query.getSql());
+ });
return bulkOperations.bulkUpdate(bulkInputParameters, mapBulkQueryDefinition(query), connector, connection, streamingHelper);
}
@@ -117,8 +142,16 @@ public int[] bulkDelete(@DisplayName("Input Parameters") @Content @Placement(
@ParameterGroup(name = QUERY_GROUP) BulkQueryDefinition query,
@Config AbstractDbConnector connector,
@Connection DbConnection connection,
+ CorrelationInfo correlationInfo,
StreamingHelper streamingHelper)
throws SQLException {
+ forwardCompatibilityHelper.ifPresent(fwh -> {
+ DbConnectionTracingMetadata dbConnectionTracingMetadata = connection.getDbConnectionTracingMetadata();
+ setAttributesForDbClientOperation(dbConnectionTracingMetadata,
+ DELETE.name() + " " + dbConnectionTracingMetadata.getDbSystem(),
+ fwh.getDistributedTraceContextManager(correlationInfo),
+ query.getSql());
+ });
return bulkOperations.bulkDelete(bulkInputParameters, mapBulkQueryDefinition(query), connector, connection, streamingHelper);
}
@@ -135,8 +168,16 @@ public int[] bulkDelete(@DisplayName("Input Parameters") @Content @Placement(
*/
public int[] executeScript(@ParameterGroup(name = QUERY_GROUP) BulkScript script,
@ParameterGroup(name = QUERY_SETTINGS) QuerySettings settings,
- @Connection DbConnection connection)
+ @Connection DbConnection connection,
+ CorrelationInfo correlationInfo)
throws SQLException {
+ forwardCompatibilityHelper.ifPresent(fwh -> {
+ DbConnectionTracingMetadata dbConnectionTracingMetadata = connection.getDbConnectionTracingMetadata();
+ setAttributesForDbClientOperation(dbConnectionTracingMetadata,
+ dbConnectionTracingMetadata.getDbSystem(),
+ fwh.getDistributedTraceContextManager(correlationInfo),
+ "