From 24ab27a25a87290f9f320d0451c85655788a10ed Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 22:35:12 +0800 Subject: [PATCH 01/16] Polish JDBC plugins to make DBType accurate Signed-off-by: pg.yang --- .../ClickHouseStatementTracingWrapper.java | 2 +- ...eparedStatementExecuteMethodsInterceptor.java | 10 +++++----- .../StatementExecuteMethodsInterceptor.java | 2 +- ...eparedStatementExecuteMethodsInterceptor.java | 2 +- .../StatementExecuteMethodsInterceptor.java | 2 +- .../config/expectedData.yaml | 16 ++++++++-------- .../mssql-jdbc-scenario/config/expectedData.yaml | 10 +++++----- .../mssql-jtds-scenario/config/expectedData.yaml | 8 ++++---- .../mysql-scenario/config/expectedData.yaml | 16 ++++++++-------- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementTracingWrapper.java b/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementTracingWrapper.java index ad10d8f17b..6f2e9bcaa0 100644 --- a/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementTracingWrapper.java +++ b/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementTracingWrapper.java @@ -35,7 +35,7 @@ public static T of(ConnectionInfo connectionInfo, String methodName, String final AbstractSpan span = ContextManager.createExitSpan( connectionInfo.getDBType() + "/JDBC/Statement/" + methodName, connectionInfo.getDatabasePeer()); try { - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectionInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectionInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); span.setComponent(connectionInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java index 27f3ed81d4..2b2f73e8c7 100644 --- a/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java @@ -46,7 +46,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] AbstractSpan span = ContextManager.createExitSpan( buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); @@ -83,11 +83,11 @@ public final void handleMethodException(EnhancedInstance objInst, Method method, private String buildOperationName(ConnectionInfo connectionInfo, String methodName, String statementName) { return connectionInfo.getDBType() + "/JDBC/" + statementName + "/" + methodName; } - + private String getParameterString(Object[] parameters, int maxIndex) { return new PreparedStatementParameterBuilder() - .setParameters(parameters) - .setMaxIndex(maxIndex) - .build(); + .setParameters(parameters) + .setMaxIndex(maxIndex) + .build(); } } diff --git a/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/StatementExecuteMethodsInterceptor.java index cbd5c45eb1..23d48a61e5 100644 --- a/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/StatementExecuteMethodsInterceptor.java @@ -41,7 +41,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] AbstractSpan span = ContextManager.createExitSpan( buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); String sql = ""; diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java index 157080b442..b01f10c7c1 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java @@ -51,7 +51,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] AbstractSpan span = ContextManager.createExitSpan( buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java index cfcf97fe38..8895e118a5 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java @@ -48,7 +48,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); /** diff --git a/test/plugin/scenarios/clickhouse-0.3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/clickhouse-0.3.x-scenario/config/expectedData.yaml index 684a5ba57b..d3062dc8a5 100644 --- a/test/plugin/scenarios/clickhouse-0.3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/clickhouse-0.3.x-scenario/config/expectedData.yaml @@ -50,7 +50,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: 'select timezone(), version()'} - {key: http.status_code, value: '200'} @@ -67,7 +67,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: SELECT * FROM clusters} - {key: http.status_code, value: '200'} @@ -84,7 +84,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: SELECT 1} - {key: http.status_code, value: '200'} @@ -101,7 +101,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: ''} - operationName: ClickHouse/JDBC/Statement/executeQuery @@ -117,7 +117,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: 'select timezone(), version()'} - {key: http.status_code, value: '200'} @@ -134,7 +134,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: SELECT * FROM clusters} - {key: http.status_code, value: '200'} @@ -151,7 +151,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: SELECT 1} - {key: http.status_code, value: '200'} @@ -168,7 +168,7 @@ segmentItems: peer: not null skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: ClickHouse} - {key: db.instance, value: system} - {key: db.statement, value: ''} - operationName: GET:/clickhouse-scenario/case/clickhouse-scenario diff --git a/test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml b/test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml index 1090c80296..dd9c28b006 100644 --- a/test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -41,7 +41,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} - {key: db.sql.parameters, value: '[1,1]'} @@ -58,7 +58,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: 'SELECT id, value FROM test_007 WHERE id=?'} - {key: db.sql.parameters, value: '[1]'} @@ -75,7 +75,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: DROP table test_007} logs: [] @@ -91,7 +91,7 @@ segmentItems: parentSpanId: 0 spanId: 5 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: ''} logs: [] diff --git a/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml b/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml index 85b112b07f..0b285736a8 100644 --- a/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - - {key: db.type, value: sql} + {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -41,7 +41,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - - {key: db.type, value: sql} + {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} logs: [] @@ -57,7 +57,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - - {key: db.type, value: sql} + {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: DROP table test_007} logs: [] @@ -73,7 +73,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - - {key: db.type, value: sql} + {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: ''} logs: [] diff --git a/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml b/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml index 916f5c9e50..d5902157ba 100644 --- a/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -41,7 +41,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} logs: [] @@ -57,7 +57,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: DROP table test_007} logs: [] @@ -73,7 +73,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: "create procedure testProcedure(IN id varchar(10)) \n begin \n select id; \n end"} logs: [] @@ -97,14 +97,14 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: SHOW CREATE PROCEDURE `test`.`testProcedure`} - operationName: Mysql/JDBC/CallableStatement/execute parentSpanId: 0 spanId: 6 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: "call testProcedure( ? )"} logs: [] @@ -120,7 +120,7 @@ segmentItems: parentSpanId: 0 spanId: 7 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: "drop procedure testProcedure"} logs: [] @@ -136,7 +136,7 @@ segmentItems: parentSpanId: 0 spanId: 8 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: ''} logs: [] From 47c473d4fe14b923d776d0cbeb0ec026959fc156 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 22:49:51 +0800 Subject: [PATCH 02/16] PostgreSQL --- .../PreparedStatementExecuteMethodsInterceptor.java | 2 +- .../postgresql/StatementExecuteMethodsInterceptor.java | 2 +- .../postgresql-scenario/config/expectedData.yaml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java index d859e96d51..2bf42f4194 100755 --- a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java @@ -47,7 +47,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] AbstractSpan span = ContextManager.createExitSpan( buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo .getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/StatementExecuteMethodsInterceptor.java index ed248f73c1..a93621eab0 100755 --- a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/StatementExecuteMethodsInterceptor.java @@ -41,7 +41,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] ConnectionInfo connectInfo = cacheObject.getConnectionInfo(); AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo .getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); String sql = (String) allArguments[0]; sql = SqlBodyUtil.limitSqlBodySize(sql); diff --git a/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml index 7a1c88d906..04db779d65 100644 --- a/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -40,7 +40,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} startTime: nq 0 @@ -55,7 +55,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: DROP table test_007} startTime: nq 0 @@ -70,7 +70,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: ''} startTime: nq 0 From ca2b73f1c26e80b1d8cdeafbd483a1ce67959638 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 22:56:22 +0800 Subject: [PATCH 03/16] Mariadb --- .../v2/PreparedStatementExecuteMethodsInterceptor.java | 2 +- .../mariadb/v2/StatementExecuteMethodsInterceptor.java | 2 +- .../mariadb-scenario/config/expectedData.yaml | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java index b358aed742..950bab2822 100644 --- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java @@ -45,7 +45,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] } AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptor.java index e34373cd28..4c4b518cb0 100644 --- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptor.java @@ -40,7 +40,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] if (connectInfo != null) { AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); String sql = allArguments.length > 0 ? (String) allArguments[0] : ""; sql = SqlBodyUtil.limitSqlBodySize(sql); diff --git a/test/plugin/scenarios/mariadb-scenario/config/expectedData.yaml b/test/plugin/scenarios/mariadb-scenario/config/expectedData.yaml index 10152cd236..aa853b2cb1 100644 --- a/test/plugin/scenarios/mariadb-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mariadb-scenario/config/expectedData.yaml @@ -31,7 +31,7 @@ segmentItems: peer: mariadb-server:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mariadb} - {key: db.instance, value: test} - key: db.statement value: "CREATE TABLE test_table(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(10)\ @@ -48,7 +48,7 @@ segmentItems: peer: mariadb-server:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mariadb} - {key: db.instance, value: test} - {key: db.statement, value: "INSERT INTO test_table(id, value) VALUES(?,?)"} - operationName: Mariadb/JDBC/PreparedStatement/execute @@ -63,7 +63,7 @@ segmentItems: peer: mariadb-server:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mariadb} - {key: db.instance, value: test} - {key: db.statement, value: "SELECT id, value FROM test_table WHERE id = ?"} - operationName: Mariadb/JDBC/Statement/execute @@ -78,7 +78,7 @@ segmentItems: peer: mariadb-server:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mariadb} - {key: db.instance, value: test} - {key: db.statement, value: "DROP table test_table"} - operationName: Mariadb/JDBC/Connection/close @@ -93,7 +93,7 @@ segmentItems: peer: mariadb-server:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mariadb} - {key: db.instance, value: test} - {key: db.statement, value: ''} - operationName: GET:/mariadb-scenario/case/mariadb-scenario From b64558eba539a6da605a23ac1073a1974c01dc76 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:00:54 +0800 Subject: [PATCH 04/16] PostgreSQL 9+ --- .../config/expectedData.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml index ebd38fa0cb..1b50265675 100644 --- a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -40,7 +40,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} - {key: db.sql.parameters, value: '[1,1]'} @@ -56,7 +56,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: DROP table test_007} startTime: nq 0 @@ -71,7 +71,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - - {key: db.type, value: sql} + - {key: db.type, value: PostgreSQL} - {key: db.instance, value: postgres} - {key: db.statement, value: ''} startTime: nq 0 From 671dc38da54aa362e1dbe6ae58ecda451b8fc027 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:02:59 +0800 Subject: [PATCH 05/16] kylin --- .../kylin/PreparedStatementExecuteMethodsInterceptor.java | 2 +- .../jdbc/kylin/StatementExecuteMethodsInterceptor.java | 2 +- .../config/expectedData.yaml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptor.java index a9d70254ca..6c47ffa4ab 100644 --- a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptor.java @@ -45,7 +45,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] } AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptor.java index cff46169d6..26f8077d63 100644 --- a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptor.java @@ -39,7 +39,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] if (connectInfo != null) { AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); String sql = allArguments.length > 0 ? (String) allArguments[0] : ""; sql = SqlBodyUtil.limitSqlBodySize(sql); diff --git a/test/plugin/scenarios/kylin-jdbc-2.6.x-3.x-4.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/kylin-jdbc-2.6.x-3.x-4.x-scenario/config/expectedData.yaml index 5137f96edb..451c6dda14 100644 --- a/test/plugin/scenarios/kylin-jdbc-2.6.x-3.x-4.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/kylin-jdbc-2.6.x-3.x-4.x-scenario/config/expectedData.yaml @@ -31,7 +31,7 @@ segmentItems: peer: kylin-server:7070 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: kylin} - {key: db.instance, value: learn_kylin} - key: db.statement value: "select * from KYLIN_ACCOUNT LIMIT 1" @@ -47,7 +47,7 @@ segmentItems: peer: kylin-server:7070 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: kylin} - {key: db.instance, value: learn_kylin} - {key: db.statement, value: "select * from KYLIN_ACCOUNT"} - operationName: kylin/JDBC/Connection/close @@ -62,7 +62,7 @@ segmentItems: peer: kylin-server:7070 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: kylin} - {key: db.instance, value: learn_kylin} - {key: db.statement, value: ''} - operationName: HEAD:/kylin-jdbc-2.6.x-3.x-4.x-scenario/case/healthCheck From f05a2268e43970bb1f5795081274a4c9dbf3ed9c Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:12:14 +0800 Subject: [PATCH 06/16] H2 --- .../plugin/scenarios/h2-scenario/config/expectedData.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin/scenarios/h2-scenario/config/expectedData.yaml b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml index 1c74ac9e79..d06c487e8a 100644 --- a/test/plugin/scenarios/h2-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: test} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -47,7 +47,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: test} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} skipAnalysis: 'false' @@ -62,7 +62,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: test} - {key: db.statement, value: DROP table test_007} skipAnalysis: 'false' @@ -77,7 +77,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: test} - {key: db.statement, value: ''} skipAnalysis: 'false' From 7fdcdc4844fd45171242341ffad58b6c64ecb68d Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:16:44 +0800 Subject: [PATCH 07/16] kotlin-coroutine-scenario --- .../kotlin-coroutine-scenario/config/expectedData.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml b/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml index 2ad7c91d26..d0cb831780 100644 --- a/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo} - {key: db.statement, value: 'SELECT * FROM PERSON WHERE ID = ?'} skipAnalysis: 'false' @@ -45,7 +45,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo} - {key: db.statement, value: ''} skipAnalysis: 'false' @@ -76,7 +76,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo} - {key: db.statement, value: 'SELECT * FROM PERSON WHERE ID = ?'} skipAnalysis: 'false' @@ -91,7 +91,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo} - {key: db.statement, value: ''} skipAnalysis: 'false' From e037e45742c150fcb18e2e489e3bceab68378650 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:17:39 +0800 Subject: [PATCH 08/16] spring tx --- .../spring-tx-scenario/config/expectedData.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml index 77f420c0ba..f8ab707618 100644 --- a/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml @@ -45,7 +45,7 @@ segmentItems: spanType: Exit peer: mysql:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: 'insert into `test`.`table_demo`(name) values(?)'} skipAnalysis: 'false' @@ -60,7 +60,7 @@ segmentItems: spanType: Exit peer: mysql:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: 'insert into `test`.`table_demo`(name) values(?)'} skipAnalysis: 'false' @@ -75,7 +75,7 @@ segmentItems: spanType: Exit peer: mysql:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: ''} skipAnalysis: 'false' @@ -90,7 +90,7 @@ segmentItems: spanType: Exit peer: mysql:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: select @@session.tx_read_only} skipAnalysis: 'false' @@ -105,7 +105,7 @@ segmentItems: spanType: Exit peer: mysql:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: ''} skipAnalysis: 'false' From f8fbdabf7db6a74e4dce0963e1792bb08534c9d8 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:19:06 +0800 Subject: [PATCH 09/16] sharding --- .../shardingsphere-3.x-scenario/config/expectedData.yaml | 8 ++++---- .../config/expectedData.yaml | 8 ++++---- .../shardingsphere-4.x-scenario/config/expectedData.yaml | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml index 0573028065..69e4c3198d 100644 --- a/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -62,7 +62,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -94,7 +94,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' @@ -139,7 +139,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' diff --git a/test/plugin/scenarios/shardingsphere-4.0.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-4.0.x-scenario/config/expectedData.yaml index 144e657fd1..1a2df52395 100644 --- a/test/plugin/scenarios/shardingsphere-4.0.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-4.0.x-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -62,7 +62,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -94,7 +94,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' @@ -139,7 +139,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' diff --git a/test/plugin/scenarios/shardingsphere-4.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-4.x-scenario/config/expectedData.yaml index 10c5841b1e..09d252e2fd 100644 --- a/test/plugin/scenarios/shardingsphere-4.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-4.x-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -62,7 +62,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_1} skipAnalysis: 'false' @@ -94,7 +94,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_1} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' @@ -139,7 +139,7 @@ segmentItems: spanType: Exit peer: localhost:-1 tags: - - {key: db.type, value: sql} + - {key: db.type, value: H2} - {key: db.instance, value: demo_ds_0} - {key: db.statement, value: SELECT * FROM t_order_0} skipAnalysis: 'false' From 7a407b9aa611910ad7dc0d8d2c91725dd5fa5d95 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Tue, 22 Nov 2022 23:21:02 +0800 Subject: [PATCH 10/16] adatasource --- .../dbcp-2.x-scenario/config/expectedData.yaml | 12 ++++++------ .../druid-1.x-scenario/config/expectedData.yaml | 10 +++++----- .../hikaricp-scenario/config/expectedData.yaml | 10 +++++----- .../mybatis-3.x-scenario/config/expectedData.yaml | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/plugin/scenarios/dbcp-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/dbcp-2.x-scenario/config/expectedData.yaml index 4c9b0e7bf1..7e21e55dd6 100755 --- a/test/plugin/scenarios/dbcp-2.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/dbcp-2.x-scenario/config/expectedData.yaml @@ -28,7 +28,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: ''} - operationName: DBCP/Connection/getConnection @@ -52,7 +52,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: "CREATE TABLE test_DBCP(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -88,7 +88,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: 'INSERT INTO test_DBCP(id, value) VALUES(1,1)' @@ -123,7 +123,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: 'SELECT id, value FROM test_DBCP WHERE id=1' @@ -158,7 +158,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: "DELETE FROM test_DBCP WHERE id=1" @@ -193,7 +193,7 @@ segmentItems: peer: mysql-server:3306 skipAnalysis: false tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - key: db.statement value: "DROP table test_DBCP" diff --git a/test/plugin/scenarios/druid-1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/druid-1.x-scenario/config/expectedData.yaml index ec61052a09..79b64a8ab5 100644 --- a/test/plugin/scenarios/druid-1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/druid-1.x-scenario/config/expectedData.yaml @@ -40,7 +40,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'CREATE TABLE test_DRUID(id VARCHAR(1) PRIMARY KEY, value VARCHAR(1) NOT NULL)'} @@ -75,7 +75,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'INSERT INTO test_DRUID(id, value) VALUES(1,1)'} - operationName: Druid/Connection/close @@ -109,7 +109,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'SELECT id, value FROM test_DRUID WHERE id=1'} - operationName: Druid/Connection/close @@ -143,7 +143,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'DELETE FROM test_DRUID WHERE id=1'} - operationName: Druid/Connection/close @@ -177,7 +177,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'DROP table test_DRUID'} - operationName: Druid/Connection/close diff --git a/test/plugin/scenarios/hikaricp-scenario/config/expectedData.yaml b/test/plugin/scenarios/hikaricp-scenario/config/expectedData.yaml index 471089ab93..75106a2a57 100644 --- a/test/plugin/scenarios/hikaricp-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/hikaricp-scenario/config/expectedData.yaml @@ -40,7 +40,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'CREATE TABLE test_Hikari(id VARCHAR(1) PRIMARY KEY, value VARCHAR(1) NOT NULL)'} @@ -75,7 +75,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'INSERT INTO test_Hikari(id, value) VALUES(1,1)'} - operationName: HikariCP/Connection/close @@ -109,7 +109,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'SELECT id, value FROM test_Hikari WHERE id=1'} - operationName: HikariCP/Connection/close @@ -143,7 +143,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'DELETE FROM test_Hikari WHERE id=1'} - operationName: HikariCP/Connection/close @@ -177,7 +177,7 @@ segmentItems: spanType: Exit peer: mysql-server:3306 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: test} - {key: db.statement, value: 'DROP table test_Hikari'} - operationName: HikariCP/Connection/close diff --git a/test/plugin/scenarios/mybatis-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/mybatis-3.x-scenario/config/expectedData.yaml index f9c1250bc2..7d42e35ae2 100644 --- a/test/plugin/scenarios/mybatis-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mybatis-3.x-scenario/config/expectedData.yaml @@ -31,7 +31,7 @@ segmentItems: peer: mysql:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: 'insert into test.table_demo (name) values (?)'} - operationName: org.apache.ibatis.session.defaults.DefaultSqlSession.insert(java.lang.String,java.lang.Object) @@ -59,7 +59,7 @@ segmentItems: peer: mysql:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: ''} - operationName: Mysql/JDBC/PreparedStatement/execute @@ -74,7 +74,7 @@ segmentItems: peer: mysql:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: 'insert into test.table_demo (name) values (?)'} - operationName: org.apache.ibatis.session.defaults.DefaultSqlSession.insert(java.lang.String,java.lang.Object) @@ -102,7 +102,7 @@ segmentItems: peer: mysql:3306 skipAnalysis: 'false' tags: - - {key: db.type, value: sql} + - {key: db.type, value: Mysql} - {key: db.instance, value: ''} - {key: db.statement, value: ''} - operationName: GET:/case/mybatis-case From 298cbc3c3b34dabc1aabc03dcbe1900c458b2374 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 00:09:03 +0800 Subject: [PATCH 11/16] others --- .../PreparedStatementExecuteMethodsInterceptor.java | 2 +- .../impala/StatementExecuteMethodsInterceptor.java | 2 +- .../jdbc/ConnectionServiceMethodInterceptor.java | 2 +- .../plugin/jdbc/trace/CallableStatementTracing.java | 2 +- .../plugin/jdbc/trace/PreparedStatementTracing.java | 2 +- .../apm/plugin/jdbc/trace/StatementTracing.java | 2 +- .../skywalking/apm/plugin/jdbc/ConnectionTracing.java | 2 +- .../config/expectedData.yaml | 10 +++++----- .../config/expectedData.yaml | 10 +++++----- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptor.java index 961f04ba44..ab4a581efc 100644 --- a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptor.java @@ -45,7 +45,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] } AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, SqlBodyUtil.limitSqlBodySize(cacheObject.getSql())); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptor.java index 95715a66e2..934e8be563 100644 --- a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptor.java @@ -40,7 +40,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] if (connectInfo != null) { AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject .getStatementName()), connectInfo.getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); String sql = allArguments.length > 0 ? (String) allArguments[0] : ""; sql = SqlBodyUtil.limitSqlBodySize(sql); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java index 13ba64bf52..1c53e939d8 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java @@ -41,7 +41,7 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] if (connectInfo != null) { AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBC/Connection/" + method.getName(), connectInfo .getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, ""); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java index 6ac7415e54..58bea0fd22 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java @@ -35,7 +35,7 @@ public static R execute(java.sql.CallableStatement realStatement, Connection AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBC/CallableStatement/" + method, connectInfo .getDatabasePeer()); try { - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); SpanLayer.asDB(span); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java index 6ef4a070fa..016fd6943c 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java @@ -35,7 +35,7 @@ public static R execute(java.sql.PreparedStatement realStatement, Connection final AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBC/PreparedStatement/" + method, connectInfo .getDatabasePeer()); try { - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/StatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/StatementTracing.java index b294bf9c39..c94b777441 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/StatementTracing.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/trace/StatementTracing.java @@ -34,7 +34,7 @@ public static R execute(java.sql.Statement realStatement, ConnectionInfo con try { AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBC/Statement/" + method, connectInfo .getDatabasePeer()); - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); span.setComponent(connectInfo.getComponent()); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionTracing.java index c15346df66..11ea2d5017 100755 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionTracing.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/ConnectionTracing.java @@ -32,7 +32,7 @@ public static R execute(java.sql.Connection realConnection, ConnectionInfo c AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBC/Connection/" + method, connectInfo .getDatabasePeer()); try { - Tags.DB_TYPE.set(span, "sql"); + Tags.DB_TYPE.set(span, connectInfo.getDBType()); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); span.setComponent(connectInfo.getComponent()); diff --git a/test/plugin/scenarios/impala-jdbc-2.6.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/impala-jdbc-2.6.x-scenario/config/expectedData.yaml index e1a6d92f61..c6bcc6455e 100644 --- a/test/plugin/scenarios/impala-jdbc-2.6.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/impala-jdbc-2.6.x-scenario/config/expectedData.yaml @@ -31,7 +31,7 @@ segmentItems: peer: impala-server:21050 skipAnalysis: 'false' tags: - - { key: db.type, value: sql } + - {key: db.type, value: Impala} - { key: db.instance, value: '' } - key: db.statement value: "CREATE TABLE IF NOT EXISTS default.impala_test (test_id BIGINT, test_name STRING);" @@ -47,7 +47,7 @@ segmentItems: peer: impala-server:21050 skipAnalysis: 'false' tags: - - { key: db.type, value: sql } + - {key: db.type, value: Impala} - { key: db.instance, value: '' } - key: db.statement value: "INSERT INTO impala_test VALUES (123, 'test');" @@ -63,7 +63,7 @@ segmentItems: peer: impala-server:21050 skipAnalysis: 'false' tags: - - { key: db.type, value: sql } + - {key: db.type, value: Impala} - { key: db.instance, value: '' } - key: db.statement value: "SELECT COUNT(*) FROM impala_test;" @@ -79,7 +79,7 @@ segmentItems: peer: impala-server:21050 skipAnalysis: 'false' tags: - - { key: db.type, value: sql } + - {key: db.type, value: Impala} - { key: db.instance, value: '' } - key: db.statement value: 'SELECT COUNT(*) FROM impala_test WHERE test_id = ?;' @@ -96,7 +96,7 @@ segmentItems: peer: impala-server:21050 skipAnalysis: 'false' tags: - - { key: db.type, value: sql } + - {key: db.type, value: Impala} - { key: db.instance, value: '' } - { key: db.statement, value: '' } - operationName: HEAD:/impala-jdbc-2.6.x-scenario/case/healthCheck diff --git a/test/plugin/scenarios/shardingsphere-5.0.0-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-5.0.0-scenario/config/expectedData.yaml index 1d56d8c3fb..c938742f49 100644 --- a/test/plugin/scenarios/shardingsphere-5.0.0-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-5.0.0-scenario/config/expectedData.yaml @@ -32,7 +32,7 @@ segmentItems: peer: localhost:-1 skipAnalysis: false tags: - - { key: db.type, value: sql} + - { key: db.type, value: H2} - { key: db.instance, value: not null} - { key: db.statement, value: not null} - segmentId: not null @@ -50,7 +50,7 @@ segmentItems: peer: localhost:-1 skipAnalysis: false tags: - - { key: db.type, value: sql } + - {key: db.type, value: H2} - { key: db.instance, value: not null } - { key: db.statement, value: not null } - operationName: /ShardingSphere/executeSQL/ @@ -85,7 +85,7 @@ segmentItems: peer: localhost:-1 skipAnalysis: false tags: - - { key: db.type, value: sql } + - {key: db.type, value: H2} - { key: db.instance, value: not null } - { key: db.statement, value: '' } - segmentId: not null @@ -103,7 +103,7 @@ segmentItems: peer: localhost:-1 skipAnalysis: false tags: - - { key: db.type, value: sql } + - {key: db.type, value: H2} - { key: db.instance, value: not null } - { key: db.statement, value: not null } - operationName: /ShardingSphere/executeSQL/ @@ -172,7 +172,7 @@ segmentItems: peer: localhost:-1 skipAnalysis: false tags: - - { key: db.type, value: sql } + - {key: db.type, value: H2} - { key: db.instance, value: not null } - { key: db.statement, value: not null } - operationName: /ShardingSphere/executeSQL/ From b3108ccb8e46531ad3e292922c222a0a4b3b0802 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 08:28:27 +0800 Subject: [PATCH 12/16] fix yaml error --- .../mssql-jtds-scenario/config/expectedData.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml b/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml index 0b285736a8..e450045d67 100644 --- a/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml @@ -23,7 +23,7 @@ segmentItems: parentSpanId: 0 spanId: 1 tags: - {key: db.type, value: Mssql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -41,7 +41,7 @@ segmentItems: parentSpanId: 0 spanId: 2 tags: - {key: db.type, value: Mssql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} logs: [] @@ -57,7 +57,7 @@ segmentItems: parentSpanId: 0 spanId: 3 tags: - {key: db.type, value: Mssql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: DROP table test_007} logs: [] @@ -73,7 +73,7 @@ segmentItems: parentSpanId: 0 spanId: 4 tags: - {key: db.type, value: Mssql} + - {key: db.type, value: Mssql} - {key: db.instance, value: tempdb} - {key: db.statement, value: ''} logs: [] From a7ff17f6c4ee5bc62115ea5e1c589bad794ed60f Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 08:38:53 +0800 Subject: [PATCH 13/16] fix unit test --- .../clickhouse/ClickHouseStatementMethodInterceptorTest.java | 2 +- .../PreparedStatementExecuteMethodsInterceptorTest.java | 4 ++-- .../jdbc/impala/StatementExecuteMethodsInterceptorTest.java | 4 ++-- .../skywalking/apm/plugin/jdbc/AbstractStatementTest.java | 2 +- .../kylin/PreparedStatementExecuteMethodsInterceptorTest.java | 4 ++-- .../jdbc/kylin/StatementExecuteMethodsInterceptorTest.java | 4 ++-- .../v2/PreparedStatementExecuteMethodsInterceptorTest.java | 4 ++-- .../mariadb/v2/StatementExecuteMethodsInterceptorTest.java | 4 ++-- .../jdbc/mysql/StatementExecuteMethodsInterceptorTest.java | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementMethodInterceptorTest.java index 594d38043e..60abd47625 100644 --- a/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementMethodInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/clickhouse-0.3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/clickhouse/ClickHouseStatementMethodInterceptorTest.java @@ -121,7 +121,7 @@ private void assertSpan(final AbstractTracingSpan span) throws JsonProcessingExc SpanAssert.assertComponent(span, ComponentsDefine.CLICKHOUSE_JDBC_DRIVER); SpanAssert.assertLayer(span, SpanLayer.DB); SpanAssert.assertTagSize(span, 3); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "ClickHouse"); SpanAssert.assertTag(span, 1, "default"); SpanAssert.assertTag(span, 2, SQL); } diff --git a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptorTest.java index a73cf70ba8..33a651c137 100644 --- a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/PreparedStatementExecuteMethodsInterceptorTest.java @@ -115,7 +115,7 @@ public void testExecutePreparedStatement() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Impala/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Impala"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); @@ -145,7 +145,7 @@ public void testExecutePreparedStatementWithLimitSqlBody() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Impala/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Impala"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); diff --git a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptorTest.java index 4dcb6f45bc..052b59f004 100644 --- a/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/impala-jdbc-2.6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/impala/StatementExecuteMethodsInterceptorTest.java @@ -98,7 +98,7 @@ public void testExecuteStatement() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Impala/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Impala"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); } @@ -115,7 +115,7 @@ public void testExecuteStatementWithLimitSqlBody() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Impala/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Impala"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); } diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/AbstractStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/AbstractStatementTest.java index 279a3d30fe..b6a1640b42 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/AbstractStatementTest.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/AbstractStatementTest.java @@ -53,7 +53,7 @@ protected void assertDBSpan(AbstractTracingSpan span, String exceptOperationName assertThat(span.getOperationName(), is(exceptOperationName)); assertThat(SpanHelper.getComponentId(span), is(33)); List tags = SpanHelper.getTags(span); - assertThat(tags.get(0).getValue(), is("sql")); + assertThat(tags.get(0).getValue(), is("Mysql")); assertThat(tags.get(1).getValue(), is("test")); assertThat(SpanHelper.getLayer(span), CoreMatchers.is(SpanLayer.DB)); } diff --git a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptorTest.java index afbe04ac60..78e17281c0 100644 --- a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/PreparedStatementExecuteMethodsInterceptorTest.java @@ -114,7 +114,7 @@ public void testExecutePreparedStatement() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("kylin/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "kylin"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); @@ -144,7 +144,7 @@ public void testExecutePreparedStatementWithLimitSqlBody() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("kylin/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "kylin"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); diff --git a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptorTest.java index b4f0b07441..d0847b8e26 100644 --- a/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/kylin-jdbc-2.6.x-3.x-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/kylin/StatementExecuteMethodsInterceptorTest.java @@ -97,7 +97,7 @@ public void testExecuteStatement() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("kylin/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "kylin"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); } @@ -114,7 +114,7 @@ public void testExecuteStatementWithLimitSqlBody() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("kylin/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "kylin"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); } diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java index 2c42a540df..a50bab1234 100644 --- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java @@ -114,7 +114,7 @@ public void testExecutePreparedStatement() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Mariadb/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Mariadb"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); @@ -144,7 +144,7 @@ public void testExecutePreparedStatementWithLimitSqlBody() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Mariadb/JDBC/PreparedStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Mariadb"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); SpanAssert.assertTag(span, 3, "[abcd,efgh]"); diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptorTest.java index 59cab1e2a1..593dc65f99 100644 --- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/StatementExecuteMethodsInterceptorTest.java @@ -98,7 +98,7 @@ public void testExecuteStatement() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Mariadb/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Mariadb"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); } @@ -115,7 +115,7 @@ public void testExecuteStatementWithLimitSqlBody() { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("Mariadb/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "Mariadb"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "Select * f..."); } diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java index a3db1d3ceb..bad4c65870 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java @@ -98,7 +98,7 @@ public void testCreateDatabaseSpan() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("H2/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "H2"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, SQL); } @@ -116,7 +116,7 @@ public void testCreateDatabaseSpanWithLimitSqlBody() throws Throwable { AbstractTracingSpan span = SegmentHelper.getSpans(segment).get(0); SpanAssert.assertLayer(span, SpanLayer.DB); assertThat(span.getOperationName(), is("H2/JDBC/CallableStatement/")); - SpanAssert.assertTag(span, 0, "sql"); + SpanAssert.assertTag(span, 0, "H2"); SpanAssert.assertTag(span, 1, "test"); SpanAssert.assertTag(span, 2, "SELECT * F..."); } From 028701a5298d3026187c9714503b98a149828474 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 10:02:24 +0800 Subject: [PATCH 14/16] oracle --- .../scenarios/oracle-scenario/config/expectedData.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml b/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml index 61fcd24fdb..91df4be88d 100644 --- a/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Exit peer: oracle-server:1521 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Oracle} - {key: db.instance, value: xe} - key: db.statement value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ @@ -47,7 +47,7 @@ segmentItems: spanType: Exit peer: oracle-server:1521 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Oracle} - {key: db.instance, value: xe} - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} skipAnalysis: 'false' @@ -62,7 +62,7 @@ segmentItems: spanType: Exit peer: oracle-server:1521 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Oracle} - {key: db.instance, value: xe} - {key: db.statement, value: 'SELECT id, value FROM test_007 WHERE id=?'} skipAnalysis: 'false' @@ -77,7 +77,7 @@ segmentItems: spanType: Exit peer: oracle-server:1521 tags: - - {key: db.type, value: sql} + - {key: db.type, value: Oracle} - {key: db.instance, value: xe} - {key: db.statement, value: DROP table test_007} skipAnalysis: 'false' @@ -86,7 +86,7 @@ segmentItems: spanId: 5 spanLayer: Database tags: - - {key: db.type, value: sql} + - {key: db.type, value: Oracle} - {key: db.instance, value: xe} - {key: db.statement, value: ''} startTime: nq 0 From 02eb4d75dfcad5f648de7f38ecbf4fc73504ed2b Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 11:27:37 +0800 Subject: [PATCH 15/16] oracle test cicd --- .github/workflows/plugins-test.3.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index bbea834d32..0a8cdab1d9 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -121,7 +121,7 @@ jobs: run: | mkdir -p skywalking-agent/plugins curl -O https://skyapm.github.io/ci-assist/jars/ojdbc14-10.2.0.4.0.jar - curl -L -o ./skywalking-agent/plugins/apm-oracle-10.x-plugin-2.0.0.jar https://github.com/SkyAPM/java-plugin-extensions/releases/download/2.3.0/apm-oracle-10.x-plugin-2.3.0.jar + curl -L -o ./skywalking-agent/plugins/apm-oracle-10.x-plugin-2.3.1.jar https://github.com/SkyAPM/java-plugin-extensions/releases/download/2.3.1/apm-oracle-10.x-plugin-2.3.1.jar ./mvnw -q --batch-mode install:install-file -Dfile=ojdbc14-10.2.0.4.0.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar - name: Run Plugin Test uses: ./.github/actions/run From 9cdec6085d67466c978792286fc566d327977d97 Mon Sep 17 00:00:00 2001 From: "pg.yang" Date: Wed, 23 Nov 2022 12:21:17 +0800 Subject: [PATCH 16/16] changes.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f9dcab4ab5..76127d2d52 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Release Notes. * Bump up byte-buddy to 1.12.19 * Upgrade agent test tools * [Breaking Change] Compatible with 3.x and 4.x RabbitMQ Client, rename `rabbitmq-5.x-plugin` to `rabbitmq-plugin` +* Polish JDBC plugins to make DBType accurate #### Documentation