This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 135e61f Remove hook interface (#8957)
135e61f is described below
commit 135e61f24a728bc79a560999a293316b02e9dd42
Author: xiaoyu <[email protected]>
AuthorDate: Mon Jan 11 12:48:41 2021 +0800
Remove hook interface (#8957)
* remove hook interface for OpenTracing
---
pom.xml | 15 --
.../shardingsphere/infra/hook/RootInvokeHook.java | 36 -----
.../infra/hook/SPIRootInvokeHook.java | 48 ------
.../properties/ConfigurationPropertiesTest.java | 3 -
.../infra/hook/SPIRootInvokeHookTest.java | 47 ------
.../infra/hook/fixture/RootInvokeHookFixture.java | 55 -------
.../parser/ShardingSphereSQLParserEngine.java | 10 +-
.../infra/parser/hook/ParsingHook.java | 47 ------
.../infra/parser/hook/ParsingHookRegistry.java | 76 ----------
.../infra/parser/hook/ParsingHookRegistryTest.java | 52 -------
.../parser/hook/fixture/ParsingHookFixture.java | 61 --------
.../jdbc/adapter/AbstractConnectionAdapter.java | 7 -
shardingsphere-observability/pom.xml | 35 -----
.../shardingsphere-tracing/pom.xml | 35 -----
.../shardingsphere-tracing-opentracing/pom.xml | 46 ------
.../tracing/opentracing/OpenTracingTracer.java | 71 ---------
.../constant/ShardingErrorLogTagKeys.java | 36 -----
.../tracing/opentracing/constant/ShardingTags.java | 44 ------
.../opentracing/hook/OpenTracingParsingHook.java | 54 -------
.../hook/OpenTracingRootInvokeHook.java | 48 ------
.../hook/OpenTracingSQLExecutionHook.java | 84 -----------
.../opentracing/hook/ShardingErrorSpan.java | 52 -------
...sphere.infra.executor.sql.hook.SQLExecutionHook | 18 ---
...apache.shardingsphere.infra.hook.RootInvokeHook | 18 ---
...he.shardingsphere.infra.parser.hook.ParsingHook | 18 ---
.../tracing/opentracing/OpenTracingTracerTest.java | 89 ------------
.../tracing/opentracing/fixture/FooTracer.java | 51 -------
.../opentracing/hook/BaseOpenTracingHookTest.java | 76 ----------
.../hook/OpenTracingParsingHookTest.java | 70 ---------
.../hook/OpenTracingRootInvokeHookTest.java | 44 ------
.../hook/OpenTracingSQLExecutionHookTest.java | 161 ---------------------
.../org.mockito.plugins.MockMaker | 18 ---
.../shardingsphere-proxy-bootstrap/pom.xml | 6 -
.../impl/AbstractBootstrapInitializer.java | 8 -
.../frontend/command/CommandExecutorTask.java | 7 -
.../frontend/command/CommandExecutorTaskTest.java | 3 -
36 files changed, 1 insertion(+), 1548 deletions(-)
diff --git a/pom.xml b/pom.xml
index fc622bb..a600b3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,6 @@
<module>shardingsphere-scaling</module>
<module>shardingsphere-transaction</module>
<module>shardingsphere-governance</module>
- <module>shardingsphere-observability</module>
<module>shardingsphere-test</module>
<module>shardingsphere-distribution</module>
@@ -78,7 +77,6 @@
<btm.version>2.1.3</btm.version>
<curator.version>5.1.0</curator.version>
- <opentracing.version>0.30.0</opentracing.version>
<apollo.client.version>1.5.0</apollo.client.version>
<nacos.client.verison>1.1.4</nacos.client.verison>
<jetcd.version>0.5.0</jetcd.version>
@@ -313,13 +311,6 @@
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
-
- <dependency>
- <groupId>io.opentracing</groupId>
- <artifactId>opentracing-util</artifactId>
- <version>${opentracing.version}</version>
- </dependency>
-
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
@@ -453,12 +444,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>io.opentracing</groupId>
- <artifactId>opentracing-mock</artifactId>
- <version>${opentracing.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/RootInvokeHook.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/RootInvokeHook.java
deleted file mode 100644
index 7204598..0000000
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/RootInvokeHook.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.hook;
-
-/**
- * Root invoke hook.
- */
-public interface RootInvokeHook {
-
- /**
- * Handle when root invoke started.
- */
- void start();
-
- /**
- * Handle when root invoke finished.
- *
- * @param connectionCount connection count
- */
- void finish(int connectionCount);
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHook.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHook.java
deleted file mode 100644
index 1fe4e4f..0000000
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHook.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.hook;
-
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-
-import java.util.Collection;
-
-/**
- * Root invoke hook for SPI.
- */
-public final class SPIRootInvokeHook implements RootInvokeHook {
-
- private final Collection<RootInvokeHook> rootInvokeHooks =
ShardingSphereServiceLoader.newServiceInstances(RootInvokeHook.class);
-
- static {
- ShardingSphereServiceLoader.register(RootInvokeHook.class);
- }
-
- @Override
- public void start() {
- for (RootInvokeHook each : rootInvokeHooks) {
- each.start();
- }
- }
-
- @Override
- public void finish(final int connectionCount) {
- for (RootInvokeHook each : rootInvokeHooks) {
- each.finish(connectionCount);
- }
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
index 277ff81..f2dc28e 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
@@ -39,7 +39,6 @@ public final class ConfigurationPropertiesTest {
props.setProperty(ConfigurationPropertyKey.QUERY_WITH_CIPHER_COLUMN.getKey(),
Boolean.FALSE.toString());
props.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD.getKey(),
"20");
props.setProperty(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE.getKey(),
"XA");
-
props.setProperty(ConfigurationPropertyKey.PROXY_OPENTRACING_ENABLED.getKey(),
Boolean.TRUE.toString());
props.setProperty(ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey(),
Boolean.TRUE.toString());
props.setProperty(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED.getKey(),
Boolean.TRUE.toString());
ConfigurationProperties actual = new ConfigurationProperties(props);
@@ -51,7 +50,6 @@ public final class ConfigurationPropertiesTest {
assertFalse(actual.getValue(ConfigurationPropertyKey.QUERY_WITH_CIPHER_COLUMN));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD),
is(20));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE),
is("XA"));
-
assertTrue(actual.getValue(ConfigurationPropertyKey.PROXY_OPENTRACING_ENABLED));
assertTrue(actual.getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED));
assertTrue(actual.getValue(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED));
}
@@ -67,7 +65,6 @@ public final class ConfigurationPropertiesTest {
assertTrue(actual.getValue(ConfigurationPropertyKey.QUERY_WITH_CIPHER_COLUMN));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD),
is(128));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE),
is("LOCAL"));
-
assertFalse(actual.getValue(ConfigurationPropertyKey.PROXY_OPENTRACING_ENABLED));
assertFalse(actual.getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED));
assertFalse(actual.getValue(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED));
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHookTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHookTest.java
deleted file mode 100644
index dc4d91f..0000000
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/SPIRootInvokeHookTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.hook;
-
-import org.apache.shardingsphere.infra.hook.fixture.RootInvokeHookFixture;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public final class SPIRootInvokeHookTest {
-
- private SPIRootInvokeHook spiRootInvokeHook;
-
- @Before
- public void setUp() {
- RootInvokeHookFixture.clearActions();
- spiRootInvokeHook = new SPIRootInvokeHook();
- }
-
- @Test
- public void assertStart() {
- spiRootInvokeHook.start();
- assertTrue(RootInvokeHookFixture.containsAction("start"));
- }
-
- @Test
- public void assertFinishSuccess() {
- spiRootInvokeHook.finish(0);
- assertTrue(RootInvokeHookFixture.containsAction("finish"));
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/fixture/RootInvokeHookFixture.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/fixture/RootInvokeHookFixture.java
deleted file mode 100644
index 0e3cf26..0000000
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hook/fixture/RootInvokeHookFixture.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.hook.fixture;
-
-import org.apache.shardingsphere.infra.hook.RootInvokeHook;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-public final class RootInvokeHookFixture implements RootInvokeHook {
-
- private static final Collection<String> ACTIONS = new LinkedList<>();
-
- @Override
- public void start() {
- ACTIONS.add("start");
- }
-
- @Override
- public void finish(final int connectionCount) {
- ACTIONS.add("finish");
- }
-
- /**
- * Contains action or not.
- *
- * @param action action
- * @return contains action or not
- */
- public static boolean containsAction(final String action) {
- return ACTIONS.contains(action);
- }
-
- /**
- * Clear actions.
- */
- public static void clearActions() {
- ACTIONS.clear();
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/ShardingSphereSQLParserEngine.java
b/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/ShardingSphereSQLParserEngine.java
index 2f93521..42608f4 100644
---
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/ShardingSphereSQLParserEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/ShardingSphereSQLParserEngine.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.infra.parser;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import
org.apache.shardingsphere.distsql.parser.api.DistSQLStatementParserEngine;
-import org.apache.shardingsphere.infra.parser.hook.ParsingHookRegistry;
import org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine;
import
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngineFactory;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
@@ -34,12 +33,9 @@ public final class ShardingSphereSQLParserEngine {
private final DistSQLStatementParserEngine distSQLStatementParserEngine;
- private final ParsingHookRegistry parsingHookRegistry;
-
public ShardingSphereSQLParserEngine(final String databaseTypeName) {
sqlStatementParserEngine =
SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseTypeName);
distSQLStatementParserEngine = new DistSQLStatementParserEngine();
- parsingHookRegistry = ParsingHookRegistry.getInstance();
}
/*
@@ -56,16 +52,12 @@ public final class ShardingSphereSQLParserEngine {
*/
@SuppressWarnings("OverlyBroadCatchBlock")
public SQLStatement parse(final String sql, final boolean useCache) {
- parsingHookRegistry.start(sql);
try {
- SQLStatement result = parse0(sql, useCache);
- parsingHookRegistry.finishSuccess(result);
- return result;
+ return parse0(sql, useCache);
// CHECKSTYLE:OFF
// TODO check whether throw SQLParsingException only
} catch (final Exception ex) {
// CHECKSTYLE:ON
- parsingHookRegistry.finishFailure(ex);
throw ex;
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHook.java
b/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHook.java
deleted file mode 100644
index b2f9028..0000000
---
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHook.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.parser.hook;
-
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-/**
- * Parsing hook.
- */
-public interface ParsingHook {
-
- /**
- * Handle when parse started.
- *
- * @param sql SQL to be parsed
- */
- void start(String sql);
-
- /**
- * Handle when parse finished success.
- *
- * @param sqlStatement sql statement
- */
- void finishSuccess(SQLStatement sqlStatement);
-
- /**
- * Handle when parse finished failure.
- *
- * @param cause failure cause
- */
- void finishFailure(Exception cause);
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistry.java
b/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistry.java
deleted file mode 100644
index 4a600ef..0000000
---
a/shardingsphere-infra/shardingsphere-infra-parser/src/main/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.parser.hook;
-
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.ServiceLoader;
-
-/**
- * Parsing hook registry.
- */
-public final class ParsingHookRegistry {
-
- private static final ParsingHookRegistry INSTANCE = new
ParsingHookRegistry();
-
- private final Collection<ParsingHook> hooks = new LinkedList<>();
-
- private ParsingHookRegistry() {
- for (ParsingHook each : ServiceLoader.load(ParsingHook.class)) {
- hooks.add(each);
- }
- }
-
- /**
- * Get instance.
- *
- * @return instance
- */
- public static ParsingHookRegistry getInstance() {
- return INSTANCE;
- }
-
- /**
- * Handle when parse started.
- *
- * @param sql SQL to be parsed
- */
- public void start(final String sql) {
- hooks.forEach(each -> each.start(sql));
- }
-
- /**
- * Handle when parse finished success.
- *
- * @param sqlStatement sql statement
- */
- public void finishSuccess(final SQLStatement sqlStatement) {
- hooks.forEach(each -> each.finishSuccess(sqlStatement));
- }
-
- /**
- * Handle when parse finished failure.
- *
- * @param cause failure cause
- */
- public void finishFailure(final Exception cause) {
- hooks.forEach(each -> each.finishFailure(cause));
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistryTest.java
b/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistryTest.java
deleted file mode 100644
index 4d90d97..0000000
---
a/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/ParsingHookRegistryTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.parser.hook;
-
-import org.apache.shardingsphere.infra.parser.hook.fixture.ParsingHookFixture;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public final class ParsingHookRegistryTest {
-
- private final ParsingHookRegistry registry =
ParsingHookRegistry.getInstance();
-
- @Before
- public void setUp() {
- ParsingHookFixture.clearActions();
- }
-
- @Test
- public void assertStart() {
- registry.start("");
- assertTrue(ParsingHookFixture.containsAction("start"));
- }
-
- @Test
- public void assertFinishSuccess() {
- registry.finishSuccess(null);
- assertTrue(ParsingHookFixture.containsAction("finishSuccess"));
- }
-
- @Test
- public void assertFinishFailure() {
- registry.finishFailure(null);
- assertTrue(ParsingHookFixture.containsAction("finishFailure"));
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/fixture/ParsingHookFixture.java
b/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/fixture/ParsingHookFixture.java
deleted file mode 100644
index 1f0fa36..0000000
---
a/shardingsphere-infra/shardingsphere-infra-parser/src/test/java/org/apache/shardingsphere/infra/parser/hook/fixture/ParsingHookFixture.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.parser.hook.fixture;
-
-import org.apache.shardingsphere.infra.parser.hook.ParsingHook;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-public final class ParsingHookFixture implements ParsingHook {
-
- private static final Collection<String> ACTIONS = new LinkedList<>();
-
- @Override
- public void start(final String sql) {
- ACTIONS.add("start");
- }
-
- @Override
- public void finishSuccess(final SQLStatement sqlStatement) {
- ACTIONS.add("finishSuccess");
- }
-
- @Override
- public void finishFailure(final Exception cause) {
- ACTIONS.add("finishFailure");
- }
-
- /**
- * Contains action or not.
- *
- * @param action action
- * @return contains action or not
- */
- public static boolean containsAction(final String action) {
- return ACTIONS.contains(action);
- }
-
- /**
- * Clear actions.
- */
- public static void clearActions() {
- ACTIONS.clear();
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractConnectionAdapter.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractConnectionAdapter.java
index 066ce3a..91272b5 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractConnectionAdapter.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractConnectionAdapter.java
@@ -22,8 +22,6 @@ import com.google.common.collect.Multimap;
import lombok.Getter;
import
org.apache.shardingsphere.driver.jdbc.adapter.executor.ForceExecuteTemplate;
import
org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedOperationConnection;
-import org.apache.shardingsphere.infra.hook.RootInvokeHook;
-import org.apache.shardingsphere.infra.hook.SPIRootInvokeHook;
import
org.apache.shardingsphere.replicaquery.route.engine.impl.PrimaryVisitedManager;
import java.sql.Connection;
@@ -46,8 +44,6 @@ public abstract class AbstractConnectionAdapter extends
AbstractUnsupportedOpera
@Getter
private final ForceExecuteTemplate<Entry<String, Connection>>
forceExecuteTemplateForClose = new ForceExecuteTemplate<>();
- private final RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();
-
private boolean readOnly;
private volatile boolean closed;
@@ -55,19 +51,16 @@ public abstract class AbstractConnectionAdapter extends
AbstractUnsupportedOpera
private int transactionIsolation = TRANSACTION_READ_UNCOMMITTED;
protected AbstractConnectionAdapter() {
- rootInvokeHook.start();
}
@Override
public final void close() throws SQLException {
closed = true;
PrimaryVisitedManager.clear();
- int connectionSize = cachedConnections.size();
try {
forceExecuteTemplateForClose.execute(cachedConnections.entries(),
cachedConnections -> cachedConnections.getValue().close());
} finally {
cachedConnections.clear();
- rootInvokeHook.finish(connectionSize);
}
}
diff --git a/shardingsphere-observability/pom.xml
b/shardingsphere-observability/pom.xml
deleted file mode 100644
index f80452c..0000000
--- a/shardingsphere-observability/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
- <version>5.0.0-RC1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-observability</artifactId>
- <name>${project.artifactId}</name>
- <packaging>pom</packaging>
-
- <modules>
- <module>shardingsphere-tracing</module>
- </modules>
-</project>
diff --git a/shardingsphere-observability/shardingsphere-tracing/pom.xml
b/shardingsphere-observability/shardingsphere-tracing/pom.xml
deleted file mode 100644
index 0fbc67a..0000000
--- a/shardingsphere-observability/shardingsphere-tracing/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-observability</artifactId>
- <version>5.0.0-RC1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-tracing</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-
- <modules>
- <module>shardingsphere-tracing-opentracing</module>
- </modules>
-</project>
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/pom.xml
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/pom.xml
deleted file mode 100644
index b509bae..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/pom.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-tracing</artifactId>
- <version>5.0.0-RC1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-tracing-opentracing</artifactId>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-infra-executor</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>io.opentracing</groupId>
- <artifactId>opentracing-util</artifactId>
- </dependency>
- <dependency>
- <groupId>io.opentracing</groupId>
- <artifactId>opentracing-mock</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracer.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracer.java
deleted file mode 100644
index 2304250..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing;
-
-import com.google.common.base.Preconditions;
-import io.opentracing.Tracer;
-import io.opentracing.util.GlobalTracer;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-
-/**
- * OpenTracing tracer object container.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class OpenTracingTracer {
-
- public static final String OPENTRACING_TRACER_CLASS_NAME =
"org.apache.shardingsphere.tracing.opentracing.tracer.class";
-
- /**
- * Initialize sharding tracer.
- */
- public static void init() {
- doInit();
- }
-
- /**
- * Initialize sharding tracer.
- *
- * @param tracer opentracing tracer
- */
- public static void init(final Tracer tracer) {
- if (!GlobalTracer.isRegistered()) {
- GlobalTracer.register(tracer);
- }
- }
-
- /**
- * Get tracer.
- *
- * @return tracer
- */
- public static Tracer get() {
- return GlobalTracer.get();
- }
-
- private static void doInit() {
- String tracerClassName =
System.getProperty(OPENTRACING_TRACER_CLASS_NAME);
- Preconditions.checkNotNull(tracerClassName, "Can not find opentracing
tracer implementation class via system property `%s`",
OPENTRACING_TRACER_CLASS_NAME);
- try {
- init((Tracer) Class.forName(tracerClassName).newInstance());
- } catch (final ReflectiveOperationException ex) {
- throw new ShardingSphereException("Initialize opentracing tracer
class failure.", ex);
- }
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingErrorLogTagKeys.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingErrorLogTagKeys.java
deleted file mode 100644
index 0e4193c..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingErrorLogTagKeys.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.constant;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Sharding error log tag keys.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingErrorLogTagKeys {
-
- public static final String EVENT = "event";
-
- public static final String EVENT_ERROR_TYPE = "error";
-
- public static final String ERROR_KIND = "error.kind";
-
- public static final String MESSAGE = "message";
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingTags.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingTags.java
deleted file mode 100644
index 3797b8a..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/constant/ShardingTags.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.constant;
-
-import io.opentracing.tag.StringTag;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Sharding tags.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingTags {
-
- /**
- * Component name of ShardingSphere's open tracing tag.
- */
- public static final String COMPONENT_NAME = "ShardingSphere";
-
- /**
- * The tag to record the bind variables of SQL.
- */
- public static final StringTag DB_BIND_VARIABLES = new
StringTag("db.bind_vars");
-
- /**
- * The tag to record the connection count.
- */
- public static final StringTag CONNECTION_COUNT = new
StringTag("connection.count");
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHook.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHook.java
deleted file mode 100644
index 21aa4f6..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHook.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.Span;
-import io.opentracing.tag.Tags;
-import org.apache.shardingsphere.infra.parser.hook.ParsingHook;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
-import org.apache.shardingsphere.tracing.opentracing.constant.ShardingTags;
-
-/**
- * Open tracing parsing hook.
- */
-public final class OpenTracingParsingHook implements ParsingHook {
-
- private static final String OPERATION_NAME = "/" +
ShardingTags.COMPONENT_NAME + "/parseSQL/";
-
- private Span span;
-
- @Override
- public void start(final String sql) {
- span = OpenTracingTracer.get().buildSpan(OPERATION_NAME)
- .withTag(Tags.COMPONENT.getKey(), ShardingTags.COMPONENT_NAME)
- .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
- .withTag(Tags.DB_STATEMENT.getKey(), sql).startManual();
- }
-
- @Override
- public void finishSuccess(final SQLStatement sqlStatement) {
- span.finish();
- }
-
- @Override
- public void finishFailure(final Exception cause) {
- ShardingErrorSpan.setError(span, cause);
- span.finish();
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHook.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHook.java
deleted file mode 100644
index a71c102..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHook.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.ActiveSpan;
-import io.opentracing.tag.Tags;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
-import org.apache.shardingsphere.infra.hook.RootInvokeHook;
-import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
-import org.apache.shardingsphere.tracing.opentracing.constant.ShardingTags;
-
-/**
- * Open tracing root invoke hook.
- */
-public final class OpenTracingRootInvokeHook implements RootInvokeHook {
-
- public static final String ACTIVE_SPAN_CONTINUATION =
"ACTIVE_SPAN_CONTINUATION";
-
- private static final String OPERATION_NAME = "/" +
ShardingTags.COMPONENT_NAME + "/rootInvoke/";
-
- private ActiveSpan activeSpan;
-
- @Override
- public void start() {
- activeSpan =
OpenTracingTracer.get().buildSpan(OPERATION_NAME).withTag(Tags.COMPONENT.getKey(),
ShardingTags.COMPONENT_NAME).startActive();
- ExecutorDataMap.getValue().put(ACTIVE_SPAN_CONTINUATION,
activeSpan.capture());
- }
-
- @Override
- public void finish(final int connectionCount) {
- activeSpan.setTag(ShardingTags.CONNECTION_COUNT.getKey(),
connectionCount).deactivate();
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHook.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHook.java
deleted file mode 100644
index 07566e0..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHook.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import com.google.common.base.Joiner;
-import io.opentracing.ActiveSpan;
-import io.opentracing.Span;
-import io.opentracing.tag.Tags;
-import org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook;
-import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
-import org.apache.shardingsphere.tracing.opentracing.constant.ShardingTags;
-import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Open tracing SQL execution hook.
- */
-public final class OpenTracingSQLExecutionHook implements SQLExecutionHook {
-
- private static final String OPERATION_NAME = "/" +
ShardingTags.COMPONENT_NAME + "/executeSQL/";
-
- private ActiveSpan activeSpan;
-
- private Span span;
-
- @Override
- public void start(final String dataSourceName, final String sql, final
List<Object> parameters,
- final DataSourceMetaData dataSourceMetaData, final
boolean isTrunkThread, final Map<String, Object> shardingExecuteDataMap) {
- if (!isTrunkThread) {
- activeSpan = ((ActiveSpan.Continuation)
shardingExecuteDataMap.get(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION)).activate();
- }
- span = OpenTracingTracer.get().buildSpan(OPERATION_NAME)
- .withTag(Tags.COMPONENT.getKey(), ShardingTags.COMPONENT_NAME)
- .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
- .withTag(Tags.PEER_HOSTNAME.getKey(),
dataSourceMetaData.getHostName())
- .withTag(Tags.PEER_PORT.getKey(), dataSourceMetaData.getPort())
- .withTag(Tags.DB_TYPE.getKey(), "sql")
- .withTag(Tags.DB_INSTANCE.getKey(), dataSourceName)
- .withTag(Tags.DB_STATEMENT.getKey(), sql)
- .withTag(ShardingTags.DB_BIND_VARIABLES.getKey(),
toString(parameters)).startManual();
-
- }
-
- private String toString(final List<Object> parameterSets) {
- if (null == parameterSets || parameterSets.isEmpty()) {
- return "";
- }
- return String.format("[%s]", Joiner.on(",
").useForNull("Null").join(parameterSets));
- }
-
- @Override
- public void finishSuccess() {
- span.finish();
- if (null != activeSpan) {
- activeSpan.deactivate();
- }
- }
-
- @Override
- public void finishFailure(final Exception cause) {
- ShardingErrorSpan.setError(span, cause);
- span.finish();
- if (null != activeSpan) {
- activeSpan.deactivate();
- }
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/ShardingErrorSpan.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/ShardingErrorSpan.java
deleted file mode 100644
index 5855192..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/java/org/apache/shardingsphere/tracing/opentracing/hook/ShardingErrorSpan.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.Span;
-import io.opentracing.tag.Tags;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.tracing.opentracing.constant.ShardingErrorLogTagKeys;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Sharding error span.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingErrorSpan {
-
- /**
- * Set error.
- *
- * @param span span to be set
- * @param cause failure cause of span
- */
- public static void setError(final Span span, final Exception cause) {
- span.setTag(Tags.ERROR.getKey(), true).log(System.currentTimeMillis(),
getReason(cause));
- }
-
- private static Map<String, ?> getReason(final Throwable cause) {
- Map<String, String> result = new HashMap<>(3, 1);
- result.put(ShardingErrorLogTagKeys.EVENT,
ShardingErrorLogTagKeys.EVENT_ERROR_TYPE);
- result.put(ShardingErrorLogTagKeys.ERROR_KIND,
cause.getClass().getName());
- result.put(ShardingErrorLogTagKeys.MESSAGE, cause.getMessage());
- return result;
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook
deleted file mode 100644
index 4356f01..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.tracing.opentracing.hook.OpenTracingSQLExecutionHook
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.hook.RootInvokeHook
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.hook.RootInvokeHook
deleted file mode 100644
index 59335fe..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.hook.RootInvokeHook
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.tracing.opentracing.hook.OpenTracingRootInvokeHook
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.parser.hook.ParsingHook
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.parser.hook.ParsingHook
deleted file mode 100644
index 77fd104..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.parser.hook.ParsingHook
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.tracing.opentracing.hook.OpenTracingParsingHook
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracerTest.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracerTest.java
deleted file mode 100644
index 33c90d6..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/OpenTracingTracerTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing;
-
-import io.opentracing.NoopTracerFactory;
-import io.opentracing.Tracer;
-import io.opentracing.util.GlobalTracer;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.tracing.opentracing.fixture.FooTracer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.lang.reflect.Field;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.isA;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-public final class OpenTracingTracerTest {
-
- @Before
- public void setUp() {
- System.setProperty(OpenTracingTracer.OPENTRACING_TRACER_CLASS_NAME,
FooTracer.class.getName());
- clearGlobalTracer();
- }
-
- @After
- public void tearDown() {
-
System.getProperties().remove(OpenTracingTracer.OPENTRACING_TRACER_CLASS_NAME);
- }
-
- @Test
- public void assertDuplicatedLoading() {
- OpenTracingTracer.init(mock(Tracer.class));
- Tracer tracer = OpenTracingTracer.get();
- OpenTracingTracer.init();
- assertThat(OpenTracingTracer.get(), is(tracer));
- OpenTracingTracer.init(mock(Tracer.class));
- assertThat(OpenTracingTracer.get(), is(tracer));
- }
-
- @Test
- public void assertTracer() {
- OpenTracingTracer.init();
- assertThat((GlobalTracer) OpenTracingTracer.get(),
isA(GlobalTracer.class));
- assertTrue(GlobalTracer.isRegistered());
- assertThat(OpenTracingTracer.get(), is(OpenTracingTracer.get()));
- }
-
- @Test
- public void assertTracerSpiLoad() {
- OpenTracingTracer.init();
- assertThat((GlobalTracer) OpenTracingTracer.get(),
isA(GlobalTracer.class));
- assertTrue(GlobalTracer.isRegistered());
- assertThat(OpenTracingTracer.get(), is(OpenTracingTracer.get()));
- }
-
- @Test(expected = ShardingSphereException.class)
- public void assertTracerClassError() {
- System.setProperty(OpenTracingTracer.OPENTRACING_TRACER_CLASS_NAME,
"com.foo.FooTracer");
- OpenTracingTracer.init();
- }
-
- @SneakyThrows(ReflectiveOperationException.class)
- private static void clearGlobalTracer() {
- Field tracerField = GlobalTracer.class.getDeclaredField("tracer");
- tracerField.setAccessible(true);
- tracerField.set(GlobalTracer.class, NoopTracerFactory.create());
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/fixture/FooTracer.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/fixture/FooTracer.java
deleted file mode 100644
index 3d242d7..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/fixture/FooTracer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.fixture;
-
-import io.opentracing.ActiveSpan;
-import io.opentracing.Span;
-import io.opentracing.SpanContext;
-import io.opentracing.Tracer;
-import io.opentracing.propagation.Format;
-
-public final class FooTracer implements Tracer {
-
- @Override
- public SpanBuilder buildSpan(final String operationName) {
- return null;
- }
-
- @Override
- public <C> void inject(final SpanContext spanContext, final Format<C>
format, final C carrier) {
- }
-
- @Override
- public <C> SpanContext extract(final Format<C> format, final C carrier) {
- return null;
- }
-
- @Override
- public ActiveSpan activeSpan() {
- return null;
- }
-
- @Override
- public ActiveSpan makeActive(final Span span) {
- return null;
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
deleted file mode 100644
index d74189c..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.NoopTracerFactory;
-import io.opentracing.mock.MockSpan;
-import io.opentracing.mock.MockTracer;
-import io.opentracing.tag.Tags;
-import io.opentracing.util.GlobalTracer;
-import io.opentracing.util.ThreadLocalActiveSpanSource;
-import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
-import
org.apache.shardingsphere.tracing.opentracing.constant.ShardingErrorLogTagKeys;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public abstract class BaseOpenTracingHookTest {
-
- private static final MockTracer TRACER = new MockTracer(new
ThreadLocalActiveSpanSource(), MockTracer.Propagator.TEXT_MAP);
-
- @BeforeClass
- public static void initTracer() {
- OpenTracingTracer.init(TRACER);
- }
-
- @AfterClass
- public static void releaseTracer() throws NoSuchFieldException,
IllegalAccessException {
- Field field = GlobalTracer.class.getDeclaredField("tracer");
- field.setAccessible(true);
- field.set(GlobalTracer.class, NoopTracerFactory.create());
- }
-
- @Before
- public final void resetTracer() {
- TRACER.reset();
- }
-
- protected final MockSpan getActualSpan() {
- List<MockSpan> finishedSpans = TRACER.finishedSpans();
- assertThat(finishedSpans.size(), is(1));
- return finishedSpans.get(0);
- }
-
- protected final void assertSpanError(final Class<? extends Throwable>
expectedException, final String expectedErrorMessage) {
- MockSpan actual = getActualSpan();
- assertTrue((Boolean) actual.tags().get(Tags.ERROR.getKey()));
- List<MockSpan.LogEntry> actualLogEntries = actual.logEntries();
- assertThat(actualLogEntries.size(), is(1));
- assertThat(actualLogEntries.get(0).fields().size(), is(3));
-
assertThat(actualLogEntries.get(0).fields().get(ShardingErrorLogTagKeys.EVENT),
is(ShardingErrorLogTagKeys.EVENT_ERROR_TYPE));
-
assertThat(actualLogEntries.get(0).fields().get(ShardingErrorLogTagKeys.ERROR_KIND),
is(expectedException.getName()));
-
assertThat(actualLogEntries.get(0).fields().get(ShardingErrorLogTagKeys.MESSAGE),
is(expectedErrorMessage));
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHookTest.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHookTest.java
deleted file mode 100644
index d69a06a..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingParsingHookTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.mock.MockSpan;
-import io.opentracing.tag.Tags;
-import org.apache.shardingsphere.tracing.opentracing.constant.ShardingTags;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.parser.hook.ParsingHook;
-import org.apache.shardingsphere.infra.parser.hook.ParsingHookRegistry;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-
-public final class OpenTracingParsingHookTest extends BaseOpenTracingHookTest {
-
- private final ParsingHookRegistry registry =
ParsingHookRegistry.getInstance();
-
- @BeforeClass
- public static void registerSPI() {
- ShardingSphereServiceLoader.register(ParsingHook.class);
- }
-
- @Test
- public void assertExecuteSuccess() {
- registry.start("SELECT * FROM XXX;");
- registry.finishSuccess(mock(SQLStatement.class));
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/parseSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM XXX;"));
- }
-
- @Test
- public void assertExecuteFailure() {
- registry.start("SELECT * FROM XXX;");
- registry.finishFailure(new ShardingSphereException("parse SQL error"));
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/parseSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM XXX;"));
- assertSpanError(ShardingSphereException.class, "parse SQL error");
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHookTest.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHookTest.java
deleted file mode 100644
index 0f8e2c6..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingRootInvokeHookTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
-import org.apache.shardingsphere.infra.hook.RootInvokeHook;
-import org.apache.shardingsphere.infra.hook.SPIRootInvokeHook;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public final class OpenTracingRootInvokeHookTest extends
BaseOpenTracingHookTest {
-
- private final RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();
-
- @BeforeClass
- public static void registerSPI() {
- ShardingSphereServiceLoader.register(RootInvokeHook.class);
- }
-
- @Test
- public void assertRootInvoke() {
- rootInvokeHook.start();
-
assertTrue(ExecutorDataMap.getValue().containsKey(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION));
- rootInvokeHook.finish(1);
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHookTest.java
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHookTest.java
deleted file mode 100644
index c1ada67..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/OpenTracingSQLExecutionHookTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.tracing.opentracing.hook;
-
-import io.opentracing.ActiveSpan;
-import io.opentracing.ActiveSpan.Continuation;
-import io.opentracing.mock.MockSpan;
-import io.opentracing.tag.Tags;
-import org.apache.shardingsphere.tracing.opentracing.constant.ShardingTags;
-import org.apache.shardingsphere.infra.executor.sql.hook.SPISQLExecutionHook;
-import org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public final class OpenTracingSQLExecutionHookTest extends
BaseOpenTracingHookTest {
-
- private final SQLExecutionHook sqlExecutionHook = new
SPISQLExecutionHook();
-
- private ActiveSpan activeSpan;
-
- @BeforeClass
- public static void registerSPI() {
- ShardingSphereServiceLoader.register(SQLExecutionHook.class);
- }
-
- @Before
- public void setUp() {
- activeSpan = mockActiveSpan();
- }
-
- private ActiveSpan mockActiveSpan() {
- Continuation continuation = mock(Continuation.class);
- ActiveSpan result = mock(ActiveSpan.class);
- when(continuation.activate()).thenReturn(result);
-
ExecutorDataMap.getValue().put(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION,
continuation);
- return result;
- }
-
- @After
- public void tearDown() {
-
ExecutorDataMap.getValue().remove(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION);
- }
-
- @Test
- public void assertExecuteSuccessForTrunkThread() {
- DataSourceMetaData dataSourceMetaData = mock(DataSourceMetaData.class);
- when(dataSourceMetaData.getHostName()).thenReturn("localhost");
- when(dataSourceMetaData.getPort()).thenReturn(8888);
- sqlExecutionHook.start("success_ds", "SELECT * FROM success_tbl;",
Arrays.asList("1", 2), dataSourceMetaData, true, null);
- sqlExecutionHook.finishSuccess();
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/executeSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.PEER_HOSTNAME.getKey()),
is("localhost"));
- assertThat(actualTags.get(Tags.PEER_PORT.getKey()), is(8888));
- assertThat(actualTags.get(Tags.DB_TYPE.getKey()), is("sql"));
- assertThat(actualTags.get(Tags.DB_INSTANCE.getKey()),
is("success_ds"));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM success_tbl;"));
- assertThat(actualTags.get(ShardingTags.DB_BIND_VARIABLES.getKey()),
is("[1, 2]"));
- verify(activeSpan, times(0)).deactivate();
- sqlExecutionHook.start("success_ds", "SELECT * FROM success_tbl;",
null, dataSourceMetaData, true, null);
- sqlExecutionHook.finishSuccess();
- }
-
- @Test
- public void assertExecuteSuccessForTrunkThreadWhenParamsIsNull() {
- DataSourceMetaData dataSourceMetaData = mock(DataSourceMetaData.class);
- when(dataSourceMetaData.getHostName()).thenReturn("localhost");
- when(dataSourceMetaData.getPort()).thenReturn(8888);
- sqlExecutionHook.start("success_ds", "SELECT * FROM success_tbl;",
null, dataSourceMetaData, true, null);
- sqlExecutionHook.finishSuccess();
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/executeSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.PEER_HOSTNAME.getKey()),
is("localhost"));
- assertThat(actualTags.get(Tags.PEER_PORT.getKey()), is(8888));
- assertThat(actualTags.get(Tags.DB_TYPE.getKey()), is("sql"));
- assertThat(actualTags.get(Tags.DB_INSTANCE.getKey()),
is("success_ds"));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM success_tbl;"));
- assertThat(actualTags.get(ShardingTags.DB_BIND_VARIABLES.getKey()),
is(""));
- verify(activeSpan, times(0)).deactivate();
- }
-
- @Test
- public void assertExecuteSuccessForBranchThread() {
- DataSourceMetaData dataSourceMetaData = mock(DataSourceMetaData.class);
- when(dataSourceMetaData.getHostName()).thenReturn("localhost");
- when(dataSourceMetaData.getPort()).thenReturn(8888);
- sqlExecutionHook.start("success_ds", "SELECT * FROM success_tbl;",
Arrays.asList("1", 2), dataSourceMetaData, false, ExecutorDataMap.getValue());
- sqlExecutionHook.finishSuccess();
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/executeSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.PEER_HOSTNAME.getKey()),
is("localhost"));
- assertThat(actualTags.get(Tags.PEER_PORT.getKey()), is(8888));
- assertThat(actualTags.get(Tags.DB_TYPE.getKey()), is("sql"));
- assertThat(actualTags.get(Tags.DB_INSTANCE.getKey()),
is("success_ds"));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM success_tbl;"));
- assertThat(actualTags.get(ShardingTags.DB_BIND_VARIABLES.getKey()),
is("[1, 2]"));
- verify(activeSpan).deactivate();
- }
-
- @Test
- public void assertExecuteFailure() {
- DataSourceMetaData dataSourceMetaData = mock(DataSourceMetaData.class);
- when(dataSourceMetaData.getHostName()).thenReturn("localhost");
- when(dataSourceMetaData.getPort()).thenReturn(8888);
- sqlExecutionHook.start("failure_ds", "SELECT * FROM failure_tbl;",
Collections.emptyList(), dataSourceMetaData, true, null);
- sqlExecutionHook.finishFailure(new RuntimeException("SQL execution
error"));
- MockSpan actual = getActualSpan();
- assertThat(actual.operationName(), is("/ShardingSphere/executeSQL/"));
- Map<String, Object> actualTags = actual.tags();
- assertThat(actualTags.get(Tags.COMPONENT.getKey()),
is(ShardingTags.COMPONENT_NAME));
- assertThat(actualTags.get(Tags.SPAN_KIND.getKey()),
is(Tags.SPAN_KIND_CLIENT));
- assertThat(actualTags.get(Tags.PEER_HOSTNAME.getKey()),
is("localhost"));
- assertThat(actualTags.get(Tags.PEER_PORT.getKey()), is(8888));
- assertThat(actualTags.get(Tags.DB_TYPE.getKey()), is("sql"));
- assertThat(actualTags.get(Tags.DB_INSTANCE.getKey()),
is("failure_ds"));
- assertThat(actualTags.get(Tags.DB_STATEMENT.getKey()), is("SELECT *
FROM failure_tbl;"));
- assertThat(actualTags.get(ShardingTags.DB_BIND_VARIABLES.getKey()),
is(""));
- assertSpanError(RuntimeException.class, "SQL execution error");
- verify(activeSpan, times(0)).deactivate();
- }
-}
diff --git
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
deleted file mode 100644
index c9217d3..0000000
---
a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-mock-maker-inline
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
index 1811386..5d317e6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
@@ -130,12 +130,6 @@
<version>${project.parent.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-tracing-opentracing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<scope>compile</scope>
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
index 2b2a293..93916fa 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
@@ -32,7 +32,6 @@ import
org.apache.shardingsphere.proxy.database.DatabaseServerInfo;
import org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy;
import org.apache.shardingsphere.proxy.initializer.BootstrapInitializer;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
-import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
import
org.apache.shardingsphere.transaction.context.impl.StandardTransactionContexts;
@@ -61,7 +60,6 @@ public abstract class AbstractBootstrapInitializer implements
BootstrapInitializ
String xaTransactionMangerType =
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
TransactionContexts transactionContexts =
decorateTransactionContexts(createTransactionContexts(metaDataContexts),
xaTransactionMangerType);
ProxyContext.getInstance().init(metaDataContexts, transactionContexts);
- initOpenTracing();
setDatabaseServerInfo();
initLockContext();
initScalingWorker(yamlConfig);
@@ -101,12 +99,6 @@ public abstract class AbstractBootstrapInitializer
implements BootstrapInitializ
return new StandardTransactionContexts(transactionManagerEngines);
}
- private void initOpenTracing() {
- if
(ProxyContext.getInstance().getMetaDataContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_OPENTRACING_ENABLED))
{
- OpenTracingTracer.init();
- }
- }
-
private void setDatabaseServerInfo() {
Optional<DataSource> dataSourceSample =
ProxyContext.getInstance().getDataSourceSample();
if (dataSourceSample.isPresent()) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 74a26e3..c3ae7d3 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -25,8 +25,6 @@ import
org.apache.shardingsphere.db.protocol.packet.CommandPacket;
import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import org.apache.shardingsphere.infra.hook.RootInvokeHook;
-import org.apache.shardingsphere.infra.hook.SPIRootInvokeHook;
import
org.apache.shardingsphere.replicaquery.route.engine.impl.PrimaryVisitedManager;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionStatus;
@@ -63,10 +61,7 @@ public final class CommandExecutorTask implements Runnable {
*/
@Override
public void run() {
- RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();
- rootInvokeHook.start();
boolean isNeedFlush = false;
- int connectionSize = 0;
try (PacketPayload payload =
databaseProtocolFrontendEngine.getCodecEngine().createPacketPayload((ByteBuf)
message)) {
ConnectionStatus connectionStatus =
backendConnection.getConnectionStatus();
if
(!backendConnection.getTransactionStatus().isInConnectionHeldTransaction()) {
@@ -74,7 +69,6 @@ public final class CommandExecutorTask implements Runnable {
connectionStatus.switchToUsing();
}
isNeedFlush = executeCommand(context, payload, backendConnection);
- connectionSize = backendConnection.getConnectionSize();
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
@@ -88,7 +82,6 @@ public final class CommandExecutorTask implements Runnable {
exceptions.addAll(backendConnection.closeConnections(false));
}
processClosedExceptions(exceptions);
- rootInvokeHook.finish(connectionSize);
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
index b405292..fec0f6e 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
@@ -92,7 +92,6 @@ public final class CommandExecutorTaskTest {
@Test
public void assertRunNeedFlushByFalse() throws SQLException {
- when(backendConnection.getConnectionSize()).thenReturn(1);
when(queryCommandExecutor.execute()).thenReturn(Collections.emptyList());
when(executeEngine.getCommandPacket(eq(payload),
eq(commandPacketType), eq(backendConnection))).thenReturn(commandPacket);
when(executeEngine.getCommandExecutor(eq(commandPacketType),
eq(commandPacket), eq(backendConnection))).thenReturn(queryCommandExecutor);
@@ -113,7 +112,6 @@ public final class CommandExecutorTaskTest {
@Test
public void assertRunNeedFlushByTrue() throws SQLException {
- when(backendConnection.getConnectionSize()).thenReturn(1);
when(queryCommandExecutor.execute()).thenReturn(Collections.singletonList(databasePacket));
when(executeEngine.getCommandPacket(eq(payload),
eq(commandPacketType), eq(backendConnection))).thenReturn(commandPacket);
when(executeEngine.getCommandExecutor(eq(commandPacketType),
eq(commandPacket), eq(backendConnection))).thenReturn(queryCommandExecutor);
@@ -139,7 +137,6 @@ public final class CommandExecutorTaskTest {
public void assertRunByCommandExecutor() throws SQLException {
when(frontendContext.isFlushForPerCommandPacket()).thenReturn(true);
when(engine.getFrontendContext()).thenReturn(frontendContext);
- when(backendConnection.getConnectionSize()).thenReturn(1);
when(commandExecutor.execute()).thenReturn(Collections.singletonList(databasePacket));
when(executeEngine.getCommandPacket(eq(payload),
eq(commandPacketType), eq(backendConnection))).thenReturn(commandPacket);
when(executeEngine.getCommandExecutor(eq(commandPacketType),
eq(commandPacket), eq(backendConnection))).thenReturn(commandExecutor);